Template talk:Ifexist not redirect

Active discussions

Blank pageEdit

AlexTheWhovian: 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. — Martin (MSGJ · talk) 15:03, 10 March 2016 (UTC)

@MSGJ: 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|The|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. — 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|The|Whovian? 03:00, 11 March 2016 (UTC)
Nice. — Martin (MSGJ · talk) 08:54, 11 March 2016 (UTC)


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

{{#ifeq:{{Ifexist not redirect|PAGENAME}}|yes|DO THIS IF YES|OTHERWISE DO THIS}}

I think the former is slightly simpler. — Martin (MSGJ · talk) 08:57, 11 March 2016 (UTC)

Code on sandbox, testcases updated. — Martin (MSGJ · talk) 09:04, 11 March 2016 (UTC)
  Deployed — 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.
{{#if:{{ifexist not redirect|PAGE1}}{{ifexist not redirect|PAGE2}}{{{multiple other variables|}}}|{{ucfirst:{{{season_type|season}}}}} chronology|}}
Alex|The|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. — 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|The|Whovian? 09:31, 14 March 2016 (UTC)
Given that it returns "yes" in the absence of {{{2}}}, it should still work. Will test it out later. Alex|The|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 — Martin (MSGJ · talk) 09:45, 14 March 2016 (UTC)


I need to make the template substable, for something else I'm doing. Code on Template:Ifexist not redirect/sandbox. Any problems? — Martin (MSGJ · talk) 16:34, 21 March 2016 (UTC)

What for? This is a checking template. Alex|The|Whovian? 21:35, 21 March 2016 (UTC)
Template:Substituted comment and Template:Substituted comment/subst - a long story — 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|The|Whovian? 21:56, 21 March 2016 (UTC)
Safesubst works just as well in transclusion or substitution, so no need to make another template. — Martin (MSGJ · talk) 06:46, 22 March 2016 (UTC)

Bug: Expression error: Unexpected > operatorEdit

  • {{ifexist not redirect | 1=Talk:Kohala |2=yes |3=no }} yes — Talk:Kohala exists
  • {{ifexist not redirect | 1=Talk:Kohala/sub |2=yes |3=no }} no — Talk:Kohala/sub does NOT exist
  • {{ifexist not redirect | 1=Talk:Kohala/GA1 |2=yes |3=no }} no — Talk:Kohala/GA1 exists, and is NOT (empty)
  • {{ifexist not redirect | 1=Talk:Kohala/Comments |2=yes |3=no }} 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:

  • {{PAGESIZE:Talk:Kohala/GA1}}: 0
  • {{PAGESIZE:Talk:Kohala/sub}}: 0
  • {{PAGESIZE:Talk:Kohala/Comments}}: 0

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)

Use |R to get raw unformatted numbers:

  • {{PAGESIZE:Talk:Kohala/GA1|R}}: 0
  • {{PAGESIZE:Talk:Kohala/sub|R}}: 0
  • {{PAGESIZE:Talk:Kohala/Comments|R}}: 0

Makes no difference, other than removing the comma. wbm1058 (talk) 21:24, 15 May 2016 (UTC)

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

Per mw:Help:Magic words#Technical metadata, {{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.

  • {{ifexist not redirect/sandbox | 1=Talk:Kohala/Comments |2=yes |3=no }} no — Talk:Kohala/Comments exists, but is (empty)

I guess that will do, unless someone has a more robust solution. wbm1058 (talk) 00:27, 16 May 2016 (UTC)

Yes this issue came up at Template talk:WikiProject banner shell#Expression error at Talk:Kosovo as well. Seems like a bug to me. Wonder why those bug tickets were closed as "resolved"? — Martin (MSGJ · talk) 10:03, 16 May 2016 (UTC)
I was wondering that myself. @Matma Rex: Can you help? Thanks, wbm1058 (talk) 12:10, 16 May 2016 (UTC)
@Wbm1058: 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)
(edit conflict) @Matma Rex: 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. — Martin (MSGJ · talk) 14:05, 16 May 2016 (UTC)
Fixed Talk:Kohala/Comments by making an edit and then reverting it — Martin (MSGJ · talk) 12:41, 16 May 2016 (UTC)
  • {{ifexist not redirect | 1=Talk:Exoplanet/Comments |2=yes |3=no }} 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)
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 {{PAGESIZE:...}} 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 phab:T20998, and file a separate bug about this. Matma Rex talk 17:23, 16 May 2016 (UTC)

Filed phab:T135414 about the missing data and submitted gerrit: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)
@Wbm1058 and MSGJ: This problem should be fixed with next week's deployment (Wikipedias are on Thursday). {{PAGESIZE:}} for buggy pages will just return 0. Matma Rex talk 19:32, 22 May 2016 (UTC)
Return to "Ifexist not redirect" page.