Extension:Assert Edit appears to have no effect when called from API
Closed, ResolvedPublic

Description

Author: ais523

Description:
(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.


Version: unspecified
Severity: normal
URL: http://en.wikipedia.org/w/index.php?title=Main_Page&assert=false

bzimport added a subscriber: wikibugs-l.
bzimport set Reference to bz12038.
bzimport created this task.Via LegacyNov 19 2007, 1:39 PM
bzimport added a comment.Via ConduitNov 19 2007, 6:01 PM

ssanbeg wrote:

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

MaxSem added a comment.Via ConduitMay 23 2008, 8:46 PM

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.

bzimport added a comment.Via ConduitMay 27 2008, 3:51 PM

ssanbeg wrote:

(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.

Catrope added a comment.Via ConduitMay 27 2008, 3:57 PM

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

bzimport added a comment.Via ConduitMay 28 2008, 2:19 AM

ssanbeg wrote:

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.

Catrope added a comment.Via ConduitMay 28 2008, 9:15 AM

(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

Add Comment

Column Prototype
This is a very early prototype of a persistent column. It is not expected to work yet, and leaving it open will activate other new features which will break things. Press "\" (backslash) on your keyboard to close it now.