getprojectfile script sometimes pretends to succeed
Status: Beta
Brought to you by:
worden
sometimes is correctly says "401 unauthorized" when it doesn't have the right password to log in to the wiki, but in other cases it downloads and saves the HTML text of the "you must log in" wiki page, which is not desired.
Anonymous
The difference has to do with the setting of $wgWhitelistRead, the list of pages that are allowed even to non-logged-in users. By default it's only the login page and FAQ page. WorkingWiki.php adds Special:GetProjectFile to the list, and then has Special:GetProjectFile check whether the user is logged in and return a 401 Unauthorized if not. This allows S:GPF urls for images to work like any other images, and allows the getprojectfile script to detect the problem.
But getprojectfile should probably try to do something sane even if wiki admins decide not to allow Special:GetProjectFile to be whitelisted. Unfortunately, in that case, MediaWiki produces a normal-looking wiki page that just happens to include text telling the user to log in. What's a robust way to detect it?
Maybe there's a hook I can use to add something unmistakeable to the page?
Nope, there doesn't seem to be any hooks. Also, the text is internationalized, and I can't assume the error text will be in English.
I guess I could do the reverse, and have Special:GetProjectFile return a special header so I can detect its absence...
have sucessfully added 'X-Generator: WorkingWiki' header to Special:GetProjectFile output, I think. Still need to make getprojectfile script check for it.