Page MenuHomePhabricator

Argument 1 passed to ManualLogEntry::setComment() must be of the type string, null given
Closed, ResolvedPublicBUG REPORT

Description

What is the problem?

When attempting to import an article via the API on beta cluster, I get the exception:

{
    "error": {
        "code": "internal_api_error_TypeError",
        "info": "[YtVWGbvGl4HEfJ0enKBoDgAAABA] Exception caught: Argument 1 passed to ManualLogEntry::setComment() must be of the type string, null given, called in /srv/mediawiki/php-master/includes/specials/helpers/ImportReporter.php on line 169",
        "errorclass": "TypeError",
        "*": "TypeError at /srv/mediawiki/php-master/includes/logging/ManualLogEntry.php(190)\nfrom /srv/mediawiki/php-master/includes/logging/ManualLogEntry.php(190)\n#0 /srv/mediawiki/php-master/includes/specials/helpers/ImportReporter.php(169): ManualLogEntry->setComment(NULL)\n#1 /srv/mediawiki/php-master/includes/api/ApiImportReporter.php(59): ImportReporter->reportPage(Title, ForeignTitle, integer, integer, array)\n#2 /srv/mediawiki/php-master/includes/import/WikiImporter.php(625): ApiImportReporter->reportPage(Title, ForeignTitle, integer, integer, array)\n#3 /srv/mediawiki/php-master/includes/import/WikiImporter.php(964): WikiImporter->pageOutCallback(Title, ForeignTitle, integer, integer, array)\n#4 /srv/mediawiki/php-master/includes/import/WikiImporter.php(755): WikiImporter->handlePage()\n#5 /srv/mediawiki/php-master/includes/api/ApiImport.php(117): WikiImporter->doImport()\n#6 /srv/mediawiki/php-master/includes/api/ApiMain.php(1901): ApiImport->execute()\n#7 /srv/mediawiki/php-master/includes/api/ApiMain.php(875): ApiMain->executeAction()\n#8 /srv/mediawiki/php-master/includes/api/ApiMain.php(846): ApiMain->executeActionWithErrorHandling()\n#9 /srv/mediawiki/php-master/api.php(90): ApiMain->execute()\n#10 /srv/mediawiki/php-master/api.php(45): wfApiMain()\n#11 /srv/mediawiki/w/api.php(3): require(string)\n#12 {main}"
    },
    "servedby": "deployment-mediawiki11"
}
Steps to reproduce problem
  1. https://en.wikipedia.beta.wmflabs.org/wiki/Special:ApiSandbox#action=import&format=json&interwikisource=wikipedia%3Aen&interwikipage=Cat
  2. Click "Make request"
  3. Click "Correct token and resubmit"

Expected behavior: Article imported successfully
Observed behavior: Exception above

Environment

Wiki(s): https://en.wikipedia.beta.wmflabs.org and https://en.wikisource.beta.wmflabs.org and on my local docker wiki MediaWiki 1.39.0-alpha (0fcb9e6) 09:29, 18 July 2022.

Event Timeline

I can also reproduce this on my local docker (where import had previously worked), so I guess it is not just beta being misconfigured.

RhinosF1 triaged this task as Unbreak Now! priority.Jul 18 2022, 1:13 PM
RhinosF1 subscribed.

Blocker -> UBN!

Likely caused by https://gerrit.wikimedia.org/r/c/mediawiki/core/+/809314, ImportReporter should be always pass a string to setComment. Also, according to the documentation in __construct, $reason can only be string|bool, but the trace above suggests that NULL is also a possible value. I think the class should either restrict the type to just string, or to string|null and add an explicit cast.

Added the author and reviewer, if it doesn't get fixed by tomorrow, feel free to revert the patch.

Change 814852 had a related patch set uploaded (by MarkAHershberger; author: MarkAHershberger):

[mediawiki/core@master] Handle setComment for ImportReporter

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

Change 814852 merged by jenkins-bot:

[mediawiki/core@master] Handle setComment for specials

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

Urbanecm assigned this task to MarkAHershberger.
Urbanecm subscribed.

Steps from the description now lead to a successfully imported article, patch is merged. Problematic patch only made it to wmf.21 (and .20, but that won't be deployed), fix also made wmf.21 => this should no longer be a blocker.