*/
private $mFlags = [];
+ /** @var string[] */
+ private static $speculativeFields = [
+ 'speculativePageIdUsed',
+ 'speculativeRevIdUsed',
+ 'revisionTimestampUsed'
+ ];
/** @var int|null Assumed rev ID for {{REVISIONID}} if no revision is set */
- private $mSpeculativeRevId;
+ private $speculativeRevIdUsed;
+ /** @var int|null Assumed page ID for {{PAGEID}} if no revision is set */
+ private $speculativePageIdUsed;
+ /** @var int|null Assumed rev timestamp for {{REVISIONTIMESTAMP}} if no revision is set */
+ private $revisionTimestampUsed;
+
+ /** @var string|null SHA-1 base 36 hash of any self-transclusion */
+ private $revisionUsedSha1Base36;
/** string CSS classes to use for the wrapping div, stored in the array keys.
* If no class is given, no wrapper is added.
* @since 1.28
*/
public function setSpeculativeRevIdUsed( $id ) {
- $this->mSpeculativeRevId = $id;
+ $this->speculativeRevIdUsed = $id;
}
/**
* @since 1.28
*/
public function getSpeculativeRevIdUsed() {
- return $this->mSpeculativeRevId;
+ return $this->speculativeRevIdUsed;
+ }
+
+ /**
+ * @param int $id
+ * @since 1.34
+ */
+ public function setSpeculativePageIdUsed( $id ) {
+ $this->speculativePageIdUsed = $id;
+ }
+
+ /**
+ * @return int|null
+ * @since 1.34
+ */
+ public function getSpeculativePageIdUsed() {
+ return $this->speculativePageIdUsed;
+ }
+
+ /**
+ * @param string $timestamp TS_MW timestamp
+ * @since 1.34
+ */
+ public function setRevisionTimestampUsed( $timestamp ) {
+ $this->revisionTimestampUsed = $timestamp;
+ }
+
+ /**
+ * @return string|null TS_MW timestamp or null if not used
+ * @since 1.34
+ */
+ public function getRevisionTimestampUsed() {
+ return $this->revisionTimestampUsed;
+ }
+
+ /**
+ * @param string $hash Lowercase SHA-1 base 36 hash
+ * @since 1.34
+ */
+ public function setRevisionUsedSha1Base36( $hash ) {
+ if ( $hash === null ) {
+ return; // e.g. RevisionRecord::getSha1() returned null
+ }
+
+ if (
+ $this->revisionUsedSha1Base36 !== null &&
+ $this->revisionUsedSha1Base36 !== $hash
+ ) {
+ $this->revisionUsedSha1Base36 = ''; // mismatched
+ } else {
+ $this->revisionUsedSha1Base36 = $hash;
+ }
+ }
+
+ /**
+ * @return string|null Lowercase SHA-1 base 36 hash, null if unused, or "" on inconsistency
+ * @since 1.34
+ */
+ public function getRevisionUsedSha1Base36() {
+ return $this->revisionUsedSha1Base36;
}
public function &getLanguageLinks() {
$this->mWarnings = self::mergeMap( $this->mWarnings, $source->mWarnings ); // don't use getter
$this->mTimestamp = $this->useMaxValue( $this->mTimestamp, $source->getTimestamp() );
- if ( $this->mSpeculativeRevId && $source->mSpeculativeRevId
- && $this->mSpeculativeRevId !== $source->mSpeculativeRevId
- ) {
- wfLogWarning(
- 'Inconsistent speculative revision ID encountered while merging parser output!'
- );
+ foreach ( self::$speculativeFields as $field ) {
+ if ( $this->$field && $source->$field && $this->$field !== $source->$field ) {
+ wfLogWarning( __METHOD__ . ": inconsistent '$field' properties!" );
+ }
+ $this->$field = $this->useMaxValue( $this->$field, $source->$field );
}
- $this->mSpeculativeRevId = $this->useMaxValue(
- $this->mSpeculativeRevId,
- $source->getSpeculativeRevIdUsed()
- );
$this->mParseStartTime = $this->useEachMinValue(
$this->mParseStartTime,
$source->mParseStartTime