Last modified: 2008-05-28 09:15:09 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 T14038, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 12038 - Extension:Assert Edit appears to have no effect when called from API
Extension:Assert Edit appears to have no effect when called from API
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
General/Unknown (Other open bugs)
unspecified
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
http://en.wikipedia.org/w/index.php?t...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-11-19 13:39 UTC by ais523
Modified: 2008-05-28 09:15 UTC (History)
3 users (show)

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


Attachments

Description ais523 2007-11-19 13:39:56 UTC
(Component is wrong, AssertEdit doesn't seem to be in the component box yet.)

According to [[Special:Version]], [[mw:Extension:Assert Edit]] is installed on enwiki (at least), but it doesn't appear to do anything at the moment; the URL referenced should cause an assertion failure, but instead acts as it would if the extension weren't installed. I couldn't cause an assertion failure with any other URL I tried either; not with /w/ or /wiki/ URLs, nor with any of the six assertions mentioned on the extension description page. I haven't tried on wikis other than enwiki.
Comment 1 Steve Sanbeg 2007-11-19 18:01:00 UTC
The assertions are only checked when you hit the "edit" tab, since bot frameworks tend to bypass the page view, and grab the content directly from the edit view.

You will currently get the expected error it you view 

http://en.wikipedia.org/w/index.php?title=Main_Page&action=edit&assert=false
Comment 2 Max Semenik 2008-05-23 20:46:23 UTC
It works for normal editing, but ironically not for API editing, where it's most needed. When parsing page HTML, a bot can learn that it has logged off by looking up JS variables, but there is no such easy method for API.
Comment 3 Steve Sanbeg 2008-05-27 15:51:00 UTC
(In reply to comment #2)
> It works for normal editing, but ironically not for API editing, where it's
> most needed. When parsing page HTML, a bot can learn that it has logged off by
> looking up JS variables, but there is no such easy method for API.
> 

It looks like the API doesn't set the global request object, so the extension doesn't have access to parameters from the URL.  It's probably necessary for the API to do something like "$wgRequest = $this->getMain()->getRequest()" somewhere, or have some other way of passing these arguments to the extension.
Comment 4 Roan Kattouw 2008-05-27 15:57:25 UTC
Assert Edit uses the AlternateEdit hook, which probably shouldn't even be in the API edit codepath. The extension should be fixed to use the APIEditBeforeSave hook instead. $wgRequest IS set in the API, though, look at api.php:74
Comment 5 Steve Sanbeg 2008-05-28 02:19:34 UTC
I'm not sure why it doesn't work then, although I obviously haven't looked too carefully at the API yet.  It looks like APIEditBeforeSave hides the normal request, and replaces it with a new one for the save, so that may not work unless it pass unrecognized options to the extension.
  
Comment 6 Roan Kattouw 2008-05-28 09:15:09 UTC
(In reply to comment #5)
> I'm not sure why it doesn't work then, although I obviously haven't looked too
> carefully at the API yet.  It looks like APIEditBeforeSave hides the normal
> request, and replaces it with a new one for the save, so that may not work
> unless it pass unrecognized options to the extension.
> 

You're right: it seems I've *deliberately* done that for hooks inside EditPage. Probably best to do that only after APIEditBeforeSave is run. Fixed in r35472

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


Navigation
Links