/**
* @var Language
*/
- private $contentLanguage;
+ private $contLang;
/**
* @var LoggerInterface
/**
* The state of the relevant row in page table before the edit.
* This is determined by the first call to grabCurrentRevision, prepareContent,
- * or prepareUpdate.
+ * or prepareUpdate (so it is only accessible in 'knows-current' or a later stage).
* If pageState was not initialized when prepareUpdate() is called, prepareUpdate() will
* attempt to emulate the state of the page table before the edit.
*
+ * Contains the following fields:
+ * - oldRevision (RevisionRecord|null): the revision that was current before the change
+ * associated with this update. Might not be set, use getOldRevision() instead of direct
+ * access.
+ * - oldId (int|null): the id of the above revision. 0 if there is no such revision (the change
+ * was about creating a new page); null if not known (that should not happen).
+ * - oldIsRedirect (bool|null): whether the page was a redirect before the change. Lazy-loaded,
+ * can be null; use wasRedirect() instead of direct access.
+ * - oldCountable (bool|null): whether the page was countable before the change (or null
+ * if we don't have that information)
+ *
* @var array
*/
private $pageState = null;
* @param ParserCache $parserCache
* @param JobQueueGroup $jobQueueGroup
* @param MessageCache $messageCache
- * @param Language $contentLanguage
+ * @param Language $contLang
* @param LoggerInterface|null $saveParseLogger
*/
public function __construct(
ParserCache $parserCache,
JobQueueGroup $jobQueueGroup,
MessageCache $messageCache,
- Language $contentLanguage,
+ Language $contLang,
LoggerInterface $saveParseLogger = null
) {
$this->wikiPage = $wikiPage;
$this->revisionStore = $revisionStore;
$this->jobQueueGroup = $jobQueueGroup;
$this->messageCache = $messageCache;
- $this->contentLanguage = $contentLanguage;
+ $this->contLang = $contLang;
// XXX: replace all wfDebug calls with a Logger. Do we nede more than one logger here?
$this->saveParseLogger = $saveParseLogger ?: new NullLogger();
/**
* Checks whether this DerivedPageDataUpdater can be re-used for running updates targeting
- * the the given revision.
+ * the given revision.
*
* @param UserIdentity|null $user The user creating the revision in question
* @param RevisionRecord|null $revision New revision (after save, if already saved)
$this->canonicalParserOutput = $output;
}
- $userPopts = ParserOptions::newFromUserAndLang( $user, $this->contentLanguage );
+ $userPopts = ParserOptions::newFromUserAndLang( $user, $this->contLang );
Hooks::run( 'ArticlePrepareTextForEdit', [ $wikiPage, $userPopts ] );
$this->user = $user;
* - null: if created is false, don't update the article count; if created
* is true, do update the article count
* - 'no-change': don't update the article count, ever
- *
+ * When set to null, pageState['oldCountable'] will be used instead if available.
*/
public function prepareUpdate( RevisionRecord $revision, array $options = [] ) {
Assert::parameter(
} elseif ( $this->options['oldcountable'] !== null ) {
$good = (int)$this->isCountable()
- (int)$this->options['oldcountable'];
+ } elseif ( isset( $this->pageState['oldCountable'] ) ) {
+ $good = (int)$this->isCountable()
+ - (int)$this->pageState['oldCountable'];
} else {
$good = 0;
}
// TODO: In the wiring, register a listener for this on the new PageEventEmitter
ResourceLoaderWikiModule::invalidateModuleCache(
- $title, $oldLegacyRevision, $legacyRevision, $this->getWikiId()
+ $title, $oldLegacyRevision, $legacyRevision, $this->getWikiId() ?: wfWikiID()
);
$this->doTransition( 'done' );