Improve namespaceDupes.php
authorTim Starling <tstarling@wikimedia.org>
Thu, 5 Feb 2015 05:08:14 +0000 (16:08 +1100)
committerTim Starling <tstarling@wikimedia.org>
Fri, 13 Feb 2015 01:00:15 +0000 (01:00 +0000)
commit64765720b0b5cf4290a9d8f22bc10f13e3b7c101
tree9b5537602622ac6eed2c10f07b39997207328a46
parent147196cdaeee7d15799284eb4ef962055ef2a3fe
Improve namespaceDupes.php

General review and improvement in service of T87645.

* Add the option to add a prefix to a page on conflict, instead of a suffix.
  This makes it easier to find the pages after they are renamed, since
  [[Special:Prefixindex]] can be used.
* Rename options --prefix to --source-pseudo-ns, --suffix to --add-suffix,
  --key to --dest-ns.
* Document --source-pseudo-ns and verify that it does what I think it was
  meant to do, per T14371, thus allowing me to remove the "todo" note.
* Add the option to do a history merge instead of a rename to resolve
  conflicts.
* Pass around an options array instead of an ever-growing list of formal
  parameters.
* Rename resolveConflictOn() to movePage() and remove the $table and
  $prefix parameters which were unused since MW 1.5. Also get rid of
  the usage AS in getConflicts(), most instances of which were for MW 1.4
  compatibility.
* Rename getConflicts() to getTargetList() since "conflict" is a
  misnomer. A conflict occurs between two entities, really what the code
  was calling an "unresolvable conflict" is actually a conflict, whereas a
  "resolvable conflict" is merely a page in the wrong namespace.
* Add option --move-talk since checking the talk namespace doesn't make sense
  in the case of corruption, it only makes sense when introducing a new
  namespace, when a pseudo-namespace has previously been used.
* Use terse, greppable output, with a single line per page.
* Replace ksort() followed by asort() with a single uksort(), since I think
  that is what was intended. PHP's sort functions are not stable, so you
  can't run two different sort functions on the same array and expect to the
  first sort to have a predictable effect on the result.
* If --fix is not given, give the same output, just don't take the action.
* Refactor checkNamespace(). Move target title determination to its own
  function, was a mixture of SQL and a couple of lines in reportConflict().
  Move alternate title determination to its own function, was mostly in
  resolveConflict(). Get rid of reportConflict() and resolveConflict(), do
  what's left of them in the main loop. Get rid of modification of page row.
* Improve destination namespace calculation logic of --move-talk feature,
  per comments by PleaseStand.

Change-Id: I49921315315e1a29c9559ba221e9903b10b73d68
maintenance/namespaceDupes.php