[MediaWiki-commits] [Gerrit] mediawiki...FileImporter[master]: Add an import notice to the top of an imported page's wikitext

2017-10-30 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/376778 )

Change subject: Add an import notice to the top of an imported page's wikitext
..


Add an import notice to the top of an imported page's wikitext

Bug: T160182
Change-Id: Ic32f8025338f81a64ccd060f3bd534ed3231212d
---
M extension.json
M src/Data/ImportPlan.php
M src/ServiceWiring.php
M src/Services/Importer.php
D src/Services/NullRevisionCreator.php
5 files changed, 39 insertions(+), 80 deletions(-)

Approvals:
  Addshore: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/extension.json b/extension.json
index f5fdf66..4a4533f 100644
--- a/extension.json
+++ b/extension.json
@@ -55,7 +55,6 @@
"FileImporter\\Services\\Importer": "src/Services/Importer.php",
"FileImporter\\Services\\ImportPlanFactory": 
"src/Services/ImportPlanFactory.php",
"FileImporter\\Services\\ImportPlanValidator": 
"src/Services/ImportPlanValidator.php",
-   "FileImporter\\Services\\NullRevisionCreator": 
"src/Services/NullRevisionCreator.php",
"FileImporter\\Services\\SourceSite": 
"src/Services/SourceSite.php",
"FileImporter\\Services\\SourceSiteLocator": 
"src/Services/SourceSiteLocator.php",
"FileImporter\\Services\\SourceUrlNormalizer": 
"src/Services/SourceUrlNormalizer.php",
@@ -87,7 +86,11 @@
"FileImporterSourceSiteServices": [],
"FileImporterTextPotentialProblems": [],
"FileImporterTextReplacements": [],
-   "FileImporterAccountForSuppressedUsername": 
"FileImporterSuppressed"
+   "FileImporterAccountForSuppressedUsername": 
"FileImporterSuppressed",
+   "@FileImporterCommentForPostImportRevision": "Text used for the 
edit summary of a post import revision.",
+   "FileImporterCommentForPostImportRevision": "Imported with 
FileImporter from $1",
+   "@FileImporterTextForPostImportRevision": "Text added to the 
top of the imported page's wikitext",
+   "FileImporterTextForPostImportRevision": "\n"
},
"ResourceModules": {
"ext.FileImporter.Special": {
diff --git a/src/Data/ImportPlan.php b/src/Data/ImportPlan.php
index 5dc279d..5f192ab 100644
--- a/src/Data/ImportPlan.php
+++ b/src/Data/ImportPlan.php
@@ -122,15 +122,28 @@
return $intendedWikiText;
}
}
-   return 
$this->getDetails()->getTextRevisions()->getLatest()->getField( '*' );
+   return $this->getInitialFileInfoText();
+   }
+
+   /**
+* Appends a marker to the beginning of the original File Info Text 
indicating that
+* it was imported using FileImporter
+*
+* @return string
+*/
+   public function getInitialFileInfoText() {
+   $config = MediaWikiServices::getInstance()->getMainConfig();
+
+   return wfMsgReplaceArgs(
+   $config->get( 'FileImporterTextForPostImportRevision' 
), [ $this->request->getUrl() ]
+   ) . 
$this->details->getTextRevisions()->getLatest()->getField( '*' );
}
 
/**
 * @return bool
 */
public function wasFileInfoTextChanged() {
-   return $this->getFileInfoText() !== 
$this->getDetails()->getTextRevisions()->getLatest()
-   ->getField( '*' );
+   return $this->getFileInfoText() !== 
$this->getInitialFileInfoText();
}
 
 }
diff --git a/src/ServiceWiring.php b/src/ServiceWiring.php
index 8d3fa31..4de81ae 100644
--- a/src/ServiceWiring.php
+++ b/src/ServiceWiring.php
@@ -10,7 +10,6 @@
 use FileImporter\Services\Http\HttpRequestExecutor;
 use FileImporter\Services\Importer;
 use FileImporter\Services\ImportPlanFactory;
-use FileImporter\Services\NullRevisionCreator;
 use FileImporter\Services\SourceSite;
 use FileImporter\Services\SourceSiteLocator;
 use FileImporter\Services\SourceUrlNormalizer;
@@ -58,24 +57,17 @@
'FileImporterImporter' => function ( MediaWikiServices $services ) {
/** @var WikiRevisionFactory $wikiRevisionFactory */
$wikiRevisionFactory = $services->getService( 
'FileImporterWikiRevisionFactory' );
-   /** @var NullRevisionCreator $nullRevisionCreator */
-   $nullRevisionCreator = $services->getService( 
'FileImporterNullRevisionCreator' );
/** @var HttpRequestExecutor $httpRequestExecutor */
$httpRequestExecutor = $services->getService( 
'FileImporterHttpRequestExecutor' );
/** @var UploadBaseFactory $uploadBaseFactory */
$uploadBaseFactory = $services->getService( 
'FileImporterUploadBaseFactory' );
$importer = new Importer(
 

[MediaWiki-commits] [Gerrit] mediawiki...FileImporter[master]: Add an import notice to the top of an imported page's wikitext

2017-09-08 Thread Andrew-WMDE (Code Review)
Andrew-WMDE has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/376778 )

Change subject: Add an import notice to the top of an imported page's wikitext
..

Add an import notice to the top of an imported page's wikitext

Should the message be translatable/changeable in i18n or should it
be hardcoded?

Bug: T160182
Change-Id: Ic32f8025338f81a64ccd060f3bd534ed3231212d
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M src/Data/ImportPlan.php
M src/ServiceWiring.php
M src/Services/Importer.php
D src/Services/NullRevisionCreator.php
7 files changed, 48 insertions(+), 93 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/FileImporter 
refs/changes/78/376778/1

diff --git a/extension.json b/extension.json
index fc3..448db26 100644
--- a/extension.json
+++ b/extension.json
@@ -55,7 +55,6 @@
"FileImporter\\Services\\Importer": "src/Services/Importer.php",
"FileImporter\\Services\\ImportPlanFactory": 
"src/Services/ImportPlanFactory.php",
"FileImporter\\Services\\ImportPlanValidator": 
"src/Services/ImportPlanValidator.php",
-   "FileImporter\\Services\\NullRevisionCreator": 
"src/Services/NullRevisionCreator.php",
"FileImporter\\Services\\SourceSite": 
"src/Services/SourceSite.php",
"FileImporter\\Services\\SourceSiteLocator": 
"src/Services/SourceSiteLocator.php",
"FileImporter\\Services\\WikiRevisionFactory": 
"src/Services/WikiRevisionFactory.php",
diff --git a/i18n/en.json b/i18n/en.json
index e9857b2..923600f 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -19,15 +19,15 @@
"fileimporter-cantimportmissingfile": "Can't import a missing file.",
"fileimporter-badtoken": "CSRF token does not match",
"fileimporter-badimporthash": "Import hash does not match. Please 
restart the import.",
-   "fileimporter-filenameerror-default" : "There is an unknown issue with 
your filename.",
-   "fileimporter-filenameerror-illegal" : "The file name you are currently 
trying to import to is invalid.",
-   "fileimporter-filenameerror-toolong" : "The file name you are currently 
trying to import to is too long.",
-   "fileimporter-filenameerror-automaticchanges" : "The file name you are 
currently trying to import to will be automatically changed to \"$1\" due to 
the use of invalid characters.",
-   "fileimporter-localtitleexists" : "The title you are currently trying 
to import to already exists on this wiki.",
-   "fileimporter-sourcetitleexists" : "The title you are currently trying 
to import to already exists on the source wiki.",
-   "fileimporter-illegalfilenamechars" : "The title you are currently 
trying to import to contains invalid filename characters.",
-   "fileimporter-duplicatefilesdetected" : "The file you are currently 
trying to import already exists on this wiki.",
-   "fileimporter-duplicatefilesdetected-prefix" : "Duplicates",
+   "fileimporter-filenameerror-default": "There is an unknown issue with 
your filename.",
+   "fileimporter-filenameerror-illegal": "The file name you are currently 
trying to import to is invalid.",
+   "fileimporter-filenameerror-toolong": "The file name you are currently 
trying to import to is too long.",
+   "fileimporter-filenameerror-automaticchanges": "The file name you are 
currently trying to import to will be automatically changed to \"$1\" due to 
the use of invalid characters.",
+   "fileimporter-localtitleexists": "The title you are currently trying to 
import to already exists on this wiki.",
+   "fileimporter-sourcetitleexists": "The title you are currently trying 
to import to already exists on the source wiki.",
+   "fileimporter-illegalfilenamechars": "The title you are currently 
trying to import to contains invalid filename characters.",
+   "fileimporter-duplicatefilesdetected": "The file you are currently 
trying to import already exists on this wiki.",
+   "fileimporter-duplicatefilesdetected-prefix": "Duplicates",
"fileimporter-exampleprefix": "Example",
"fileimporter-textrevisions": "$1 {{PLURAL:$1|revision|revisions}} of 
the file will be imported.",
"fileimporter-submit": "Submit",
@@ -47,5 +47,7 @@
"fileimporter-heading-filehistory": "File history",
"fileimporter-revision-removed-text": "Suppressed text removed by 
FileImporter.",
"fileimporter-revision-removed-comment": "Suppressed comment removed by 
FileImporter.",
-   "fileimporter-in-beta": "File import is in beta mode: We tested it 
carefully but it still might have some problems. If you encounter problems, 
please [//www.mediawiki.org/w/index.php?title=Extension_talk:FileImporter 
report them on our help page] - ideally with a step by step way to reproduce 
the problem, so we can understand and fix it."
+