Page MenuHomePhabricator

Allow setting target namespace in importDump.php
Open, Needs TriagePublic

Description

Special:Import allows pages to be placed into a selected namespace.
This functionality is not present in importDump.php.

My reason for needing this is importing Wikidata items from namespace 0 into a custom Item: namespace.

Note that this is not required to import Wikidata properties from namespace 120 to a different namespace number if the namespace name is "Property".

Details

Event Timeline

Change 306219 had a related patch set uploaded (by John Vandenberg):
Allow importing to specified namespace

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

The attached patch in gerrit has the problem that a dump with pages in multiple namespaces needs to be processed multiple times -- once for each source namespace that is mapped to a different target namespace. i.e.

  1. --namespaces=0 --to-namespace=$WB_NS_DATA, then
  2. --namespaces= --to-namespace=$WB_NS_DATA_TALK` , and then
  3. --namespaces=1|2|3|4|5|6|7|8|9|10|11|12|13|14|15 for unchanged namespaces

Another approach, which will require more development work, is to map XML source namespaces to the target wiki namespaces. i.e. the command line equivalent of T43969 , allowing that task to focus on the UI aspects.

This could be done with the --namespaces argument, which is currently only an inclusive filter for the namespaces to import, but it could be expanded to optionally specify the target namespace for each namespace included. e.g.

--namespaces=0:120|1:121|2|3|...

or

--namespaces=0:120|1:121|all

Some validation of the target namespaces will be needed (or at least useful), so it might be useful to solve T64111 first.

Change #306219 abandoned by Hashar:

[mediawiki/core@master] Allow importing to specified namespace

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

Change #306219 restored by Thcipriani:

[mediawiki/core@master] Allow importing to specified namespace

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