Daniel Kinzler has uploaded a new change for review.

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


Change subject: (bug 46624) Avoid fatal when undoing deleted rev.
......................................................................

(bug 46624) Avoid fatal when undoing deleted rev.

An undo action that involved a revision that was delted, oversighted or 
otherwise
missing content triggered a fatal error. Added a check and nice error message.-

Change-Id: I37e82b999d7eea7cf3761960a3d3df467582a596
---
M repo/Wikibase.i18n.php
M repo/includes/actions/EditEntityAction.php
2 files changed, 17 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/77/56377/1

diff --git a/repo/Wikibase.i18n.php b/repo/Wikibase.i18n.php
index 6a87374..8cb5d12 100644
--- a/repo/Wikibase.i18n.php
+++ b/repo/Wikibase.i18n.php
@@ -56,6 +56,7 @@
        'wikibase-undo-samerev' => 'Cannot undo, same revision given for undo 
base and undo target.',
        'wikibase-undo-badpage' => 'Bad revision: Revision $2 does not belong 
to [[$1]].',
        'wikibase-undo-firstrev' => "Cannot undo the page's creation",
+       'wikibase-undo-nocontent' => "Cannot load content of revision $2 of 
page $1",
        'wikibase-propertyedittool-full' => 'List of values is complete.',
        'wikibase-ui-pendingquantitycounter-nonpending' => '$2 $1',
        'wikibase-ui-pendingquantitycounter-pending' => '$2$3 $1',
@@ -493,6 +494,10 @@
 * $1 is the title of the page;
 * $2 is the revision id number.',
        'wikibase-undo-firstrev' => "Message shown when the user attempts to 
undo the very first revision of a page, that is, the page's creation.",
+       'wikibase-undo-nocontent' => "Message shown when the content of one of 
the revisions needed for undo could not be loaded.
+This may happen if there is an error ion the storage backend, or if the 
respective revision has been hidden (oversighted) or deleted.
+* $1 is the title of the page;
+* $2 is the revision id number.",
        'wikibase-propertyedittool-full' => 'A list of elements the user is 
assumed to enter is now complete.',
        'wikibase-ui-pendingquantitycounter-nonpending' => "Message for a 
generic counter which will display a quantity and of what nature that quantity 
is. Parameters:
 * $1 is the label of the counter's subject. E.g. 'sources' in an item's 
statement's references counter displayed in the heading above the references.
diff --git a/repo/includes/actions/EditEntityAction.php 
b/repo/includes/actions/EditEntityAction.php
index e822e93..0af55f6 100644
--- a/repo/includes/actions/EditEntityAction.php
+++ b/repo/includes/actions/EditEntityAction.php
@@ -130,6 +130,18 @@
                        return Status::newFatal( 'wikibase-undo-badpage', 
$this->getTitle(), $olderRevision->getId() );
                }
 
+               if ( $olderRevision->getContent() === null ) {
+                       return Status::newFatal( 'wikibase-undo-nocontent', 
$this->getTitle(), $olderRevision->getId() );
+               }
+
+               if ( $newerRevision->getContent() === null ) {
+                       return Status::newFatal( 'wikibase-undo-nocontent', 
$this->getTitle(), $newerRevision->getId() );
+               }
+
+               if ( $latestRevision->getContent() === null ) {
+                       return Status::newFatal( 'wikibase-undo-nocontent', 
$this->getTitle(), $latestRevision->getId() );
+               }
+
                return Status::newGood( array(
                        $olderRevision, $newerRevision, $latestRevision,
                ) );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I37e82b999d7eea7cf3761960a3d3df467582a596
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to