Template talk:Ifexist not redirect

Blank page

 * this template will return "yes" for a blank page (see /testcases). Is this intentional? I wanted to use this template for something, but would like to treat a blank page the same as a non-existent page. &mdash; Martin (MSGJ · talk) 15:03, 10 March 2016 (UTC)
 * That particular test case hadn't crossed my mind, but realistically, it should return false as it would with a redirect. To make it work, I need a template that returns the size of an article to check if it's greater than zero (zero = empty). However, transcluding the article then using str len won't work if the article is too big. Alex&#124;The&#124;Whovian ? 21:47, 10 March 2016 (UTC)
 * You can use the PAGESIZE magic word. I've put some code in Template:Ifexist not redirect/sandbox and updated test cases. &mdash; Martin (MSGJ · talk) 22:19, 10 March 2016 (UTC)
 * Great stuff, the template's been updated, then. There's also some easy testcases in the documentation. Alex&#124;The&#124;Whovian ? 03:00, 11 March 2016 (UTC)
 * Nice. &mdash; Martin (MSGJ · talk) 08:54, 11 March 2016 (UTC)

Syntax
Instead of just returning "yes" would it make more sense if you called it like this This would avoid the need to use an additional parser function, i.e. when using this I think the former is slightly simpler. &mdash; Martin (MSGJ · talk) 08:57, 11 March 2016 (UTC)
 * Code on sandbox, testcases updated. &mdash; Martin (MSGJ · talk) 09:04, 11 March 2016 (UTC)
 * ✅ &mdash; Martin (MSGJ · talk) 09:16, 14 March 2016 (UTC)
 * How would one deal with the following code? This is in the old format, and is currently in use at Template:Infobox television season. The usage is if the first page exists OR the second page exists OR any of the other parameters are true THEN do something.
 * Alex&#124;The&#124;Whovian ? 09:21, 14 March 2016 (UTC)
 * My head is spinning. Not sure if there is an easier way to do that, but the previous behaviour is respected, so it should work fine. &mdash; Martin (MSGJ · talk) 09:27, 14 March 2016 (UTC)
 * So, we should ignore the other examples, and give support for only one usage of the template. I'll figure something out! Luckily I haven't implemented the granularity edits to the television season template yet, else there'd be no links for previous/next seasons. Alex&#124;The&#124;Whovian ? 09:31, 14 March 2016 (UTC)
 * Given that it returns "yes" in the absence of, it should still work. Will test it out later. Alex&#124;The&#124;Whovian ? 09:39, 14 March 2016 (UTC)
 * That's what I meant when I said "previous behaviour is respected". Should still work fine, no need to change anything! Regards &mdash; Martin (MSGJ · talk) 09:45, 14 March 2016 (UTC)
 * That's what I meant when I said "previous behaviour is respected". Should still work fine, no need to change anything! Regards &mdash; Martin (MSGJ · talk) 09:45, 14 March 2016 (UTC)

Substitutable
I need to make the template substable, for something else I'm doing. Code on Template:Ifexist not redirect/sandbox. Any problems? &mdash; Martin (MSGJ · talk) 16:34, 21 March 2016 (UTC)
 * What for? This is a checking template. Alex&#124;The&#124;Whovian ? 21:35, 21 March 2016 (UTC)
 * Template:Substituted comment and Template:Substituted comment/subst - a long story &mdash; Martin (MSGJ · talk) 21:46, 21 March 2016 (UTC)
 * I see no issues. I can just copy the code across to "If actual article" or something if I want to recreate the template to its original intended simple purpose. Alex&#124;The&#124;Whovian ? 21:56, 21 March 2016 (UTC)
 * Safesubst works just as well in transclusion or substitution, so no need to make another template. &mdash; Martin (MSGJ · talk) 06:46, 22 March 2016 (UTC)

Bug: Expression error: Unexpected > operator

 * { {ifexist not redirect | 1=Talk:Kohala |2=yes |3=no }} — Talk:Kohala exists
 * { {ifexist not redirect | 1=Talk:Kohala/sub |2=yes |3=no }} — Talk:Kohala/sub does NOT exist
 * { {ifexist not redirect | 1=Talk:Kohala/GA1 |2=yes |3=no }} — Talk:Kohala/GA1 exists, and is NOT (empty)
 * { {ifexist not redirect | 1=Talk:Kohala/Comments |2=yes |3=no }} — Talk:Kohala/Comments exists, but is (empty)
 * voila: Talk:Kohala/Comments exists, but is (empty)! – wbm1058 (talk) 20:25, 15 May 2016 (UTC)

Comparing PAGESIZEs: If the page doesn't exist, the PAGESIZE is zero, but if it exists and is (empty), the PAGESIZE seems to be "(empty)" too!! Hence the error: it's not the expected integer value. – wbm1058 (talk) 21:09, 15 May 2016 (UTC)
 * { {PAGESIZE:Talk:Kohala/GA1}}:
 * { {PAGESIZE:Talk:Kohala/sub}}:
 * { {PAGESIZE:Talk:Kohala/Comments}}:

Use |R to get raw unformatted numbers: Makes no difference, other than removing the comma. wbm1058 (talk) 21:24, 15 May 2016 (UTC)
 * { {PAGESIZE:Talk:Kohala/GA1|R}}:
 * { {PAGESIZE:Talk:Kohala/sub|R}}:
 * { {PAGESIZE:Talk:Kohala/Comments|R}}:

OK, per mw:Help:Magic words, PAGESIZE is an expensive parser function for getting technical metadata of another page. MediaWiki r33551 - Code Review

Per mw:Help:Magic words, { {REVISIONSIZE}} returns the size (bytes of wikitext) of the current revision of this page. Added REVISIONSIZE variable to get the current size of a revision Of course, if use have to put this on a page to find out if the page is (empty), then it won't be (empty) anymore! wbm1058 (talk) 22:07, 15 May 2016 (UTC)

MediaWiki r44885 - Code Review Null revisions are stored in the DB with rev_len=NULL – wbm1058 (talk) 22:29, 15 May 2016 (UTC)

I have a fix in the sandbox that seems to work. It's not pretty, and it makes two expensive PAGESIZE calls. I guess that will do, unless someone has a more robust solution. wbm1058 (talk) 00:27, 16 May 2016 (UTC)
 * { {ifexist not redirect/sandbox | 1=Talk:Kohala/Comments |2=yes |3=no }} — Talk:Kohala/Comments exists, but is (empty)
 * Yes this issue came up at Template talk:WikiProject banner shell as well. Seems like a bug to me. Wonder why those bug tickets were closed as "resolved"? &mdash; Martin (MSGJ · talk) 10:03, 16 May 2016 (UTC)
 * I was wondering that myself. Can you help? Thanks, wbm1058 (talk) 12:10, 16 May 2016 (UTC)
 * I'm sorry, but I have no idea what the problem is here. Please explain? It seems that it was fixed before I got to look at it… Matma Rex talk 13:54, 16 May 2016 (UTC)
 * As Martin demonstrated below, a dummy edit to a blank page, followed by a reversion of that edit, "fixes" the issue. The two phabs I linked above-right seem to describe the issue perfectly; we don't understand why they've been closed as resolved, as the issue doesn't seem to be resolved.
 * I ran into this via patrolling Category:ParserFunction errors; see also Talk:Exoplanet, Talk:Golden-ringed dragonfly and Talk:Manx cat. We shouldn't have to make and revert dummy edits to fix this. Martin, please leave those as-is to aid reporting and debugging this. Thanks, wbm1058 (talk) 14:08, 16 May 2016 (UTC)
 * Sorry for fixing it. But if you look at the history of Talk:Kohala/Comments, the revision on 29 June 2014 had no size associated with it. It was this revision that was causing PAGESIZE to fail. &mdash; Martin (MSGJ · talk) 14:05, 16 May 2016 (UTC)
 * Fixed Talk:Kohala/Comments by making an edit and then reverting it &mdash; Martin (MSGJ · talk) 12:41, 16 May 2016 (UTC)


 * { {ifexist not redirect | 1=Talk:Exoplanet/Comments |2=yes |3=no }} — Talk:Exoplanet/Comments exists, but is (empty)
 * – there's another one that hasn't been "fixed" by dummy edits yet. wbm1058 (talk) 14:16, 16 May 2016 (UTC)


 * Template:Ifexist not redirect/testcases uses this example to demonstrate my kludgey work-around: (diff)
 * Only after checking to see that PAGESIZE, which is supposed to be of data-type integer, is not NULL, can we safely check to see whether it is > 0. – wbm1058 (talk) 14:53, 16 May 2016 (UTC)

OK, thanks for the explanation. As for what to do about it… I think we could safely make just return 0 for the broken pages. Back when T20998 was filed this was not possible (since all null revisions were missing the rev_len field, even for pages which had text), but the bug we discovered here only affected pages which were empty anyway. I'm not sure if it'll be feasible to fix the data, there is no index on rev_len in the database and a query to find the affected revisions is probably going to take multiple days to execute (it took ~15 minutes to scan a period of three days in 2014), and that's not considering all other wikis. I'll reopen and fix T20998, and file a separate bug about this. Matma Rex talk 17:23, 16 May 2016 (UTC)
 * This doesn't seem to be relevant to T18748 Null revisions are stored in the database with rev_len=null, which was filed and fixed in 2008 (and the missing data was backfilled per T14188 in 2010 and T48183 in 2013); the examples you've given are mostly from 2014. So the incorrect data must be caused by some other bug.
 * I went looking in MediaWiki commit log for changes related to revision length made after 1 September 2014 (the most recent example you pointed out), and quickly chanced upon 4fb4ad91 Don't clobber revision size of 0 (163458), which is apparently what fixed this problem. The bug seems to have been introduced with ContentHandler in 429ae88d, 2012-ish (I can't find this commit in Gerrit, I think it's from SVN days).
 * T20998 returns empty string when top revision of page has no associated revision length definitely was not fixed (it was just presumed irrelevant because the data was backfilled, per T14188).
 * Filed T135414 about the missing data and submitted 288997 to fix PAGESIZE. Matma Rex talk 18:13, 16 May 2016 (UTC)
 * Perfect. Thanks so much for the quick response! – wbm1058 (talk) 20:21, 16 May 2016 (UTC)
 * This problem should be fixed with next week's deployment (Wikipedias are on Thursday). for buggy pages will just return 0. Matma Rex talk 19:32, 22 May 2016 (UTC)