Error
- service.version: 1.44.0-wmf.13
- trace.id: 6da3b530-2772-4b9e-a787-dfad8c6cfcd4
- Find trace.id in Logstash
[{reqId}] {exception_url} PHP Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated[{reqId}] {exception_url} PHP Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated| Status | Subtype | Assigned | Task | |
|---|---|---|---|---|
| · · · | ||||
| Resolved | None | T379874 ☂ PHP 8.1 issues found during WMF rollout/ramp up | ||
| Resolved | PRODUCTION ERROR | • hashar | T385143 PHP Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated | |
| · · · |
The code from 2013 is:
$response = MediaWikiServices::getInstance()->getHttpRequestFactory() ->post( $this->flickrApiUrl, $params, __METHOD__ ); if ( $response !== false ) { $response = json_decode( $response, true ); }
But post() is documented to return string|null, same for the underlying request(). I imagine ideally Phan should catch that we compare a string|null with boolean false and should flag it.
The reason is 4e9cd14878149ce59138767c02458ea4dea87ac4 by @Umherirrender. The patch switches to HttpRequestFactory::post which returns string|null when previously it used Http:post which returned string|false false on error.
Change #1115338 had a related patch set uploaded (by Hashar; author: Hashar):
[mediawiki/extensions/UploadWizard@master] Fix response error handling in FlickrBlacklist
Change #1115338 merged by jenkins-bot:
[mediawiki/extensions/UploadWizard@master] Fix response error handling in FlickrBlacklist
Change #1115344 had a related patch set uploaded (by Hashar; author: Hashar):
[mediawiki/extensions/UploadWizard@wmf/1.44.0-wmf.14] Fix response error handling in FlickrBlacklist
Change #1115346 had a related patch set uploaded (by Hashar; author: Hashar):
[mediawiki/extensions/UploadWizard@REL1_39] Fix response error handling in FlickrBlacklist
Change #1115346 abandoned by Hashar:
[mediawiki/extensions/UploadWizard@REL1_39] Fix response error handling in FlickrBlacklist
Change #1115347 had a related patch set uploaded (by Hashar; author: Hashar):
[mediawiki/extensions/UploadWizard@REL1_42] Fix response error handling in FlickrBlacklist
Change #1115348 had a related patch set uploaded (by Hashar; author: Hashar):
[mediawiki/extensions/UploadWizard@REL1_43] Fix response error handling in FlickrBlacklist
Change #1115346 restored by Hashar:
[mediawiki/extensions/UploadWizard@REL1_39] Fix response error handling in FlickrBlacklist
Change #1115344 merged by jenkins-bot:
[mediawiki/extensions/UploadWizard@wmf/1.44.0-wmf.14] Fix response error handling in FlickrBlacklist
Mentioned in SAL (#wikimedia-operations) [2025-01-30T13:24:54Z] <hashar@deploy2002> Started scap sync-world: Backport for [[gerrit:1115344|Fix response error handling in FlickrBlacklist (T385143)]]
Mentioned in SAL (#wikimedia-operations) [2025-01-30T13:27:58Z] <hashar@deploy2002> hashar: Backport for [[gerrit:1115344|Fix response error handling in FlickrBlacklist (T385143)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)
Mentioned in SAL (#wikimedia-operations) [2025-01-30T13:36:49Z] <hashar@deploy2002> Finished scap sync-world: Backport for [[gerrit:1115344|Fix response error handling in FlickrBlacklist (T385143)]] (duration: 11m 54s)
Change #1115346 merged by jenkins-bot:
[mediawiki/extensions/UploadWizard@REL1_39] Fix response error handling in FlickrBlacklist
Change #1115347 merged by jenkins-bot:
[mediawiki/extensions/UploadWizard@REL1_42] Fix response error handling in FlickrBlacklist
Change #1115348 merged by jenkins-bot:
[mediawiki/extensions/UploadWizard@REL1_43] Fix response error handling in FlickrBlacklist
It does, but only if the return type is typehinted. Impossible comparisons (like this one where a string|null value is compared against false) are only reported for "real" types, i.e., those that are enforced by the interpreter or other runtime checks (typehints, if ( cond ), assert( cond ), etc.). Phan's philosophy is to avoid false positives, and docblock types in legacy code are notoriously inaccurate when it comes to small details (like null vs false vs empty string vs 0).
Thank you, meanwhile I filed a task dedicated to Phan and I pasted your above response there: T385200