TTO has uploaded a new change for review.

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

Change subject: Fix exception in Import, when import of a revision fails
......................................................................

Fix exception in Import, when import of a revision fails

A 'notice' is thrown when an import fails, for some reason,
such as the user does not have permission, and the reason
is reported to the user.

In this case, $title is false and not a Title object,
as needed by the beforeImportPage callback (which calls
WikiPage::factory).  As well, $pageInfo['_title'] is undefined,
in pageOutCallback, which also calls WikiPage::factory via
finishImportPage.

Bug: T108544
Change-Id: I55042fdf305cd1198d3a4b28a0ebb5ce31b76a1f
(cherry picked from commit 9442adf96d61579a15821248fd0b7560bfadb77c)
---
M includes/Import.php
1 file changed, 13 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/02/263202/1

diff --git a/includes/Import.php b/includes/Import.php
index 6a0bfd0..db4a6b2 100644
--- a/includes/Import.php
+++ b/includes/Import.php
@@ -728,13 +728,14 @@
                                        $title = $this->processTitle( 
$pageInfo['title'],
                                                isset( $pageInfo['ns'] ) ? 
$pageInfo['ns'] : null );
 
-                                       if ( !$title ) {
+                                       // $title is either an array of two 
titles or false.
+                                       if ( is_array( $title ) ) {
+                                               $this->pageCallback( $title );
+                                               list( $pageInfo['_title'], 
$foreignTitle ) = $title;
+                                       } else {
                                                $badTitle = true;
                                                $skip = true;
                                        }
-
-                                       $this->pageCallback( $title );
-                                       list( $pageInfo['_title'], 
$foreignTitle ) = $title;
                                }
 
                                if ( $title ) {
@@ -750,10 +751,17 @@
                        }
                }
 
-               $this->pageOutCallback( $pageInfo['_title'], $foreignTitle,
+               // @note $pageInfo is only set if a valid $title is processed 
above with
+               //       no error. If we have a valid $title, then pageCallback 
is called
+               //       above, $pageInfo['title'] is set and we do 
pageOutCallback here.
+               //       If $pageInfo['_title'] is not set, then $foreignTitle 
is also not
+               //       set since they both come from $title above.
+               if ( array_key_exists( '_title', $pageInfo ) ) {
+                       $this->pageOutCallback( $pageInfo['_title'], 
$foreignTitle,
                                        $pageInfo['revisionCount'],
                                        $pageInfo['successfulRevisionCount'],
                                        $pageInfo );
+               }
        }
 
        /**

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I55042fdf305cd1198d3a4b28a0ebb5ce31b76a1f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_26
Gerrit-Owner: TTO <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>

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

Reply via email to