Jackmcbarn has uploaded a new change for review.
https://gerrit.wikimedia.org/r/179397
Change subject: Always use the newly-saved revision with vary-revision
......................................................................
Always use the newly-saved revision with vary-revision
When vary-revision is set, use a currentRevisionCallback to ensure that
the newly-saved revision will always be used by the parser. This keeps
slave lag from making vary-revision not do its job.
Bug: T78237
Change-Id: I92ec928203a67f1236c3ecf6dd5002f66a75c38c
---
M includes/page/WikiPage.php
1 file changed, 29 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/97/179397/1
diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php
index b9f7eda..6dca752 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -2066,7 +2066,7 @@
* Returns a stdclass with source, pst and output members
*
* @param Content $content
- * @param int|null $revid
+ * @param Revision|int|null $revision Revision object or ID
* @param User|null $user
* @param string|null $serialFormat
* @param bool $useCache Check shared prepared edit cache
@@ -2076,9 +2076,16 @@
* @since 1.21
*/
public function prepareContentForEdit(
- Content $content, $revid = null, User $user = null,
$serialFormat = null, $useCache = true
+ Content $content, $revision = null, User $user = null,
$serialFormat = null, $useCache = true
) {
global $wgContLang, $wgUser;
+
+ if ( gettype( $revision ) === 'object' ) {
+ $revid = $revision->getId();
+ } else {
+ $revid = $revision;
+ $revision = null;
+ }
$user = is_null( $user ) ? $wgUser : $user;
//XXX: check $user->getId() here???
@@ -2129,6 +2136,25 @@
if ( $cachedEdit ) {
$edit->output = $cachedEdit->output;
} else {
+ if ( $revision ) {
+ // We get here if vary-revision is set. This
means that this page references
+ // itself (such as via self-transclusion). In
this case, we need to make sure
+ // that any such self-references refer to the
newly-saved revision, and not
+ // to the previous one, which could otherwise
happen due to slave lag.
+ $oldCallback =
$edit->popts->setCurrentRevisionCallback(
+ function ( $title, $parser = false )
use ( $revision, &$oldCallback ) {
+ if ( $title->equals(
$revision->getTitle() ) ) {
+ return $revision;
+ } else {
+ return call_user_func(
+ $oldCallback,
+ $title,
+ $parser
+ );
+ }
+ }
+ );
+ }
$edit->output = $edit->pstContent
? $edit->pstContent->getParserOutput(
$this->mTitle, $revid, $edit->popts )
: null;
@@ -2181,7 +2207,7 @@
// already pre-save transformed once.
if ( !$this->mPreparedEdit ||
$this->mPreparedEdit->output->getFlag( 'vary-revision' ) ) {
wfDebug( __METHOD__ . ": No prepared edit or
vary-revision is set...\n" );
- $editInfo = $this->prepareContentForEdit( $content,
$revision->getId(), $user );
+ $editInfo = $this->prepareContentForEdit( $content,
$revision, $user );
} else {
wfDebug( __METHOD__ . ": No vary-revision, using
prepared edit...\n" );
$editInfo = $this->mPreparedEdit;
--
To view, visit https://gerrit.wikimedia.org/r/179397
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I92ec928203a67f1236c3ecf6dd5002f66a75c38c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Jackmcbarn <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits