Avoid PHP scalar type juggling in includes/ (part 2)
Continuation of e5444ea55a.
Change-Id: I9f95e7de4e219dee3abcdd210bb708d949f378d0
This commit is contained in:
parent
6608d9a481
commit
dbf0990447
13 changed files with 31 additions and 24 deletions
|
|
@ -760,7 +760,7 @@ class InfoAction extends FormlessAction {
|
|||
$result['watchers'] = $watchedItemStore->countWatchers( $title );
|
||||
|
||||
if ( $config->get( 'ShowUpdatedMarker' ) ) {
|
||||
$updated = wfTimestamp( TS_UNIX, $page->getTimestamp() );
|
||||
$updated = (int)wfTimestamp( TS_UNIX, $page->getTimestamp() );
|
||||
$result['visitingWatchers'] = $watchedItemStore->countVisitingWatchers(
|
||||
$title,
|
||||
$updated - $config->get( 'WatchersMaxAge' )
|
||||
|
|
|
|||
|
|
@ -291,6 +291,9 @@ abstract class ApiBase extends ContextSource {
|
|||
/** @var string */
|
||||
private $mModuleName, $mModulePrefix;
|
||||
private $mReplicaDB = null;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $mParamCache = [];
|
||||
/** @var array|null|bool */
|
||||
private $mModuleSource = false;
|
||||
|
|
@ -768,9 +771,10 @@ abstract class ApiBase extends ContextSource {
|
|||
];
|
||||
|
||||
$parseLimit = (bool)$options['parseLimit'];
|
||||
$cacheKey = (int)$parseLimit;
|
||||
|
||||
// Cache parameters, for performance and to avoid T26564.
|
||||
if ( !isset( $this->mParamCache[$parseLimit] ) ) {
|
||||
if ( !isset( $this->mParamCache[$cacheKey] ) ) {
|
||||
$params = $this->getFinalParams() ?: [];
|
||||
$results = [];
|
||||
$warned = [];
|
||||
|
|
@ -852,10 +856,10 @@ abstract class ApiBase extends ContextSource {
|
|||
}
|
||||
}
|
||||
|
||||
$this->mParamCache[$parseLimit] = $results;
|
||||
$this->mParamCache[$cacheKey] = $results;
|
||||
}
|
||||
|
||||
$ret = $this->mParamCache[$parseLimit];
|
||||
$ret = $this->mParamCache[$cacheKey];
|
||||
if ( !$options['safeMode'] ) {
|
||||
foreach ( $ret as $v ) {
|
||||
if ( $v instanceof ApiUsageException ) {
|
||||
|
|
@ -864,7 +868,7 @@ abstract class ApiBase extends ContextSource {
|
|||
}
|
||||
}
|
||||
|
||||
return $this->mParamCache[$parseLimit];
|
||||
return $this->mParamCache[$cacheKey];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ use MediaWiki\Revision\RevisionRecord;
|
|||
*/
|
||||
class ApiParse extends ApiBase {
|
||||
|
||||
/** @var string */
|
||||
/** @var string|false|null */
|
||||
private $section = null;
|
||||
|
||||
/** @var Content */
|
||||
|
|
@ -634,7 +634,7 @@ class ApiParse extends ApiBase {
|
|||
*
|
||||
* @param Title $title of the page being parsed
|
||||
* @param array $params The API parameters of the request
|
||||
* @return Content|bool
|
||||
* @return string HTML
|
||||
*/
|
||||
private function formatSummary( $title, $params ) {
|
||||
$summary = $params['summary'] ?? '';
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
|
|||
$joins = [
|
||||
'actor' => [ 'JOIN', 'rc_actor = actor_id' ],
|
||||
];
|
||||
$timestamp = $db->timestamp( wfTimestamp( TS_UNIX ) - $activeUserSeconds );
|
||||
$timestamp = $db->timestamp( (int)wfTimestamp( TS_UNIX ) - $activeUserSeconds );
|
||||
$this->addFields( [
|
||||
'recentactions' => '(' . $db->selectSQLText(
|
||||
$tables,
|
||||
|
|
|
|||
|
|
@ -908,7 +908,7 @@ class ApiQueryInfo extends ApiQueryBase {
|
|||
$timestamps = [];
|
||||
foreach ( $timestampRes as $row ) {
|
||||
$revTimestamp = wfTimestamp( TS_UNIX, (int)$row->rev_timestamp );
|
||||
$timestamps[$row->page_namespace][$row->page_title] = $revTimestamp - $age;
|
||||
$timestamps[$row->page_namespace][$row->page_title] = (int)$revTimestamp - $age;
|
||||
}
|
||||
$titlesWithThresholds = array_map(
|
||||
function ( LinkTarget $target ) use ( $timestamps ) {
|
||||
|
|
|
|||
|
|
@ -54,14 +54,14 @@ class LocalPasswordPrimaryAuthenticationProvider
|
|||
* @return \stdClass|null
|
||||
*/
|
||||
protected function getPasswordResetData( $username, $row ) {
|
||||
$now = wfTimestamp();
|
||||
$now = (int)wfTimestamp();
|
||||
$expiration = wfTimestampOrNull( TS_UNIX, $row->user_password_expires );
|
||||
if ( $expiration === null || $expiration >= $now ) {
|
||||
if ( $expiration === null || (int)$expiration >= $now ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$grace = $this->config->get( 'PasswordExpireGrace' );
|
||||
if ( $expiration + $grace < $now ) {
|
||||
if ( (int)$expiration + $grace < $now ) {
|
||||
$data = [
|
||||
'hard' => true,
|
||||
'msg' => \Status::newFatal( 'resetpass-expired' )->getMessage(),
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ class TemporaryPasswordPrimaryAuthenticationProvider
|
|||
if (
|
||||
$this->passwordReminderResendTime
|
||||
&& $row->user_newpass_time
|
||||
&& time() < wfTimestamp( TS_UNIX, $row->user_newpass_time )
|
||||
&& time() < (int)wfTimestamp( TS_UNIX, $row->user_newpass_time )
|
||||
+ $this->passwordReminderResendTime * 3600
|
||||
) {
|
||||
// Round the time in hours to 3 d.p., in case someone is specifying
|
||||
|
|
@ -415,7 +415,7 @@ class TemporaryPasswordPrimaryAuthenticationProvider
|
|||
protected function isTimestampValid( $timestamp ) {
|
||||
$time = wfTimestampOrNull( TS_MW, $timestamp );
|
||||
if ( $time !== null ) {
|
||||
$expiry = wfTimestamp( TS_UNIX, $time ) + $this->newPasswordExpiry;
|
||||
$expiry = (int)wfTimestamp( TS_UNIX, $time ) + $this->newPasswordExpiry;
|
||||
if ( time() >= $expiry ) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -501,7 +501,7 @@ class BlockManager {
|
|||
*/
|
||||
public function setBlockCookie( DatabaseBlock $block, WebResponse $response ) {
|
||||
// Calculate the default expiry time.
|
||||
$maxExpiryTime = wfTimestamp( TS_MW, wfTimestamp() + ( 24 * 60 * 60 ) );
|
||||
$maxExpiryTime = wfTimestamp( TS_MW, (int)wfTimestamp() + ( 24 * 60 * 60 ) );
|
||||
|
||||
// Use the block's expiry time only if it's less than the default.
|
||||
$expiryTime = $block->getExpiry();
|
||||
|
|
@ -575,12 +575,12 @@ class BlockManager {
|
|||
$id = ( $bangPos === false ) ? $cookieValue : substr( $cookieValue, 0, $bangPos );
|
||||
if ( !$this->options->get( 'SecretKey' ) ) {
|
||||
// If there's no secret key, just use the ID as given.
|
||||
return $id;
|
||||
return (int)$id;
|
||||
}
|
||||
$storedHmac = substr( $cookieValue, $bangPos + 1 );
|
||||
$calculatedHmac = MWCryptHash::hmac( $id, $this->options->get( 'SecretKey' ), false );
|
||||
if ( $calculatedHmac === $storedHmac ) {
|
||||
return $id;
|
||||
return (int)$id;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -438,7 +438,7 @@ class DatabaseBlock extends AbstractBlock {
|
|||
$this->setTarget( $row->ipb_address );
|
||||
|
||||
$this->setTimestamp( wfTimestamp( TS_MW, $row->ipb_timestamp ) );
|
||||
$this->mAuto = $row->ipb_auto;
|
||||
$this->mAuto = (bool)$row->ipb_auto;
|
||||
$this->setHideName( $row->ipb_deleted );
|
||||
$this->mId = (int)$row->ipb_id;
|
||||
$this->mParentBlockId = $row->ipb_parent_block_id;
|
||||
|
|
@ -872,7 +872,7 @@ class DatabaseBlock extends AbstractBlock {
|
|||
);
|
||||
$timestamp = wfTimestampNow();
|
||||
$autoblock->setTimestamp( $timestamp );
|
||||
$autoblock->mAuto = 1;
|
||||
$autoblock->mAuto = true;
|
||||
$autoblock->isCreateAccountBlocked( $this->isCreateAccountBlocked() );
|
||||
# Continue suppressing the name if needed
|
||||
$autoblock->setHideName( $this->getHideName() );
|
||||
|
|
@ -1107,7 +1107,7 @@ class DatabaseBlock extends AbstractBlock {
|
|||
public static function getAutoblockExpiry( $timestamp ) {
|
||||
global $wgAutoblockExpiry;
|
||||
|
||||
return wfTimestamp( TS_MW, wfTimestamp( TS_UNIX, $timestamp ) + $wgAutoblockExpiry );
|
||||
return wfTimestamp( TS_MW, (int)wfTimestamp( TS_UNIX, $timestamp ) + $wgAutoblockExpiry );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ abstract class ChangesListFilter {
|
|||
/**
|
||||
* Priority integer. Higher value means higher up in the group's filter list.
|
||||
*
|
||||
* @var string
|
||||
* @var int
|
||||
*/
|
||||
protected $priority;
|
||||
|
||||
|
|
@ -138,6 +138,9 @@ abstract class ChangesListFilter {
|
|||
* UI.
|
||||
* * $filterDefinition['priority'] int Priority integer. Higher value means higher
|
||||
* up in the group's filter list.
|
||||
* @codingStandardsIgnoreStart
|
||||
* @phan-param array{name:string,cssClassSuffix?:string,isRowApplicableCallable?:callable,group:ChangesListFilterGroup,label:string,description:string,priority:int} $filterDefinition
|
||||
* @codingStandardsIgnoreEnd
|
||||
*/
|
||||
public function __construct( array $filterDefinition ) {
|
||||
if ( isset( $filterDefinition['group'] ) ) {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class SquidPurgeClient {
|
|||
const BUFFER_SIZE = 8192;
|
||||
|
||||
/**
|
||||
* @var resource|null The socket resource, or null for unconnected, or false
|
||||
* @var resource|false|null The socket resource, or null for unconnected, or false
|
||||
* for disabled due to error.
|
||||
*/
|
||||
protected $socket;
|
||||
|
|
|
|||
|
|
@ -507,7 +507,7 @@ class IcuCollation extends Collation {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return int
|
||||
* @since 1.16.3
|
||||
*/
|
||||
public function getFirstLetterCount() {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class WikitextContent extends TextContent {
|
|||
private $hadSignature = false;
|
||||
|
||||
/**
|
||||
* @var array|null Stack trace of the previous parse
|
||||
* @var string|null Stack trace of the previous parse
|
||||
*/
|
||||
private $previousParseStackTrace = null;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue