commit | 565d8e6cc148428fcb5b607d4a811e9df1576cf7 | [log] [tgz] |
---|---|---|
author | Umherirrender <umherirrender_de.wp@web.de> | Thu Oct 11 18:10:06 2018 +0000 |
committer | Umherirrender <umherirrender_de.wp@web.de> | Thu Oct 11 18:10:43 2018 +0000 |
tree | fecd7594d9bb4b1ed15e8d755d683f24292eecee | |
parent | 9ceb1416b9e2f226634839894c2c0afd7531f8e9 [diff] |
Increase required MediaWiki version Namespaces from Iaab6f6d61b511ee350bd541e5c0cdf1fcec6eadb are in 1.32 (I16bea8927566a3c73c07e4f4afb3537e05aa04a5) Follow-Up: Iaab6f6d61b511ee350bd541e5c0cdf1fcec6eadb Change-Id: I9e4b456e90ee2b267027e3b88fc6c62f2b290e05
This MediaWiki extension allows for the easy importing of a file from one site to another. The word site is chosen specifically here as there is no reason code can not be written allowing the importing of files from sites that are not MediaWiki wikis.
This extension has been created as part of the 2013 German Community Technical Wishlist where a wish requested that it be possible to "Correctly move files from Wikipedia to Commons" including file & description page history along with maintaining edit attribution & migrating templates.
Please also see the FileExporter extension which provides a link on the file pages of a MediaWiki site to link to a wiki that is running the FileImporter extension.
FileImporterRequiredRight specifies the user right required to use the special page. Default is "upload" – the same right [[Special:Upload]] requires.
The FileImporterSourceSiteServices setting lists enabled services responsible for imports from different sources. Each service allows extensions and modifications of data retrieved by it and limits the type of sites where files can be imported from. The default empty list []
allows files to be imported from any MediaWiki site. Set the list to [ 'FileImporter-WikimediaSitesTableSite' ]
if you only want to allow imports from sites that are in the sites table.
FileImporterMaxRevisions specifies the maximum number of revisions (file or text) a file can have in order to be imported. This is restricted to a hard-coded default of 100, which can be lowered via configuration, but not raised.
FileImporterMaxAggregatedBytes specifies the maximum aggregated size of versions a file can have in order to be imported. This is restricted to a hard-coded default of 250 MB, which can be lowered via configuration, but not raised.
FileImporterShowInputScreen enables the FileImporter special page to be used without being directed there by the FileExporter
extension's link. If set to true
an input field shows on the Special:ImportFile
that can be used to import files. Default is false
.
FileImporterInterWikiMap specifies a map from host names to interwiki prefixes, e.g. [ 'de.wikisource.org' => 's:de' ]
. This is currently mandatory for chains of more than one prefix (e.g. s:de
to point from Wikimedia Commons to the German Wikisource), and optional for 1-level prefixes (e.g. mw
, which always points to mediawiki.org).
FileImporterCommonsHelperServer and FileImporterCommonsHelperBasePageName specify the location of CommonsHelper2-compatible rule sets that specify transfer rules and template migrations for individual source wikis. For example, with server and base page name set to https://www.mediawiki.org/
and Extension:FileImporter/Data/
, imports from en.wikipedia.org will be restricted by the rules specified in https://www.mediawiki.org/wiki/Extension:FileImporter/Data/en.wikipedia. See the later for a self-documenting example of such a rule set. Setting the server to an empty string turns the feature off.
FileImporterCommentForPostImportRevision defines the text used for the edit summary of a post import revision. Default is Imported with FileImporter from $1
where $1
is the URL of the source file.
FileImporterTextForPostImportRevision defines the text added to the top of the imported page's wikitext. Default is <!--This file was moved here using FileImporter from $1-->\n
where $1
is the URL of the source file.
In general the extension is build to be modular when it comes to the systems to import from. Code that deals with retrieving data from a source, transforming it and inserting it into corresponding MediaWiki objects (e.g. wiki pages and histories) is put into services that could be loaded depending on the type of the source system.
For now only code is included to import from other MediaWiki installations.
Direct database access to a remote MediaWiki installation is not required. All request are done server-side utilizing MediaWiki's HttpRequest infrastructure (see HttpRequestExecutor
). MediaWiki typically utilizes CURL for this, depending on the servers configuration (see MWHttpRequest::factory
and HttpRequestFactory
).
HttpApiLookup
).<link rel="EditURI" href="…" />
in the header of the HTML page.action=query
API to request all non-binary information (see ApiDetailRetriever
).prop=revisions
in the query API).prop=imageinfo
in the query API).TextRevision
and FileRevision
objects, in FileRevisions
and TextRevisions
collections, and in a combined ImportDetails
object.url
it got from the ImageInfo query API (see FileRevisionFromRemoteUrl::prepare
). These are the "fully-qualified URL to the file" (see File::getFullUrl
).HttpRequestExecutor
).FileRevisionFromRemoteUrl::prepare
).TempFSFile
from MediaWiki's FileBackend infrastructure is utilized for this.fopen( …, 'wb' )
(see FileChunkSaver
).FileRevisionFromRemoteUrl::commit
).UploadRevisionImporter
).LocalFile::upload
is called, and OldLocalFile::uploadOld
for archived file revisions.OldRevisionImporter
).When failures occur:
TempFSFile
takes care of this.Importer::importInternal
), as discussed in https://phabricator.wikimedia.org/T147451. This means a failure while moving a temporary file to it's final location might leave a file description page behind with no or not all expected file revisions. This page might need to be deleted manually.