Page MenuHomePhabricator

Update ContentTranslation for changes in AbuseFilter and SpamBlacklist API error responses
Closed, DuplicatePublic

Description

API error responses generated by AbuseFilter and SpamBlacklist have changed, as announced here: https://lists.wikimedia.org/pipermail/mediawiki-api-announce/2019-September/000148.html (relevant task: T229539).

It appears you have special handling for the old responses. It should be updated, otherwise it will probably show a generic error message instead of a more specific one.

extensions/ContentTranslation/modules/mw.cx.TargetArticle.js:
  222: 		// {"result":"error","edit":{"spamblacklist":"facebook.com","result":"Failure"}}
  223: 		if ( editResult.spamblacklist ) {
  225: 				mw.msg( 'cx-publish-error-spam-blacklist', editResult.spamblacklist ),
  230: 		// Handle abusefilter errors.
  231: 		if ( editResult.code && editResult.code.indexOf( 'abusefilter' ) === 0 ) {

extensions/ContentTranslation/modules/eventlogging/ext.cx.eventlogging.translation.js:
   26: 			mw.hook( 'mw.cx.translation.abusefilter' ).add( this.logAbuseFilter );
  122: 			var abuseFilterCodes = [ 'abusefilter-warning', 'abusefilter-disallowed' ];
  129: 				trace.edit.abusefilter
  138: 					trace.edit.abusefilter.id

extensions/ContentTranslation/modules/eventlogging/legacy/ext.cx.eventlogging.translation.js:
  220: 			var abuseFilterCodes = [ 'abusefilter-warning', 'abusefilter-disallowed' ];
  227: 				trace.edit.abusefilter
  236: 					trace.edit.abusefilter.id

extensions/ContentTranslation/modules/publish/ext.cx.publish.js:
  299: 				// Handle abusefilter errors.
  300: 				if ( details.edit.code && details.edit.code.indexOf( 'abusefilter' ) === 0 ) {
  305: 					// {"result":"error","edit":{"spamblacklist":"facebook.com","result":"Failure"}}

extensions/ContentTranslation/tests/phpunit/AbuseFilterCheckTest.php:
  107: 				[ 'disallow' => [ 'abusefilter-disallow' ] ],
  109: 					'disallow' => [ 'action' => 'disallow', 'parameters' => [ 'abusefilter-disallow' ] ]
  114: 				[ 'warn' => [ 'abusefilter-warning-cx' ] ],
  118: 						'parameters' => [ 'abusefilter-warning-cx' ],
  119: 						'messageHtml' => wfMessage( 'abusefilter-warning-cx' )
  142: 				[ 'disallow' => [ 'abusefilter-disallow' ], 'degroup' => [] ],
  144: 					'disallow' => [ 'action' => 'disallow', 'parameters' => [ 'abusefilter-disallow' ] ],
  178: 				[ 'disallow' => [ 'abusefilter-disallow-cx' ] ],
  180: 					'disallow' => [ 'action' => 'disallow', 'parameters' => [ 'abusefilter-disallow-cx' ] ]
  186: 				[ 'warn' => [ 'abusefilter-warning-cx2' ] ],
  190: 						'parameters' => [ 'abusefilter-warning-cx2' ],
  191: 						'messageHtml' => wfMessage( 'abusefilter-warning-cx2' )
  242: 				[ 'disallow' => [ 'abusefilter-disallow-cx2' ] ],

Event Timeline

Restricted Application added a subscriber: Liuxinyu970226. · View Herald TranscriptWed, Sep 11, 10:43 PM
Restricted Application removed a subscriber: Liuxinyu970226. · View Herald TranscriptThu, Sep 12, 7:39 AM

We are on it :)

I don't see what need to be changed in AbuseFilterCheckTest.php. The rest is changed as part of T232583.

@Nikerabbit Nice, thank you :)

@Petar.petkovic It might be fine, I just copy-pasted search results for 'abusefilter' and 'spamblacklist' and only removed obvious false positives (like code comments).