aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--includes/Rest/ConditionalHeaderUtil.php7
-rw-r--r--includes/Rest/Handler/PageHistoryCountHandler.php7
-rw-r--r--includes/Rest/HeaderParser/HttpDate.php17
3 files changed, 22 insertions, 9 deletions
diff --git a/includes/Rest/ConditionalHeaderUtil.php b/includes/Rest/ConditionalHeaderUtil.php
index 866ac51dd03a..3508f4485e68 100644
--- a/includes/Rest/ConditionalHeaderUtil.php
+++ b/includes/Rest/ConditionalHeaderUtil.php
@@ -132,11 +132,14 @@ class ConditionalHeaderUtil {
/**
* The weak comparison function
*
- * @param array $tag1 Parsed tag info array
- * @param array $tag2 Parsed tag info array
+ * @param array|null $tag1 Parsed tag info array
+ * @param array|null $tag2 Parsed tag info array
* @return bool
*/
private function weakCompare( $tag1, $tag2 ) {
+ if ( $tag1 === null || $tag2 === null ) {
+ return false;
+ }
return $tag1['contents'] === $tag2['contents'];
}
diff --git a/includes/Rest/Handler/PageHistoryCountHandler.php b/includes/Rest/Handler/PageHistoryCountHandler.php
index 4d9ecbb8a11a..004c72e7b5f4 100644
--- a/includes/Rest/Handler/PageHistoryCountHandler.php
+++ b/includes/Rest/Handler/PageHistoryCountHandler.php
@@ -68,7 +68,7 @@ class PageHistoryCountHandler extends SimpleHandler {
/** @var RevisionRecord|false|null */
private $revision = false;
- /** @var array */
+ /** @var array|null */
private $lastModifiedTimes;
/** @var ExistingPageRecord|false|null */
@@ -318,7 +318,7 @@ class PageHistoryCountHandler extends SimpleHandler {
* Returns array with 2 timestamps:
* 1. Current revision
* 2. OR entry from the DB logging table for the given page
- * @return array
+ * @return array|null
*/
protected function getLastModifiedTimes() {
$currentRev = $this->getCurrentRevision();
@@ -382,6 +382,7 @@ class PageHistoryCountHandler extends SimpleHandler {
if ( $oldValue ) {
// Last modified timestamp was NOT a dependency change (e.g. revdel)
$doIncrementalUpdate = (
+ // @phan-suppress-next-line PhanTypeArraySuspiciousNullable
$this->getLastModified() != $this->getLastModifiedTimes()['dependencyModTS']
);
if ( $doIncrementalUpdate ) {
@@ -391,6 +392,7 @@ class PageHistoryCountHandler extends SimpleHandler {
return [
'revision' => $currentRev->getId(),
'count' => $oldValue['count'] + $additionalCount,
+ // @phan-suppress-next-line PhanTypeArraySuspiciousNullable
'dependencyModTS' => $this->getLastModifiedTimes()['dependencyModTS']
];
}
@@ -401,6 +403,7 @@ class PageHistoryCountHandler extends SimpleHandler {
return [
'revision' => $currentRev->getId(),
'count' => $fetchCount(),
+ // @phan-suppress-next-line PhanTypeArraySuspiciousNullable
'dependencyModTS' => $this->getLastModifiedTimes()['dependencyModTS']
];
},
diff --git a/includes/Rest/HeaderParser/HttpDate.php b/includes/Rest/HeaderParser/HttpDate.php
index 938950292e5e..7f59cd637a97 100644
--- a/includes/Rest/HeaderParser/HttpDate.php
+++ b/includes/Rest/HeaderParser/HttpDate.php
@@ -56,12 +56,19 @@ class HttpDate extends HeaderParserBase {
'Sunday',
];
+ /** @var string */
private $dayName;
+ /** @var string */
private $day;
+ /** @var int */
private $month;
+ /** @var int */
private $year;
+ /** @var string */
private $hour;
+ /** @var string */
private $minute;
+ /** @var string */
private $second;
/**
@@ -201,7 +208,7 @@ class HttpDate extends HeaderParserBase {
* @throws HeaderParserError
*/
private function consumeYear() {
- $this->year = $this->consumeFixedDigits( 4 );
+ $this->year = (int)$this->consumeFixedDigits( 4 );
}
/**
@@ -242,8 +249,8 @@ class HttpDate extends HeaderParserBase {
$this->consumeString( '-' );
$year = $this->consumeFixedDigits( 2 );
// RFC 2626 section 11.2
- $currentYear = gmdate( 'Y' );
- $startOfCentury = round( $currentYear, -2 );
+ $currentYear = (int)gmdate( 'Y' );
+ $startOfCentury = (int)round( $currentYear, -2 );
$this->year = $startOfCentury + intval( $year );
$pivot = $currentYear + 50;
if ( $this->year > $pivot ) {
@@ -305,7 +312,7 @@ class HttpDate extends HeaderParserBase {
* @return int
*/
private function getUnixTime() {
- return gmmktime( $this->hour, $this->minute, $this->second,
- $this->month, $this->day, $this->year );
+ return gmmktime( (int)$this->hour, (int)$this->minute, (int)$this->second,
+ $this->month, (int)$this->day, $this->year );
}
}