Mattflaschen has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/289239

Change subject: WIP: Use ArticleRevisionUndeleted instead of ArticleUndelete
......................................................................

WIP: Use ArticleRevisionUndeleted instead of ArticleUndelete

ArticleUndelete was broken in the following scenario (but possibly also
others)

1. Create page as wikitext.
2. Delete wikitext
3. Use Special:EnableFlow to create as Flow
4. Delete Flow
5. Restore just the wikitext
6. Restore Flow using revision checkbox

This was partly because of Ia0ed86a9c24809256215418673e9ee8e263d1349
(it didn't recognize that the new top-level revision would be
Flow, so it didn't know to update the Flow workflows).

However, fixing that then causes it to reject the change,
since the current Title's ID (from the wikitext revision) is different
from the old page ID.  It's actually Flow on top of wikitext,
but it wrongly detects it.

This needs more testing, but I think processing every revision
will avoid inconsistent states.

Bug: T122262
Change-Id: I552c119b47268a7888cf78d2fd1d5a9d98d51856
---
M Flow.php
M Hooks.php
2 files changed, 6 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/39/289239/1

diff --git a/Flow.php b/Flow.php
index b380656..ea36504 100644
--- a/Flow.php
+++ b/Flow.php
@@ -151,7 +151,7 @@
 $wgHooks['ArticleConfirmDelete'][] = 'FlowHooks::onArticleConfirmDelete';
 $wgHooks['ArticleDelete'][] = 'FlowHooks::onArticleDelete';
 $wgHooks['ArticleDeleteComplete'][] = 'FlowHooks::onArticleDeleteComplete';
-$wgHooks['ArticleUndelete'][] = 'FlowHooks::onArticleUndelete';
+$wgHooks['ArticleRevisionUndeleted'][] = 
'FlowHooks::onArticleRevisionUndeleted';
 $wgHooks['SearchableNamespaces'][] = 'FlowHooks::onSearchableNamespaces';
 $wgHooks['ImportHandleToplevelXMLTag'][] = 
'FlowHooks::onImportHandleToplevelXMLTag';
 
diff --git a/Hooks.php b/Hooks.php
index 2bb4d5f..0ac6e39 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -1586,24 +1586,19 @@
 
        /**
         * @param Title $title Title corresponding to the article restored
-        * @param bool $created Whether or not the restoration caused the page 
to be created (i.e. it didn't exist before).
-        * @param string $comment The comment associated with the undeletion.
-        * @param int $oldPageId ID of page previously deleted (from archive 
table)
+        * @param Revision $revision Revision just undeleted
+        * @param string $oldPageId Old page ID stored with that revision when 
it was in the archive table
         * @throws InvalidUndeleteException
         * @return bool
         */
-       public static function onArticleUndelete( Title $title, $created, 
$comment, $oldPageId ) {
-               if ( $title->getContentModel() === CONTENT_MODEL_FLOW_BOARD ) {
-                       if ( $title->getArticleID() !== $oldPageId ) {
-                               throw new InvalidUndeleteException( 'Failed to 
move ' . $oldPageId . ' over ' . $title->getArticleID() );
-                       }
-
+       public static function onArticleRevisionUndeleted( Title $title, 
Revision $revision, $oldPageId ) {
+               if ( $revision->getContentModel() === CONTENT_MODEL_FLOW_BOARD 
) {
                        // complete hack to make sure that when the page is 
saved to new
                        // location and rendered it doesn't throw an error 
about the wrong title
                        Container::get( 'factory.loader.workflow' 
)->pageMoveInProgress();
                        // open a database transaction and prepare everything 
for the move & commit
                        $boardMover = Container::get( 'board_mover' );
-                       $boardMover->prepareMove( $oldPageId, $title );
+                       $boardMover->prepareMove( intval( $oldPageId ), $title 
);
                        $boardMover->commit();
                }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/289239
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I552c119b47268a7888cf78d2fd1d5a9d98d51856
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Mattflaschen <mflasc...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to