Page MenuHomePhabricator

validatepassword: Passing null to parameter #2 ($code) of type int is deprecated
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Visit to /w/api.php?action=validatepassword&password=qwerty&user=Example (module requires POST for requests)

What happens?:

[2024-04-10T17:39:36.454687+00:00] error.WARNING: [1a4524b8765d41133ee5c4af] /w/api.php?action=validatepassword&password=querty&user=Example   PHP Deprecated: Exception::__construct(): Passing null to parameter #2 ($code) of type int is deprecated {"exception":"[object] (ErrorException(code: 0): PHP Deprecated: Exception::__construct(): Passing null to parameter #2 ($code) of type int is deprecated at /www/[XXX]/tags/2024-04-07_15:54:39/includes/api/ApiUsageException.php:58)
[stacktrace]
#0 [internal function]: MWExceptionHandler::handleError(8192, 'Exception::__co...', '/www/[XXX]...', 58)
#1 /www/[XXX]/tags/2024-04-07_15:54:39/includes/api/ApiUsageException.php(58): Exception->__construct('The \"validatepa...', NULL, NULL)
#2 /www/[XXX]/tags/2024-04-07_15:54:39/includes/api/ApiUsageException.php(73): ApiUsageException->__construct(Object(ApiMain), Object(StatusValue), NULL, NULL)
#3 /www/[XXX]/tags/2024-04-07_15:54:39/includes/api/ApiBase.php(1516): ApiUsageException::newWithMessage(Object(ApiMain), Array, NULL, NULL, NULL)
#4 /www/[XXX]/tags/2024-04-07_15:54:39/includes/api/ApiBase.php(1690): ApiBase->dieWithError(Array, NULL, NULL, NULL)
#5 /www/[XXX]/tags/2024-04-07_15:54:39/includes/api/ApiMain.php(1878): ApiBase->dieWithErrorOrDebug(Array)
#6 /www/[XXX]/tags/2024-04-07_15:54:39/includes/api/ApiMain.php(1932): ApiMain->setupExternalResponse(Object(ApiValidatePassword), Array)
#7 /www/[XXX]/tags/2024-04-07_15:54:39/includes/api/ApiMain.php(912): ApiMain->executeAction()
#8 /www/[XXX]/tags/2024-04-07_15:54:39/includes/api/ApiMain.php(883): ApiMain->executeActionWithErrorHandling()
#9 /www/[XXX]/tags/2024-04-07_15:54:39/api.php(95): ApiMain->execute()
#10 /www/[XXX]/tags/2024-04-07_15:54:39/api.php(48): wfApiMain()
#11 {main}
","exception_url":"/w/api.php?action=validatepassword&password=querty&user=Example","reqId":"1a4524b8765d41133ee5c4af","caught_by":"mwe_handler"} []

What should have happened instead?:
No deprecation warning

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):
1.41.1 and PHP 8.2.7

Other information (browser name/version, screenshots, etc.):

Event Timeline

I can't replicate it on master, using my dev wiki (where user=Example doesn't exist, and not logged in)

{
    "validatepassword": {
        "validity": "Change",
        "validitymessages": [
            {
                "message": "passwordtooshort",
                "params": [
                    8
                ],
                "code": "passwordtooshort",
                "type": "error"
            },
            {
                "message": "passwordincommonlist",
                "params": [],
                "code": "passwordincommonlist",
                "type": "error"
            }
        ]
    }
}

Are you able to get the seemingly nested error? Exception->__construct('The \"validatepa...', NULL, NULL)

Change #1018763 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/core@master] api: Replace null $httpCode by 0 in ApiBase::dieWithErrorOrDebug

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

Umherirrender subscribed.

The message is apierror-mustbeposted and only happen when visiting the provided url directly in the browser (at least for me this must be a GET to produce the error)

Change #1018763 merged by jenkins-bot:

[mediawiki/core@master] api: Replace null $httpCode by 0 in ApiBase::dieWithErrorOrDebug

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

Change #1019170 had a related patch set uploaded (by Reedy; author: Umherirrender):

[mediawiki/core@REL1_42] api: Replace null $httpCode by 0 in ApiBase::dieWithErrorOrDebug

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

Change #1019171 had a related patch set uploaded (by Reedy; author: Umherirrender):

[mediawiki/core@REL1_41] api: Replace null $httpCode by 0 in ApiBase::dieWithErrorOrDebug

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

Change #1019172 had a related patch set uploaded (by Reedy; author: Umherirrender):

[mediawiki/core@REL1_40] api: Replace null $httpCode by 0 in ApiBase::dieWithErrorOrDebug

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

Change #1019173 had a related patch set uploaded (by Reedy; author: Umherirrender):

[mediawiki/core@REL1_39] api: Replace null $httpCode by 0 in ApiBase::dieWithErrorOrDebug

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

Change #1019170 merged by jenkins-bot:

[mediawiki/core@REL1_42] api: Replace null $httpCode by 0 in ApiBase::dieWithErrorOrDebug

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

Change #1019171 merged by jenkins-bot:

[mediawiki/core@REL1_41] api: Replace null $httpCode by 0 in ApiBase::dieWithErrorOrDebug

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

Change #1019172 merged by jenkins-bot:

[mediawiki/core@REL1_40] api: Replace null $httpCode by 0 in ApiBase::dieWithErrorOrDebug

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

Change #1019173 merged by jenkins-bot:

[mediawiki/core@REL1_39] api: Replace null $httpCode by 0 in ApiBase::dieWithErrorOrDebug

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