Page MenuHomePhabricator

AbstractBlock::getHideName() can return 0/1 instead of boolean
Closed, ResolvedPublic

Description

Documentation for AbstractBlock::getHideName() claims it can return just a boolean. However, when writing https://gerrit.wikimedia.org/r/c/mediawiki/core/+/588104, I get a lot of errors like "0 is not false" or "1 is not true", meaning somehow unexpected values sneak in.

Event Timeline

Apparently not specific to that method:

urbanecm@notebook (master * u=) ~/unsynced/gerrit/mediawiki/core
$ !php
php maintenance/shell.php --wiki=awiki
Psy Shell v0.9.12 (PHP 7.2.24-0ubuntu0.18.04.3 — cli) by Justin Hileman
>>> use MediaWiki\Block\DatabaseBlock;
>>> $block = DatabaseBlock::newFromTarget('127.0.0.3');
=> MediaWiki\Block\DatabaseBlock {#2557
     +mAuto: false,
     +mParentBlockId: 0,
     +mTimestamp: "20200328145821",
     +mExpiry: "infinity",
     +mHideName: false,
   }
>>>  $block->isCreateAccountBlocked();
=> "1"

Change 592491 had a related patch set uploaded (by Urbanecm; owner: Urbanecm):
[mediawiki/core@master] DatabaseBlock's status variables don't return bool

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

Urbanecm moved this task from Backlog to Waiting on review on the User-Urbanecm board.

Change 592491 merged by jenkins-bot:
[mediawiki/core@master] DatabaseBlock's status variables should return bool

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