Last modified: 2010-10-15 17:14:14 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T26792, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 24792 - API help caching doesn't vary on $wgUser->isAnon(), causes staleness
API help caching doesn't vary on $wgUser->isAnon(), causes staleness
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
API (Other open bugs)
unspecified
All All
: Normal minor (vote)
: ---
Assigned To: Roan Kattouw
: patch-reviewed
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-08-14 08:14 UTC by MZMcBride
Modified: 2010-10-15 17:14 UTC (History)
7 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Patch (733 bytes, patch)
2010-10-13 22:38 UTC, Sam Reed (reedy)
Details

Description MZMcBride 2010-08-14 08:14:19 UTC
From http://en.wiktionary.org/w/api.php
* action=purge *
  Purge the cache for the given titles.

This module requires read rights.
This module requires write rights.
Parameters:
  titles         - A list of titles
Example:
  api.php?action=purge&titles=Main_Page|API

From http://commons.wikimedia.org/w/api.php
* action=purge *
  Purge the cache for the given titles.

This module requires read rights.
This module requires write rights.
This module only accepts POST requests.
Parameters:
  titles         - A list of titles
Example:
  api.php?action=purge&titles=Main_Page|API

Commons says that it only accepts POST requests. The English Wiktionary does not. Something is wrong.
Comment 1 Bawolff (Brian Wolff) 2010-08-14 08:39:12 UTC
I think this might be due to caching the help message. action=purge only requires post rights if your an anon, but the cache key for the help message doesn't distinguish between logged in users and non-logged in users.

To test this theory, i went to http://commons.wikimedia.org/w/api.php which said POST needed for me at time of testing, but http://commons.wikimedia.org/w/api.php?version which uses a different cache key did not.
Comment 2 MZMcBride 2010-08-14 08:45:08 UTC
(In reply to comment #1)
> I think this might be due to caching the help message. action=purge only
> requires post rights if your an anon, but the cache key for the help message
> doesn't distinguish between logged in users and non-logged in users.

Yes, it seems you're right (I just tested a bit myself with curl and Firefox). Is there a bug about this already?
Comment 3 db [inactive,noenotif] 2010-08-21 15:31:37 UTC
Have you try it logged in on both wikis?

See at ApiPurge::mustBePosted()

	public function mustBePosted() {
		global $wgUser;
		return $wgUser->isAnon();
	}
Comment 4 MZMcBride 2010-08-21 15:41:48 UTC
(In reply to comment #3)
> Have you try it logged in on both wikis?
> 
> See at ApiPurge::mustBePosted()
> 
>     public function mustBePosted() {
>         global $wgUser;
>         return $wgUser->isAnon();
>     }

I tested logged in and logged out.

When I visit http://en.wiktionary.org/w/api.php right now logged in, the purge module says "This module only accepts POST requests."

As far as I understand, this behavior is wrong (or at least unexpected).
Comment 5 Roan Kattouw 2010-09-08 18:30:55 UTC
A nice and clean solution for this could be to allow modules to add to the cache key by overriding a base method.
Comment 6 MZMcBride 2010-09-08 18:47:01 UTC
It seems that the purge module is exceptional (it's probably the only module that makes a distinction between POST behavior based on logged-in status). Modifying the purge module to output a generic message in the documentation is probably the simplest solution, something like "If you're not logged in, you must POST this request."
Comment 7 Sam Reed (reedy) 2010-10-09 14:34:31 UTC
Seems like the ApiHelp caching is done seperately...

Adding a variance of the isAnon would take care of this...

$key = wfMemcKey( 'apihelp', $this->getModuleName(), $wgUser->isAnon(),
			SpecialVersion::getVersion( 'nodb' ) .
			$this->getMain()->getShowVersions() );
Comment 8 Sam Reed (reedy) 2010-10-13 22:38:03 UTC
Created attachment 7734 [details]
Patch

Stashing a patch for this so I don't accidentally commit/loose it. Still seems a sane way to go. Roan?
Comment 9 Roan Kattouw 2010-10-15 16:26:48 UTC
(In reply to comment #8)
> Created attachment 7734 [details]
> Patch
> 
> Stashing a patch for this so I don't accidentally commit/loose it. Still seems
> a sane way to go. Roan?

Looks good.
Comment 10 Sam Reed (reedy) 2010-10-15 17:14:14 UTC
r74810

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links