Page MenuHomePhabricator

Argument 1 passed to AbuseFilter::contentToString() must implement interface Content
Closed, ResolvedPublic

Description

Catchable fatal error: Argument 1 passed to AbuseFilter::contentToString() must implement interface Content, null given, called in /srv/mediawiki/php-1.25wmf1/extensions/AbuseFilter/AbuseFilter.hooks.php on line 154 and defined at /srv/mediawiki/php-1.25wmf1/extensions/AbuseFilter/AbuseFilter.class.php on line 2297

Backtrace:

#0 /srv/mediawiki/php-1.25wmf1/extensions/AbuseFilter/AbuseFilter.class.php(2297): AbuseFilter::contentToString()
#1 /srv/mediawiki/php-1.25wmf1/extensions/AbuseFilter/AbuseFilter.hooks.php(154): AbuseFilter::contentToString(NULL)
#2 /srv/mediawiki/php-1.25wmf1/extensions/AbuseFilter/AbuseFilter.hooks.php(106): AbuseFilterHooks::filterEdit(Object(DerivativeContext), Object(Wikibase\ItemContent), 'Q15397877?Disch...', Object(Status), '/* wbeditentity...', false)
#3 [internal function]: AbuseFilterHooks::onEditFilterMergedContent(Object(DerivativeContext), Object(Wikibase\ItemContent), Object(Status), '/* wbeditentity...', Object(User), false)
#4 /srv/mediawiki/php-1.25wmf1/includes/Hooks.php(206): call_user_func_array('AbuseFilterHook...', Array)
#5 /srv/mediawiki/php-1.25wmf1/includes/GlobalFunctions.php(3991): Hooks::run('EditFilterMerge...', Array, NULL)
#6 /srv/mediawiki/php-1.25wmf1/extensions/Wikidata/extensions/Wikibase/repo/includes/EditEntity.php(778): wfRunHooks('EditFilterMerge...', Array)
#7 /srv/mediawiki/php-1.25wmf1/extensions/Wikidata/extensions/Wikibase/repo/includes/EditEntity.php(704): Wikibase\EditEntity->runEditFilterHooks('/* wbeditentity...')
#8 /srv/mediawiki/php-1.25wmf1/extensions/Wikidata/extensions/Wikibase/repo/includes/api/ApiWikibase.php(446): Wikibase\EditEntity->attemptSave('/* wbeditentity...', 18, '0b9fa35041cf3d1...')
#9 /srv/mediawiki/php-1.25wmf1/extensions/Wikidata/extensions/Wikibase/repo/includes/api/ModifyEntity.php(371): Wikibase\Api\ApiWikibase->attemptSaveEntity(Object(Wikibase\DataModel\Entity\Item), Object(Wikibase\Summary), 18)
#10 /srv/mediawiki/php-1.25wmf1/includes/api/ApiMain.php(932): Wikibase\Api\ModifyEntity->execute()
#11 /srv/mediawiki/php-1.25wmf1/includes/api/ApiMain.php(364): ApiMain->executeAction()
#12 /srv/mediawiki/php-1.25wmf1/includes/api/ApiMain.php(335): ApiMain->executeActionWithErrorHandling()
#13 /srv/mediawiki/php-1.25wmf1/api.php(85): ApiMain->execute()
#14 /srv/mediawiki/w/api.php(3): require('/srv/mediawiki/...')

Details

Reference
bz71545

Event Timeline

bzimport raised the priority of this task from to Normal.Nov 22 2014, 3:56 AM
bzimport added a project: AbuseFilter.
bzimport set Reference to bz71545.
bzimport added a subscriber: Unknown Object (MLST).
aude created this task.Oct 2 2014, 6:35 AM
hoo added a comment.Oct 13 2014, 7:59 PM

This actually is an AbuseFilter bug where AbuseFilter chokes on Revision::getContent returning null

gerritadmin wrote:

Change 166510 had a related patch set uploaded by Hoo man:
Check for Revision::getContent returning null

https://gerrit.wikimedia.org/r/166510

gerritadmin wrote:

Change 166522 had a related patch set uploaded by Jackmcbarn:
Remove negative caching from Revision::getContentInternal

https://gerrit.wikimedia.org/r/166522

gerritadmin wrote:

Change 166510 abandoned by Hoo man:
Check for Revision::getContent returning null

Reason:
Core change merged instead (https://gerrit.wikimedia.org/r/166522). Let's hope that fixes the issue

https://gerrit.wikimedia.org/r/166510

hoo added a comment.Oct 21 2014, 12:53 PM

Core patch approved, so that we no longer should see such revisions.

gerritadmin wrote:

Change 166522 merged by jenkins-bot:
Remove negative caching from Revision::getContentInternal

https://gerrit.wikimedia.org/r/166522

Zoglun reopened this task as Open.Apr 3 2017, 7:31 PM
Zoglun added a subscriber: Zoglun.

Is this bug reintroduced into MW 1.28.0 with Abuse Filter version https://phabricator.wikimedia.org/r/revision/mediawiki/extensions/AbuseFilter.git;c3be1ce87f62d3e721af6d11720ad4c1e353ff9c ?

Got following error when submit edit:

[d266dd92bb462822689f3650] /index.php?title=File:%E6%9A%B4%E9%A3%8E%E5%AD%90.jpg&action=submit TypeError from line 2476 of /wiki/extensions/AbuseFilter/AbuseFilter.class.php: Argument 1 passed to AbuseFilter::contentToString() must implement interface Content, null given, called in /wiki/extensions/AbuseFilter/AbuseFilter.hooks.php on line 95

Backtrace:

#0 /wiki/extensions/AbuseFilter/AbuseFilter.hooks.php(95): AbuseFilter::contentToString(NULL)
#1 /wiki/extensions/AbuseFilter/AbuseFilter.hooks.php(53): AbuseFilterHooks::filterEdit(RequestContext, WikitextContent, string, Status, string, boolean)
#2 /wiki/includes/Hooks.php(195): AbuseFilterHooks::onEditFilterMergedContent(RequestContext, WikitextContent, Status, string, User, boolean)
#3 /wiki/includes/EditPage.php(1634): Hooks::run(string, array)
#4 /wiki/includes/EditPage.php(2048): EditPage->runPostMergeFilters(WikitextContent, Status, User)
#5 /wiki/includes/EditPage.php(1467): EditPage->internalAttemptSave(NULL, boolean)
#6 /wiki/includes/EditPage.php(612): EditPage->attemptSave(NULL)
#7 /wiki/includes/actions/EditAction.php(59): EditPage->edit()
#8 /wiki/includes/actions/SubmitAction.php(38): EditAction->show()
#9 /wiki/includes/MediaWiki.php(495): SubmitAction->show()
#10 /wiki/includes/MediaWiki.php(289): MediaWiki->performAction(ImagePage, Title)
#11 /wiki/includes/MediaWiki.php(851): MediaWiki->performRequest()
#12 /wiki/includes/MediaWiki.php(512): MediaWiki->main()
#13 /wiki/index.php(43): MediaWiki->run()
#14 {main}

Seen still/again on 1.32.0-wmf.24:

SpecialUpload
PHP Fatal Error: Argument 1 passed to AbuseFilter::contentToString() must implement interface Content, null given

#0 /srv/mediawiki/php-1.32.0-wmf.24/extensions/AbuseFilter/includes/AbuseFilterHooks.php(801): NO_FUNCTION_GIVEN()
#1 /srv/mediawiki/php-1.32.0-wmf.24/extensions/AbuseFilter/includes/AbuseFilterHooks.php(729): AbuseFilterHooks::filterUpload(string, UploadFromFile, User, array, string, boolean, NULL)
#2 /srv/mediawiki/php-1.32.0-wmf.24/includes/Hooks.php(174): AbuseFilterHooks::onUploadVerifyUpload(UploadFromFile, User, array, string, boolean, NULL)
#3 /srv/mediawiki/php-1.32.0-wmf.24/includes/Hooks.php(202): Hooks::callHook(string, array, array, NULL)
#4 /srv/mediawiki/php-1.32.0-wmf.24/includes/upload/UploadBase.php(852): Hooks::run(string, array)
#5 /srv/mediawiki/php-1.32.0-wmf.24/includes/specials/SpecialUpload.php(568): UploadBase->performUpload(string, boolean, boolean, User, array)
#6 /srv/mediawiki/php-1.32.0-wmf.24/includes/specials/SpecialUpload.php(207): SpecialUpload->processUpload()
#7 /srv/mediawiki/php-1.32.0-wmf.24/includes/specialpage/SpecialPage.php(569): SpecialUpload->execute(NULL)
ApiUpload
PHP Fatal Error: Argument 1 passed to AbuseFilter::contentToString() must implement interface Content, null given

#0 /srv/mediawiki/php-1.32.0-wmf.24/extensions/AbuseFilter/includes/AbuseFilterHooks.php(801): NO_FUNCTION_GIVEN()
#1 /srv/mediawiki/php-1.32.0-wmf.24/extensions/AbuseFilter/includes/AbuseFilterHooks.php(729): AbuseFilterHooks::filterUpload(string, UploadFromFile, User, array, string, string, NULL)
#2 /srv/mediawiki/php-1.32.0-wmf.24/includes/Hooks.php(174): AbuseFilterHooks::onUploadVerifyUpload(UploadFromFile, User, array, string, string, NULL)
#3 /srv/mediawiki/php-1.32.0-wmf.24/includes/Hooks.php(202): Hooks::callHook(string, array, array, NULL)
#4 /srv/mediawiki/php-1.32.0-wmf.24/includes/upload/UploadBase.php(852): Hooks::run(string, array)
#5 /srv/mediawiki/php-1.32.0-wmf.24/includes/api/ApiUpload.php(828): UploadBase->performUpload(string, string, boolean, User, NULL)
#6 /srv/mediawiki/php-1.32.0-wmf.24/includes/api/ApiUpload.php(146): ApiUpload->performUpload(array)
#7 /srv/mediawiki/php-1.32.0-wmf.24/includes/api/ApiUpload.php(104): ApiUpload->getContextResult()
#8 /srv/mediawiki/php-1.32.0-wmf.24/includes/api/ApiMain.php(1587): ApiUpload->execute()
Impact

Some users who are using Special:Upload or ApiUpload receive a "Wikimedia Error - Technical problems" error page with no further information about what went wrong.

Daimona moved this task from Backlog to Future on the User-Daimona board.

Hm, looking at this, it seems like $revision::getContent() is returning null although $revision is not null. However, looking at RevisionRecord and similar classes, I couldn't find a case when this can happen, given that we use RAW as audience (so deleted content shouldn't be a problem). To avoid the error we could just check that $oldcontent is not null, but this wouldn't help much, as we should understand the root cause.

Daimona moved this task from Future to Waiting on the User-Daimona board.Oct 18 2018, 5:04 PM

Hm, unseen in the last 30 days. Maybe this was fixed in rEABF688eccea477a3a537c86066112bda7da202a8463?

matej_suchanek updated the task description. (Show Details)
matej_suchanek removed a subscriber: wikibugs-l-list.
Daimona closed this task as Resolved.Mar 30 2019, 12:06 PM
Daimona claimed this task.

Calling resolved, given that the EditFilterMergedContent hook is guaranteed to provide a valid Content object (that is then passed to contentToString).

Daimona moved this task from Waiting to Done on the User-Daimona board.Mar 30 2019, 12:06 PM
mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:12 PM