aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFunc <Funcer@outlook.com>2022-12-13 14:35:28 +0800
committerFunc <Funcer@outlook.com>2022-12-13 14:42:17 +0800
commitde535fa92b2c309fd5eee088fee7f81f8b142b2e (patch)
tree7e50b469b74462a53dc042ea7eabb40ed7471ace
parentc526317c03d509986c2dade388ae91e2ca962ab1 (diff)
downloadmediawikicore-de535fa92b2c309fd5eee088fee7f81f8b142b2e.tar.gz
mediawikicore-de535fa92b2c309fd5eee088fee7f81f8b142b2e.zip
RangeChronologicalPager: Restore the compatibility with derived classes
Derived classes may expect that $rangeConds is defined and would read from or write to it. Bug: T228431 Bug: T325034 Change-Id: I49f1001a8675323ce4f2fe4b30dff66b4680712c
-rw-r--r--includes/pager/RangeChronologicalPager.php19
1 files changed, 14 insertions, 5 deletions
diff --git a/includes/pager/RangeChronologicalPager.php b/includes/pager/RangeChronologicalPager.php
index 4c135d037305..8e41340344c7 100644
--- a/includes/pager/RangeChronologicalPager.php
+++ b/includes/pager/RangeChronologicalPager.php
@@ -27,6 +27,12 @@ use Wikimedia\Timestamp\TimestampException;
*/
abstract class RangeChronologicalPager extends ReverseChronologicalPager {
+ /**
+ * @var string[]
+ * @deprecated since 1.40, use $startOffset and $endOffset instead.
+ */
+ protected $rangeConds;
+
/** @var string */
protected $startOffset;
@@ -44,8 +50,8 @@ abstract class RangeChronologicalPager extends ReverseChronologicalPager {
* or null if dates are invalid
*/
public function getDateRangeCond( $startTime, $endTime ) {
- // Construct the conds array for compatibility with callers (if any)
- $rangeConds = [];
+ // Construct the conds array for compatibility with callers and derived classes
+ $this->rangeConds = [];
// This is a chronological pager, so the first column should be some kind of timestamp
$timestampField = is_array( $this->mIndexField ) ? $this->mIndexField[0] : $this->mIndexField;
@@ -53,7 +59,7 @@ abstract class RangeChronologicalPager extends ReverseChronologicalPager {
if ( $startTime !== '' ) {
$startTimestamp = MWTimestamp::getInstance( $startTime );
$this->startOffset = $this->mDb->timestamp( $startTimestamp->getTimestamp() );
- $rangeConds[] = $this->mDb->buildComparison( '>=', [ $timestampField => $this->startOffset ] );
+ $this->rangeConds[] = $this->mDb->buildComparison( '>=', [ $timestampField => $this->startOffset ] );
}
if ( $endTime !== '' ) {
@@ -62,7 +68,7 @@ abstract class RangeChronologicalPager extends ReverseChronologicalPager {
// add one second for compatibility with existing use cases
$endTimestamp->timestamp = $endTimestamp->timestamp->modify( '+1 second' );
$this->endOffset = $this->mDb->timestamp( $endTimestamp->getTimestamp() );
- $rangeConds[] = $this->mDb->buildComparison( '<', [ $timestampField => $this->endOffset ] );
+ $this->rangeConds[] = $this->mDb->buildComparison( '<', [ $timestampField => $this->endOffset ] );
// populate existing variables for compatibility with parent
$this->mYear = (int)$endTimestamp->format( 'Y' );
@@ -73,7 +79,7 @@ abstract class RangeChronologicalPager extends ReverseChronologicalPager {
return null;
}
- return $rangeConds;
+ return $this->rangeConds;
}
/**
@@ -89,6 +95,9 @@ abstract class RangeChronologicalPager extends ReverseChronologicalPager {
if ( $this->startOffset ) {
$timestampField = is_array( $this->mIndexField ) ? $this->mIndexField[0] : $this->mIndexField;
$conds[] = $this->mDb->buildComparison( '>=', [ $timestampField => $this->startOffset ] );
+ } elseif ( $this->rangeConds ) {
+ // Keep compatibility with some derived classes, T325034
+ $conds = array_merge( $conds, $this->rangeConds );
}
return [ $tables, $fields, $conds, $fname, $options, $join_conds ];