Page MenuHomePhabricator

Spam Blacklist blows up API edits
Closed, ResolvedPublic

Description

Patch to add API support to Spam Blacklist

Regarding revision r42580.

When the spam blacklist triggers on an API edit, MediaWiki simply dies with a 500 Internal Server Error instead of returning any sort of proper error code. If php is configured not to output errors to the browser, the body of the error is an empty page; if it does output errors, the following is produced: (with php 5.2.6)

<br />
<b>Catchable fatal error</b>: Argument 2 passed to Parser::parse() must be an instance of Title, null given, called in /usr/local/src/MediaWiki/phase3/includes/OutputPage.php on line 633 and defined in <b>/usr/local/src/MediaWiki/phase3/includes/parser/Parser.php</b> on line <b>300</b><br />

The attached patch adds API support to Spam Blacklist, although I'm sure there is more than one way to do it. With this patch, an API edit attempt will now output something useful instead of crashing:

<?xml version="1.0"?><api><edit spamblacklist="http://blacklistme.example.com" result="Failure" /></api>


Version: unspecified
Severity: normal

Attached:

Details

Reference
bz16120

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:20 PM
bzimport added a project: SpamBlacklist.
bzimport set Reference to bz16120.
bzimport added a subscriber: Unknown Object (MLST).

(In reply to comment #0)

Created an attachment (id=5470) [details]
Patch to add API support to Spam Blacklist

Regarding revision r42580.

That revision is totally unrelated. Sure you didn't get the number wrong?

When the spam blacklist triggers on an API edit, MediaWiki simply dies with a
500 Internal Server Error instead of returning any sort of proper error code.
If php is configured not to output errors to the browser, the body of the error
is an empty page; if it does output errors, the following is produced: (with
php 5.2.6)

<br />
<b>Catchable fatal error</b>: Argument 2 passed to Parser::parse() must be an
instance of Title, null given, called in
/usr/local/src/MediaWiki/phase3/includes/OutputPage.php on line 633 and defined
in <b>/usr/local/src/MediaWiki/phase3/includes/parser/Parser.php</b> on line
<b>300</b><br />

The attached patch adds API support to Spam Blacklist, although I'm sure there
is more than one way to do it. With this patch, an API edit attempt will now
output something useful instead of crashing:

<?xml version="1.0"?><api><edit spamblacklist="http://blacklistme.example.com"
result="Failure" /></api>

Looks good. is_null($wgTitle) is maybe not ideal to check for API edit mode, but it's the best we have right now.

(In reply to comment #1)

(In reply to comment #0)

Regarding revision r42580.

That revision is totally unrelated. Sure you didn't get the number wrong?

It was the revision reported by "svn info" on my local copy of the tree when I tested this and created the patch. Sorry for the confusion.