Module talk:Check DYK hook
Appearance
Script error
[edit]@Frietjes and Mr. Stradivarius:
This [1] apparently 'fixed' some script errors, but broke the checks. At least, for entries ending with {{-?}}
and made Category:Pages with a malformed DYK entry balloon to 160+ 'malformed' entries, which were perfectly well-formed. Headbomb {t · c · p · b} 15:17, 27 November 2020 (UTC)
- It's possible that it did fix the script, but that the check itself didn't handle those entries. But this is LUA, so I can't diagnose anything here much. Headbomb {t · c · p · b} 15:18, 27 November 2020 (UTC)
- Headbomb, yes, before the fix those 160+ entries were in Category:Pages with script errors instead. I think the regular expression requires some changes you may be able to test it with
Live
"{{#invoke:Check DYK hook|isValidHook|1=... that director and screenwriter Travis Stevens paused renovations on his production company's house to film '''''[[Girl on the Third Floor]]'''''?}}"
= "yes""{{#invoke:Check DYK hook|isValidHook|1=... that director and screenwriter Travis Stevens paused renovations on his production company's house to film '''''[[Girl on the Third Floor]]'''''{{-?}}}"
= "yes"
Sandbox
"{{#invoke:Check DYK hook/sandbox|isValidHook|1=... that director and screenwriter Travis Stevens paused renovations on his production company's house to film '''''[[Girl on the Third Floor]]'''''?}}"
= "yes""{{#invoke:Check DYK hook/sandbox|isValidHook|1=... that director and screenwriter Travis Stevens paused renovations on his production company's house to film '''''[[Girl on the Third Floor]]'''''{{-?}}}}"
= "yes"
- not sure why we are getting a script error for the live template even with the
|1=
. Frietjes (talk) 15:26, 27 November 2020 (UTC)- Headbomb, it looks like the "match" used for whitespace cleaning was returning "nil" in those cases but changing it to a mw.ustring.gsub (see here) fixed it. or at least fixed it so both cases are showing valid and no script errors. Frietjes (talk) 15:42, 27 November 2020 (UTC)
- @Frietjes: seems to work yup. Thanks. I could never have caught that. Headbomb {t · c · p · b} 15:46, 27 November 2020 (UTC)
- Headbomb, unfortunately, for the "#if:" parser an error is the same as "yes" which is probably why it wasn't noticed earlier. Frietjes (talk) 15:52, 27 November 2020 (UTC)
- @Frietjes and Headbomb: Sorry, this was my mistake; I used
.*?
in the whitespace-trimming pattern, when it should have been.-
. The.*?
is how non-greedy matching works in PCRE regex, but Lua was interpreting that as a greedy match for any character, plus a literal question mark. So hooks that didn't have a literal question mark in (like ones containing {{-?}}) didn't match the pattern, meaning the whitespace-trimming code returned nil. Unfortunately, all the test cases that tested the whitespace trimming code contained question marks, so none of them picked this up. I've fixed the problem in the module and added some extra test cases so that this will get caught next time. I've also added a|hook=
parameter, which I thought seemed neater than|1=
for dealing with hooks that might contain an equals sign. — Mr. Stradivarius ♪ talk ♪ 12:42, 29 November 2020 (UTC)
- @Frietjes and Headbomb: Sorry, this was my mistake; I used
- Headbomb, unfortunately, for the "#if:" parser an error is the same as "yes" which is probably why it wasn't noticed earlier. Frietjes (talk) 15:52, 27 November 2020 (UTC)
- @Frietjes: seems to work yup. Thanks. I could never have caught that. Headbomb {t · c · p · b} 15:46, 27 November 2020 (UTC)
- Headbomb, it looks like the "match" used for whitespace cleaning was returning "nil" in those cases but changing it to a mw.ustring.gsub (see here) fixed it. or at least fixed it so both cases are showing valid and no script errors. Frietjes (talk) 15:42, 27 November 2020 (UTC)