Module talk:Check DYK hook

Script error
This 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. &#32; 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. &#32; 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 Sandbox
 * 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 ([//en.wikipedia.org/w/index.php?title=Module%3ACheck_DYK_hook&type=revision&diff=990969954&oldid=990966539 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)
 * seems to work yup. Thanks. I could never have caught that. &#32; 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)
 * 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)
 * 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)
 * 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)