Addshore has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/344338 )
Change subject: Cleanly show warning when trying to import from shared repo
......................................................................
Cleanly show warning when trying to import from shared repo
Bug: T161126
Change-Id: I65c4d1189a2c805d6b916422c6f9522251cbb86a
---
M src/MediaWiki/ApiDetailRetriever.php
M src/SpecialImportFile.php
2 files changed, 20 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/FileImporter
refs/changes/38/344338/1
diff --git a/src/MediaWiki/ApiDetailRetriever.php
b/src/MediaWiki/ApiDetailRetriever.php
index aab7a20..e98ac38 100644
--- a/src/MediaWiki/ApiDetailRetriever.php
+++ b/src/MediaWiki/ApiDetailRetriever.php
@@ -131,6 +131,17 @@
}
$pageInfoData = array_pop( $requestData['query']['pages'] );
+
+ if ( array_key_exists( 'missing', $pageInfoData ) ) {
+ if (
+ array_key_exists( 'imagerepository',
$pageInfoData ) &&
+ $pageInfoData['imagerepository'] == 'shared' )
+ {
+ throw new ImportException( 'Can not import a
file from a share repository.' );
+ }
+ throw new ImportException( 'Can not import a missing
file.' );
+ }
+
$pageTitle = $pageInfoData['title'];
if ( !array_key_exists( 'imageinfo', $pageInfoData ) ||
diff --git a/src/SpecialImportFile.php b/src/SpecialImportFile.php
index 9e54da1..4e0f5b7 100644
--- a/src/SpecialImportFile.php
+++ b/src/SpecialImportFile.php
@@ -5,6 +5,7 @@
use File;
use FileImporter\Generic\Data\ImportTransformations;
use FileImporter\Generic\Data\ImportDetails;
+use FileImporter\Generic\Exceptions\ImportException;
use FileImporter\Generic\Services\DetailRetriever;
use FileImporter\Generic\Services\DuplicateFileRevisionChecker;
use FileImporter\Generic\Services\Importer;
@@ -75,7 +76,14 @@
return;
}
- $importDetails = $this->detailRetreiver->getImportDetails(
$targetUrl );
+ try{
+ $importDetails =
$this->detailRetreiver->getImportDetails( $targetUrl );
+ }
+ catch ( ImportException $e ) {
+ $this->showWarningMessage( $e->getMessage() ); // TODO
i18n
+ $this->showInputForm( $targetUrl );
+ return;
+ }
$duplicateFiles = $this->duplicateFileChecker->findDuplicates(
$importDetails->getFileRevisions()->getLatest()
);
--
To view, visit https://gerrit.wikimedia.org/r/344338
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I65c4d1189a2c805d6b916422c6f9522251cbb86a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/FileImporter
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits