jenkins-bot has submitted this change and it was merged.
Change subject: Perform edit stashing when the edit preview or diff form is
requested
......................................................................
Perform edit stashing when the edit preview or diff form is requested
* Users are likely to save after they inspect and review their changes.
The buttons to do so are also located below the edit summary box.
* This obsoletes the backend stashing on preview. Most of those parses
would have been useless due to being per-section only. Also, some
extensions like the Graph extension disable stashing for "preview"
output anyway. Simplify the code by removing that method.
Bug: T136678
Change-Id: Ied77bdbd191dd9267d4295b0fa7b942f65b062db
(cherry picked from commit 406d6a2b46fb4afcfae0840b7c6b5a346f3272c2)
---
M includes/EditPage.php
M includes/api/ApiStashEdit.php
M resources/src/mediawiki.action/mediawiki.action.edit.stash.js
3 files changed, 21 insertions(+), 84 deletions(-)
Approvals:
Aaron Schulz: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/EditPage.php b/includes/EditPage.php
index f2403fe..66ee161 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -2690,6 +2690,18 @@
}
}
+ // Set a hidden field so JS knows what edit form mode we are in
+ if ( $this->isConflict ) {
+ $mode = 'conflict';
+ } elseif ( $this->preview ) {
+ $mode = 'preview';
+ } elseif ( $this->diff ) {
+ $mode = 'diff';
+ } else {
+ $mode = 'text';
+ }
+ $wgOut->addHTML( Html::hidden( 'mode', $mode, [ 'id' =>
'mw-edit-mode' ] ) );
+
// Marker for detecting truncated form data. This must be the
last
// parameter sent in order to be of use, so do not move me.
$wgOut->addHTML( Html::hidden( 'wpUltimateParam', true ) );
@@ -3603,7 +3615,7 @@
*/
function getPreviewText() {
global $wgOut, $wgUser, $wgRawHtml, $wgLang;
- global $wgAllowUserCss, $wgAllowUserJs, $wgAjaxEditStash;
+ global $wgAllowUserCss, $wgAllowUserJs;
$stats = $wgOut->getContext()->getStats();
@@ -3712,15 +3724,6 @@
$scopedCallback = $parserOptions->setupFakeRevision(
$this->mTitle, $pstContent, $wgUser );
$parserOutput = $pstContent->getParserOutput(
$this->mTitle, null, $parserOptions );
-
- # Try to stash the edit for the final submission step
- # @todo: different date format preferences cause cache
misses
- if ( $wgAjaxEditStash ) {
- ApiStashEdit::stashEditFromPreview(
- $this->getArticle(), $content,
$pstContent,
- $parserOutput, $parserOptions,
$parserOptions, wfTimestampNow()
- );
- }
$parserOutput->setEditSectionTokens( false ); // no
section edit links
$previewHTML = $parserOutput->getText();
diff --git a/includes/api/ApiStashEdit.php b/includes/api/ApiStashEdit.php
index 08fd2fd..67939a0 100644
--- a/includes/api/ApiStashEdit.php
+++ b/includes/api/ApiStashEdit.php
@@ -182,77 +182,6 @@
}
/**
- * Attempt to cache PST content and corresponding parser output in
passing
- *
- * This method can be called when the output was already generated for
other
- * reasons. Parsing should not be done just to call this method,
however.
- * $pstOpts must be that of the user doing the edit preview. If $pOpts
does
- * not match the options of WikiPage::makeParserOptions( 'canonical' ),
this
- * will do nothing. Provided the values are cacheable, they will be
stored
- * in memcached so that final edit submission might make use of them.
- *
- * @param Page|Article|WikiPage $page Page title
- * @param Content $content Proposed page content
- * @param Content $pstContent The result of preSaveTransform() on
$content
- * @param ParserOutput $pOut The result of getParserOutput() on
$pstContent
- * @param ParserOptions $pstOpts Options for $pstContent (MUST be for
prospective author)
- * @param ParserOptions $pOpts Options for $pOut
- * @param string $timestamp TS_MW timestamp of parser output generation
- * @return bool Success
- */
- public static function stashEditFromPreview(
- Page $page, Content $content, Content $pstContent, ParserOutput
$pOut,
- ParserOptions $pstOpts, ParserOptions $pOpts, $timestamp
- ) {
- $cache = ObjectCache::getLocalClusterInstance();
- $logger = LoggerFactory::getInstance( 'StashEdit' );
-
- // getIsPreview() controls parser function behavior that
references things
- // like user/revision that don't exists yet. The user/text
should already
- // be set correctly by callers, just double check the preview
flag.
- if ( !$pOpts->getIsPreview() ) {
- return false; // sanity
- } elseif ( $pOpts->getIsSectionPreview() ) {
- return false; // short-circuit (need the full content)
- }
-
- // PST parser options are for the user (handles signatures,
etc...)
- $user = $pstOpts->getUser();
- // Get a key based on the source text, format, and user
preferences
- $title = $page->getTitle();
- $key = self::getStashKey( $title, $content, $user );
-
- // Parser output options must match cannonical options.
- // Treat some options as matching that are different but don't
matter.
- $canonicalPOpts = $page->makeParserOptions( 'canonical' );
- $canonicalPOpts->setIsPreview( true ); // force match
- $canonicalPOpts->setTimestamp( $pOpts->getTimestamp() ); //
force match
- if ( !$pOpts->matches( $canonicalPOpts ) ) {
- $logger->info( "Uncacheable preview output for key
'$key' ('$title') [options]." );
- return false;
- }
-
- // Set the time the output was generated
- $pOut->setCacheTime( wfTimestampNow() );
-
- // Build a value to cache with a proper TTL
- list( $stashInfo, $ttl ) = self::buildStashValue( $pstContent,
$pOut, $timestamp, $user );
- if ( !$stashInfo ) {
- $logger->info( "Uncacheable parser output for key
'$key' ('$title') [rev/TTL]." );
- return false;
- }
-
- $ok = $cache->set( $key, $stashInfo, $ttl );
- if ( !$ok ) {
- $logger->error( "Failed to cache preview parser output
for key '$key' ('$title')." );
- } else {
- $logger->debug( "Cached preview output for key '$key'."
);
- }
-
- return $ok;
- }
-
- /**
* Check that a prepared edit is in cache and still up-to-date
*
* This method blocks if the prepared edit is already being rendered,
diff --git a/resources/src/mediawiki.action/mediawiki.action.edit.stash.js
b/resources/src/mediawiki.action/mediawiki.action.edit.stash.js
index 2a48ee6..71ed44c 100644
--- a/resources/src/mediawiki.action/mediawiki.action.edit.stash.js
+++ b/resources/src/mediawiki.action/mediawiki.action.edit.stash.js
@@ -71,9 +71,14 @@
}
function onFormLoaded() {
- // Reverts may involve use (undo) links; stash as they
review the diff.
- // Since the form has a pre-filled summary, stash the
edit immediately.
- if ( mw.util.getParamValue( 'undo' ) !== null ) {
+ if (
+ // Reverts may involve use (undo) links; stash
as they review the diff.
+ // Since the form has a pre-filled summary,
stash the edit immediately.
+ mw.util.getParamValue( 'undo' ) !== null
+ // Pressing "show changes" and "preview" also
signify that the user will
+ // probably save the page soon
+ || $.inArray( $form.find( '#mw-edit-mode'
).val(), [ 'preview', 'diff' ] ) > -1
+ ) {
stashEdit();
}
}
--
To view, visit https://gerrit.wikimedia.org/r/294382
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ied77bdbd191dd9267d4295b0fa7b942f65b062db
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.28.0-wmf.6
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Edokter <[email protected]>
Gerrit-Reviewer: Jack Phoenix <[email protected]>
Gerrit-Reviewer: Jackmcbarn <[email protected]>
Gerrit-Reviewer: Tpt <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits