2005-06-08 13:08:34 +00:00
|
|
|
<?php
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
/**
|
2009-08-02 19:35:17 +00:00
|
|
|
* Check for articles to fix after adding/deleting namespaces
|
|
|
|
|
*
|
2012-07-25 19:31:06 +00:00
|
|
|
* Copyright © 2005-2007 Brion Vibber <brion@pobox.com>
|
2014-03-20 15:45:01 +00:00
|
|
|
* https://www.mediawiki.org/
|
2009-08-02 19:35:17 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
2012-07-25 19:31:06 +00:00
|
|
|
* @file
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Maintenance
|
|
|
|
|
*/
|
|
|
|
|
|
2017-03-30 20:46:06 +00:00
|
|
|
require_once __DIR__ . '/Maintenance.php';
|
|
|
|
|
|
2016-04-20 08:29:21 +00:00
|
|
|
use MediaWiki\Linker\LinkTarget;
|
2017-01-10 09:51:50 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2017-02-19 05:03:13 +00:00
|
|
|
use Wikimedia\Rdbms\ResultWrapper;
|
2017-03-30 20:46:06 +00:00
|
|
|
use Wikimedia\Rdbms\IMaintainableDatabase;
|
2005-06-08 13:08:34 +00:00
|
|
|
|
2012-07-25 19:31:06 +00:00
|
|
|
/**
|
|
|
|
|
* Maintenance script that checks for articles to fix after
|
|
|
|
|
* adding/deleting namespaces.
|
|
|
|
|
*
|
|
|
|
|
* @ingroup Maintenance
|
|
|
|
|
*/
|
2018-05-24 01:34:01 +00:00
|
|
|
class NamespaceDupes extends Maintenance {
|
2011-09-07 21:14:55 +00:00
|
|
|
|
|
|
|
|
/**
|
2017-03-30 20:46:06 +00:00
|
|
|
* @var IMaintainableDatabase
|
2011-09-07 21:14:55 +00:00
|
|
|
*/
|
|
|
|
|
protected $db;
|
|
|
|
|
|
2015-02-13 05:06:13 +00:00
|
|
|
private $resolvablePages = 0;
|
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
2015-02-05 05:08:14 +00:00
|
|
|
private $totalPages = 0;
|
|
|
|
|
|
2015-02-13 05:06:13 +00:00
|
|
|
private $resolvableLinks = 0;
|
|
|
|
|
private $totalLinks = 0;
|
|
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
public function __construct() {
|
|
|
|
|
parent::__construct();
|
2016-01-30 02:48:47 +00:00
|
|
|
$this->addDescription( 'Find and fix pages affected by namespace addition/removal' );
|
2009-08-02 19:35:17 +00:00
|
|
|
$this->addOption( 'fix', 'Attempt to automatically fix errors' );
|
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
2015-02-05 05:08:14 +00:00
|
|
|
$this->addOption( 'merge', "Instead of renaming conflicts, do a history merge with " .
|
|
|
|
|
"the correct title" );
|
|
|
|
|
$this->addOption( 'add-suffix', "Dupes will be renamed with correct namespace with " .
|
2014-04-23 18:09:13 +00:00
|
|
|
"<text> appended after the article name", false, true );
|
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
2015-02-05 05:08:14 +00:00
|
|
|
$this->addOption( 'add-prefix', "Dupes will be renamed with correct namespace with " .
|
|
|
|
|
"<text> prepended before the article name", false, true );
|
|
|
|
|
$this->addOption( 'source-pseudo-namespace', "Move all pages with the given source " .
|
|
|
|
|
"prefix (with an implied colon following it). If --dest-namespace is not specified, " .
|
|
|
|
|
"the colon will be replaced with a hyphen.",
|
|
|
|
|
false, true );
|
|
|
|
|
$this->addOption( 'dest-namespace', "In combination with --source-pseudo-namespace, " .
|
|
|
|
|
"specify the namespace ID of the destination.", false, true );
|
|
|
|
|
$this->addOption( 'move-talk', "If this is specified, pages in the Talk namespace that " .
|
|
|
|
|
"begin with a conflicting prefix will be renamed, for example " .
|
|
|
|
|
"Talk:File:Foo -> File_Talk:Foo" );
|
2009-08-02 19:35:17 +00:00
|
|
|
}
|
2005-06-08 13:08:34 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
public function execute() {
|
2015-12-31 00:07:37 +00:00
|
|
|
$this->db = $this->getDB( DB_MASTER );
|
2009-08-02 19:35:17 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$options = [
|
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
2015-02-05 05:08:14 +00:00
|
|
|
'fix' => $this->hasOption( 'fix' ),
|
|
|
|
|
'merge' => $this->hasOption( 'merge' ),
|
|
|
|
|
'add-suffix' => $this->getOption( 'add-suffix', '' ),
|
|
|
|
|
'add-prefix' => $this->getOption( 'add-prefix', '' ),
|
|
|
|
|
'move-talk' => $this->hasOption( 'move-talk' ),
|
|
|
|
|
'source-pseudo-namespace' => $this->getOption( 'source-pseudo-namespace', '' ),
|
2016-02-17 09:09:32 +00:00
|
|
|
'dest-namespace' => intval( $this->getOption( 'dest-namespace', 0 ) ) ];
|
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
2015-02-05 05:08:14 +00:00
|
|
|
|
|
|
|
|
if ( $options['source-pseudo-namespace'] !== '' ) {
|
|
|
|
|
$retval = $this->checkPrefix( $options );
|
2009-08-02 19:35:17 +00:00
|
|
|
} else {
|
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
2015-02-05 05:08:14 +00:00
|
|
|
$retval = $this->checkAll( $options );
|
2009-08-02 19:35:17 +00:00
|
|
|
}
|
2010-12-04 03:20:14 +00:00
|
|
|
|
2010-05-22 16:50:39 +00:00
|
|
|
if ( $retval ) {
|
2009-08-02 19:35:17 +00:00
|
|
|
$this->output( "\nLooks good!\n" );
|
|
|
|
|
} else {
|
|
|
|
|
$this->output( "\nOh noeees\n" );
|
|
|
|
|
}
|
2005-06-08 13:08:34 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
/**
|
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
2015-02-05 05:08:14 +00:00
|
|
|
* Check all namespaces
|
|
|
|
|
*
|
|
|
|
|
* @param array $options Associative array of validated command-line options
|
2011-10-18 17:32:20 +00:00
|
|
|
*
|
|
|
|
|
* @return bool
|
2009-08-02 19:35:17 +00:00
|
|
|
*/
|
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
2015-02-05 05:08:14 +00:00
|
|
|
private function checkAll( $options ) {
|
2018-07-29 12:24:54 +00:00
|
|
|
global $wgNamespaceAliases, $wgCapitalLinks;
|
2010-12-04 03:20:14 +00:00
|
|
|
|
2018-07-29 12:24:54 +00:00
|
|
|
$contLang = MediaWikiServices::getInstance()->getContentLanguage();
|
2016-02-17 09:09:32 +00:00
|
|
|
$spaces = [];
|
2010-12-04 03:20:14 +00:00
|
|
|
|
2007-06-26 21:18:27 +00:00
|
|
|
// List interwikis first, so they'll be overridden
|
|
|
|
|
// by any conflicting local namespaces.
|
2010-05-22 16:50:39 +00:00
|
|
|
foreach ( $this->getInterwikiList() as $prefix ) {
|
2018-07-29 12:24:54 +00:00
|
|
|
$name = $contLang->ucfirst( $prefix );
|
2007-06-26 21:18:27 +00:00
|
|
|
$spaces[$name] = 0;
|
2007-06-26 20:18:23 +00:00
|
|
|
}
|
2007-06-26 21:18:27 +00:00
|
|
|
|
|
|
|
|
// Now pull in all canonical and alias namespaces...
|
2011-04-08 07:14:42 +00:00
|
|
|
foreach ( MWNamespace::getCanonicalNamespaces() as $ns => $name ) {
|
2007-06-26 21:18:27 +00:00
|
|
|
// This includes $wgExtraNamespaces
|
2010-05-22 16:50:39 +00:00
|
|
|
if ( $name !== '' ) {
|
2007-06-26 21:18:27 +00:00
|
|
|
$spaces[$name] = $ns;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-29 12:24:54 +00:00
|
|
|
foreach ( $contLang->getNamespaces() as $ns => $name ) {
|
2010-05-22 16:50:39 +00:00
|
|
|
if ( $name !== '' ) {
|
2007-06-26 21:18:27 +00:00
|
|
|
$spaces[$name] = $ns;
|
|
|
|
|
}
|
2007-06-26 20:18:23 +00:00
|
|
|
}
|
2010-05-22 16:50:39 +00:00
|
|
|
foreach ( $wgNamespaceAliases as $name => $ns ) {
|
2007-06-26 20:18:23 +00:00
|
|
|
$spaces[$name] = $ns;
|
|
|
|
|
}
|
2018-07-29 12:24:54 +00:00
|
|
|
foreach ( $contLang->getNamespaceAliases() as $name => $ns ) {
|
2007-06-26 20:18:23 +00:00
|
|
|
$spaces[$name] = $ns;
|
|
|
|
|
}
|
2010-12-04 03:20:14 +00:00
|
|
|
|
2007-12-21 17:49:30 +00:00
|
|
|
// We'll need to check for lowercase keys as well,
|
|
|
|
|
// since we're doing case-sensitive searches in the db.
|
2010-05-22 16:50:39 +00:00
|
|
|
foreach ( $spaces as $name => $ns ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$moreNames = [];
|
2018-07-29 12:24:54 +00:00
|
|
|
$moreNames[] = $contLang->uc( $name );
|
|
|
|
|
$moreNames[] = $contLang->ucfirst( $contLang->lc( $name ) );
|
|
|
|
|
$moreNames[] = $contLang->ucwords( $name );
|
|
|
|
|
$moreNames[] = $contLang->ucwords( $contLang->lc( $name ) );
|
|
|
|
|
$moreNames[] = $contLang->ucwordbreaks( $name );
|
|
|
|
|
$moreNames[] = $contLang->ucwordbreaks( $contLang->lc( $name ) );
|
2010-05-22 16:50:39 +00:00
|
|
|
if ( !$wgCapitalLinks ) {
|
|
|
|
|
foreach ( $moreNames as $altName ) {
|
2018-07-29 12:24:54 +00:00
|
|
|
$moreNames[] = $contLang->lcfirst( $altName );
|
2007-12-21 17:49:30 +00:00
|
|
|
}
|
2018-07-29 12:24:54 +00:00
|
|
|
$moreNames[] = $contLang->lcfirst( $name );
|
2007-12-21 17:49:30 +00:00
|
|
|
}
|
2010-05-22 16:50:39 +00:00
|
|
|
foreach ( array_unique( $moreNames ) as $altName ) {
|
|
|
|
|
if ( $altName !== $name ) {
|
2007-12-21 17:49:30 +00:00
|
|
|
$spaces[$altName] = $ns;
|
|
|
|
|
}
|
2007-06-26 21:18:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-12-04 03:20:14 +00:00
|
|
|
|
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
2015-02-05 05:08:14 +00:00
|
|
|
// Sort by namespace index, and if there are two with the same index,
|
|
|
|
|
// break the tie by sorting by name
|
|
|
|
|
$origSpaces = $spaces;
|
|
|
|
|
uksort( $spaces, function ( $a, $b ) use ( $origSpaces ) {
|
Use PHP 7 '<=>' operator in 'sort()' callbacks
`$a <=> $b` returns `-1` if `$a` is lesser, `1` if `$b` is lesser,
and `0` if they are equal, which are exactly the values 'sort()'
callbacks are supposed to return.
It also enables the neat idiom `$a[x] <=> $b[x] ?: $a[y] <=> $b[y]`
to sort arrays of objects first by 'x', and by 'y' if they are equal.
* Replace a common pattern like `return $a < $b ? -1 : 1` with the
new operator (and similar patterns with the variables, the numbers
or the comparison inverted). Some of the uses were previously not
correctly handling the variables being equal; this is now
automatically fixed.
* Also replace `return $a - $b`, which is equivalent to `return
$a <=> $b` if both variables are integers but less intuitive.
* (Do not replace `return strcmp( $a, $b )`. It is also equivalent
when both variables are strings, but if any of the variables is not,
'strcmp()' converts it to a string before comparison, which could
give different results than '<=>', so changing this would require
careful review and isn't worth it.)
* Also replace `return $a > $b`, which presumably sort of works most
of the time (returns `1` if `$b` is lesser, and `0` if they are
equal or `$a` is lesser) but is erroneous.
Change-Id: I19a3d2fc8fcdb208c10330bd7a42c4e05d7f5cf3
2017-10-06 20:39:13 +00:00
|
|
|
return $origSpaces[$a] <=> $origSpaces[$b]
|
|
|
|
|
?: $a <=> $b;
|
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
2015-02-05 05:08:14 +00:00
|
|
|
} );
|
2010-12-04 03:20:14 +00:00
|
|
|
|
2005-06-08 13:08:34 +00:00
|
|
|
$ok = true;
|
2010-05-22 16:50:39 +00:00
|
|
|
foreach ( $spaces as $name => $ns ) {
|
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
2015-02-05 05:08:14 +00:00
|
|
|
$ok = $this->checkNamespace( $ns, $name, $options ) && $ok;
|
2005-06-08 13:08:34 +00:00
|
|
|
}
|
2014-04-23 18:09:13 +00:00
|
|
|
|
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
2015-02-05 05:08:14 +00:00
|
|
|
$this->output( "{$this->totalPages} pages to fix, " .
|
2015-02-13 05:06:13 +00:00
|
|
|
"{$this->resolvablePages} were resolvable.\n\n" );
|
|
|
|
|
|
|
|
|
|
foreach ( $spaces as $name => $ns ) {
|
|
|
|
|
if ( $ns != 0 ) {
|
2015-10-14 07:40:50 +00:00
|
|
|
/* Fix up link destinations for non-interwiki links only.
|
|
|
|
|
*
|
|
|
|
|
* For example if a page has [[Foo:Bar]] and then a Foo namespace
|
|
|
|
|
* is introduced, pagelinks needs to be updated to have
|
|
|
|
|
* page_namespace = NS_FOO.
|
|
|
|
|
*
|
|
|
|
|
* If instead an interwiki prefix was introduced called "Foo",
|
|
|
|
|
* the link should instead be moved to the iwlinks table. If a new
|
|
|
|
|
* language is introduced called "Foo", or if there is a pagelink
|
|
|
|
|
* [[fr:Bar]] when interlanguage magic links are turned on, the
|
|
|
|
|
* link would have to be moved to the langlinks table. Let's put
|
|
|
|
|
* those cases in the too-hard basket for now. The consequences are
|
|
|
|
|
* not especially severe.
|
|
|
|
|
* @fixme Handle interwiki links, and pagelinks to Category:, File:
|
|
|
|
|
* which probably need reparsing.
|
|
|
|
|
*/
|
2015-02-13 05:06:13 +00:00
|
|
|
|
|
|
|
|
$this->checkLinkTable( 'pagelinks', 'pl', $ns, $name, $options );
|
|
|
|
|
$this->checkLinkTable( 'templatelinks', 'tl', $ns, $name, $options );
|
|
|
|
|
|
|
|
|
|
// The redirect table has interwiki links randomly mixed in, we
|
|
|
|
|
// need to filter those out. For example [[w:Foo:Bar]] would
|
|
|
|
|
// have rd_interwiki=w and rd_namespace=0, which would match the
|
|
|
|
|
// query for a conflicting namespace "Foo" if filtering wasn't done.
|
|
|
|
|
$this->checkLinkTable( 'redirect', 'rd', $ns, $name, $options,
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'rd_interwiki' => null ] );
|
2015-02-13 05:06:13 +00:00
|
|
|
$this->checkLinkTable( 'redirect', 'rd', $ns, $name, $options,
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'rd_interwiki' => '' ] );
|
2015-02-13 05:06:13 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->output( "{$this->totalLinks} links to fix, " .
|
|
|
|
|
"{$this->resolvableLinks} were resolvable.\n" );
|
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
2015-02-05 05:08:14 +00:00
|
|
|
|
2005-06-08 13:08:34 +00:00
|
|
|
return $ok;
|
|
|
|
|
}
|
2009-08-02 19:35:17 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the interwiki list
|
2010-06-12 21:00:32 +00:00
|
|
|
*
|
2014-04-17 20:48:32 +00:00
|
|
|
* @return array
|
2009-08-02 19:35:17 +00:00
|
|
|
*/
|
2007-06-26 21:18:27 +00:00
|
|
|
private function getInterwikiList() {
|
2017-01-10 09:51:50 +00:00
|
|
|
$result = MediaWikiServices::getInstance()->getInterwikiLookup()->getAllPrefixes();
|
2016-02-17 09:09:32 +00:00
|
|
|
$prefixes = [];
|
2010-05-22 16:50:39 +00:00
|
|
|
foreach ( $result as $row ) {
|
2012-11-22 17:14:10 +00:00
|
|
|
$prefixes[] = $row['iw_prefix'];
|
2007-06-26 21:18:27 +00:00
|
|
|
}
|
2014-04-23 18:09:13 +00:00
|
|
|
|
2007-06-26 21:18:27 +00:00
|
|
|
return $prefixes;
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
/**
|
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
2015-02-05 05:08:14 +00:00
|
|
|
* Check a given prefix and try to move it into the given destination namespace
|
|
|
|
|
*
|
|
|
|
|
* @param int $ns Destination namespace id
|
2014-04-17 20:48:32 +00:00
|
|
|
* @param string $name
|
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
2015-02-05 05:08:14 +00:00
|
|
|
* @param array $options Associative array of validated command-line options
|
2011-10-18 17:32:20 +00:00
|
|
|
* @return bool
|
2009-08-02 19:35:17 +00:00
|
|
|
*/
|
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
2015-02-05 05:08:14 +00:00
|
|
|
private function checkNamespace( $ns, $name, $options ) {
|
|
|
|
|
$targets = $this->getTargetList( $ns, $name, $options );
|
|
|
|
|
$count = $targets->numRows();
|
|
|
|
|
$this->totalPages += $count;
|
2010-05-22 16:50:39 +00:00
|
|
|
if ( $count == 0 ) {
|
2005-06-08 13:08:34 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
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
2015-02-05 05:08:14 +00:00
|
|
|
$dryRunNote = $options['fix'] ? '' : ' DRY RUN ONLY';
|
2015-01-24 00:43:26 +00:00
|
|
|
|
2005-06-08 13:08:34 +00:00
|
|
|
$ok = true;
|
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
2015-02-05 05:08:14 +00:00
|
|
|
foreach ( $targets as $row ) {
|
|
|
|
|
// Find the new title and determine the action to take
|
|
|
|
|
|
2015-02-13 05:06:13 +00:00
|
|
|
$newTitle = $this->getDestinationTitle( $ns, $name,
|
|
|
|
|
$row->page_namespace, $row->page_title, $options );
|
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
2015-02-05 05:08:14 +00:00
|
|
|
$logStatus = false;
|
|
|
|
|
if ( !$newTitle ) {
|
|
|
|
|
$logStatus = 'invalid title';
|
|
|
|
|
$action = 'abort';
|
|
|
|
|
} elseif ( $newTitle->exists() ) {
|
|
|
|
|
if ( $options['merge'] ) {
|
|
|
|
|
if ( $this->canMerge( $row->page_id, $newTitle, $logStatus ) ) {
|
|
|
|
|
$action = 'merge';
|
|
|
|
|
} else {
|
|
|
|
|
$action = 'abort';
|
|
|
|
|
}
|
|
|
|
|
} elseif ( $options['add-prefix'] == '' && $options['add-suffix'] == '' ) {
|
|
|
|
|
$action = 'abort';
|
|
|
|
|
$logStatus = 'dest title exists and --add-prefix not specified';
|
|
|
|
|
} else {
|
|
|
|
|
$newTitle = $this->getAlternateTitle( $newTitle, $options );
|
|
|
|
|
if ( !$newTitle ) {
|
|
|
|
|
$action = 'abort';
|
|
|
|
|
$logStatus = 'alternate title is invalid';
|
|
|
|
|
} elseif ( $newTitle->exists() ) {
|
|
|
|
|
$action = 'abort';
|
|
|
|
|
$logStatus = 'title conflict';
|
|
|
|
|
} else {
|
|
|
|
|
$action = 'move';
|
|
|
|
|
$logStatus = 'alternate';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$action = 'move';
|
|
|
|
|
$logStatus = 'no conflict';
|
|
|
|
|
}
|
2015-01-24 00:43:26 +00:00
|
|
|
|
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
2015-02-05 05:08:14 +00:00
|
|
|
// Take the action or log a dry run message
|
|
|
|
|
|
|
|
|
|
$logTitle = "id={$row->page_id} ns={$row->page_namespace} dbk={$row->page_title}";
|
|
|
|
|
$pageOK = true;
|
|
|
|
|
|
|
|
|
|
switch ( $action ) {
|
|
|
|
|
case 'abort':
|
|
|
|
|
$this->output( "$logTitle *** $logStatus\n" );
|
|
|
|
|
$pageOK = false;
|
|
|
|
|
break;
|
|
|
|
|
case 'move':
|
|
|
|
|
$this->output( "$logTitle -> " .
|
|
|
|
|
$newTitle->getPrefixedDBkey() . " ($logStatus)$dryRunNote\n" );
|
|
|
|
|
|
|
|
|
|
if ( $options['fix'] ) {
|
|
|
|
|
$pageOK = $this->movePage( $row->page_id, $newTitle );
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'merge':
|
|
|
|
|
$this->output( "$logTitle => " .
|
|
|
|
|
$newTitle->getPrefixedDBkey() . " (merge)$dryRunNote\n" );
|
|
|
|
|
|
|
|
|
|
if ( $options['fix'] ) {
|
2015-02-13 05:06:13 +00:00
|
|
|
$pageOK = $this->mergePage( $row, $newTitle );
|
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
2015-02-05 05:08:14 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2015-01-24 00:43:26 +00:00
|
|
|
}
|
|
|
|
|
|
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
2015-02-05 05:08:14 +00:00
|
|
|
if ( $pageOK ) {
|
2015-02-13 05:06:13 +00:00
|
|
|
$this->resolvablePages++;
|
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
2015-02-05 05:08:14 +00:00
|
|
|
} else {
|
|
|
|
|
$ok = false;
|
2005-06-08 13:08:34 +00:00
|
|
|
}
|
|
|
|
|
}
|
2014-04-23 18:09:13 +00:00
|
|
|
|
2005-06-08 13:08:34 +00:00
|
|
|
return $ok;
|
|
|
|
|
}
|
2010-12-04 03:20:14 +00:00
|
|
|
|
2015-02-13 05:06:13 +00:00
|
|
|
/**
|
|
|
|
|
* Check and repair the destination fields in a link table
|
|
|
|
|
* @param string $table The link table name
|
|
|
|
|
* @param string $fieldPrefix The field prefix in the link table
|
|
|
|
|
* @param int $ns Destination namespace id
|
|
|
|
|
* @param string $name
|
|
|
|
|
* @param array $options Associative array of validated command-line options
|
|
|
|
|
* @param array $extraConds Extra conditions for the SQL query
|
|
|
|
|
*/
|
|
|
|
|
private function checkLinkTable( $table, $fieldPrefix, $ns, $name, $options,
|
2016-02-17 09:09:32 +00:00
|
|
|
$extraConds = []
|
2015-02-13 05:06:13 +00:00
|
|
|
) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$batchConds = [];
|
2015-02-13 05:06:13 +00:00
|
|
|
$fromField = "{$fieldPrefix}_from";
|
|
|
|
|
$namespaceField = "{$fieldPrefix}_namespace";
|
|
|
|
|
$titleField = "{$fieldPrefix}_title";
|
|
|
|
|
$batchSize = 500;
|
|
|
|
|
while ( true ) {
|
|
|
|
|
$res = $this->db->select(
|
|
|
|
|
$table,
|
2016-02-17 09:09:32 +00:00
|
|
|
[ $fromField, $namespaceField, $titleField ],
|
|
|
|
|
array_merge( $batchConds, $extraConds, [
|
2015-02-13 05:06:13 +00:00
|
|
|
$namespaceField => 0,
|
|
|
|
|
$titleField . $this->db->buildLike( "$name:", $this->db->anyString() )
|
2016-02-17 09:09:32 +00:00
|
|
|
] ),
|
2015-02-13 05:06:13 +00:00
|
|
|
__METHOD__,
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
'ORDER BY' => [ $titleField, $fromField ],
|
2015-02-13 05:06:13 +00:00
|
|
|
'LIMIT' => $batchSize
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
2015-02-13 05:06:13 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if ( $res->numRows() == 0 ) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
foreach ( $res as $row ) {
|
|
|
|
|
$logTitle = "from={$row->$fromField} ns={$row->$namespaceField} " .
|
|
|
|
|
"dbk={$row->$titleField}";
|
|
|
|
|
$destTitle = $this->getDestinationTitle( $ns, $name,
|
|
|
|
|
$row->$namespaceField, $row->$titleField, $options );
|
|
|
|
|
$this->totalLinks++;
|
|
|
|
|
if ( !$destTitle ) {
|
|
|
|
|
$this->output( "$table $logTitle *** INVALID\n" );
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$this->resolvableLinks++;
|
|
|
|
|
if ( !$options['fix'] ) {
|
|
|
|
|
$this->output( "$table $logTitle -> " .
|
|
|
|
|
$destTitle->getPrefixedDBkey() . " DRY RUN\n" );
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->db->update( $table,
|
|
|
|
|
// SET
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2015-02-13 05:06:13 +00:00
|
|
|
$namespaceField => $destTitle->getNamespace(),
|
|
|
|
|
$titleField => $destTitle->getDBkey()
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2015-02-13 05:06:13 +00:00
|
|
|
// WHERE
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2015-02-13 05:06:13 +00:00
|
|
|
$namespaceField => 0,
|
|
|
|
|
$titleField => $row->$titleField,
|
|
|
|
|
$fromField => $row->$fromField
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2015-11-19 00:24:17 +00:00
|
|
|
__METHOD__,
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'IGNORE' ]
|
2015-02-13 05:06:13 +00:00
|
|
|
);
|
|
|
|
|
$this->output( "$table $logTitle -> " .
|
|
|
|
|
$destTitle->getPrefixedDBkey() . "\n" );
|
|
|
|
|
}
|
|
|
|
|
$encLastTitle = $this->db->addQuotes( $row->$titleField );
|
|
|
|
|
$encLastFrom = $this->db->addQuotes( $row->$fromField );
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$batchConds = [
|
2015-02-13 05:06:13 +00:00
|
|
|
"$titleField > $encLastTitle " .
|
2016-02-17 09:09:32 +00:00
|
|
|
"OR ($titleField = $encLastTitle AND $fromField > $encLastFrom)" ];
|
2015-02-13 05:06:13 +00:00
|
|
|
|
|
|
|
|
wfWaitForSlaves();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-17 12:51:41 +00:00
|
|
|
/**
|
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
2015-02-05 05:08:14 +00:00
|
|
|
* Move the given pseudo-namespace, either replacing the colon with a hyphen
|
|
|
|
|
* (useful for pseudo-namespaces that conflict with interwiki links) or move
|
|
|
|
|
* them to another namespace if specified.
|
|
|
|
|
* @param array $options Associative array of validated command-line options
|
2011-10-18 17:32:20 +00:00
|
|
|
* @return bool
|
2006-06-17 12:51:41 +00:00
|
|
|
*/
|
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
2015-02-05 05:08:14 +00:00
|
|
|
private function checkPrefix( $options ) {
|
|
|
|
|
$prefix = $options['source-pseudo-namespace'];
|
|
|
|
|
$ns = $options['dest-namespace'];
|
|
|
|
|
$this->output( "Checking prefix \"$prefix\" vs namespace $ns\n" );
|
2014-04-23 18:09:13 +00:00
|
|
|
|
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
2015-02-05 05:08:14 +00:00
|
|
|
return $this->checkNamespace( $ns, $prefix, $options );
|
2006-06-17 12:51:41 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
/**
|
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
2015-02-05 05:08:14 +00:00
|
|
|
* Find pages in main and talk namespaces that have a prefix of the new
|
|
|
|
|
* namespace so we know titles that will need migrating
|
2010-06-12 21:00:32 +00:00
|
|
|
*
|
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
2015-02-05 05:08:14 +00:00
|
|
|
* @param int $ns Destination namespace id
|
2014-04-17 20:48:32 +00:00
|
|
|
* @param string $name Prefix that is being made a namespace
|
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
2015-02-05 05:08:14 +00:00
|
|
|
* @param array $options Associative array of validated command-line options
|
2011-09-07 21:14:55 +00:00
|
|
|
*
|
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
2015-02-05 05:08:14 +00:00
|
|
|
* @return ResultWrapper
|
2009-08-02 19:35:17 +00:00
|
|
|
*/
|
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
2015-02-05 05:08:14 +00:00
|
|
|
private function getTargetList( $ns, $name, $options ) {
|
|
|
|
|
if ( $options['move-talk'] && MWNamespace::isSubject( $ns ) ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$checkNamespaces = [ NS_MAIN, NS_TALK ];
|
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
2015-02-05 05:08:14 +00:00
|
|
|
} else {
|
|
|
|
|
$checkNamespaces = NS_MAIN;
|
2005-06-08 13:08:34 +00:00
|
|
|
}
|
2014-04-23 18:09:13 +00:00
|
|
|
|
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
2015-02-05 05:08:14 +00:00
|
|
|
return $this->db->select( 'page',
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
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
2015-02-05 05:08:14 +00:00
|
|
|
'page_id',
|
|
|
|
|
'page_title',
|
|
|
|
|
'page_namespace',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
[
|
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
2015-02-05 05:08:14 +00:00
|
|
|
'page_namespace' => $checkNamespaces,
|
2014-06-02 04:47:10 +00:00
|
|
|
'page_title' . $this->db->buildLike( "$name:", $this->db->anyString() ),
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2014-06-02 04:47:10 +00:00
|
|
|
__METHOD__
|
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
2015-02-05 05:08:14 +00:00
|
|
|
);
|
2005-06-08 13:08:34 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
/**
|
2015-02-13 05:06:13 +00:00
|
|
|
* Get the preferred destination title for a given target page.
|
2017-08-20 11:20:59 +00:00
|
|
|
* @param int $ns The destination namespace ID
|
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
2015-02-05 05:08:14 +00:00
|
|
|
* @param string $name The conflicting prefix
|
2017-08-20 11:20:59 +00:00
|
|
|
* @param int $sourceNs The source namespace
|
|
|
|
|
* @param int $sourceDbk The source DB key (i.e. page_title)
|
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
2015-02-05 05:08:14 +00:00
|
|
|
* @param array $options Associative array of validated command-line options
|
|
|
|
|
* @return Title|false
|
2009-08-02 19:35:17 +00:00
|
|
|
*/
|
2015-02-13 05:06:13 +00:00
|
|
|
private function getDestinationTitle( $ns, $name, $sourceNs, $sourceDbk, $options ) {
|
|
|
|
|
$dbk = substr( $sourceDbk, strlen( "$name:" ) );
|
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
2015-02-05 05:08:14 +00:00
|
|
|
if ( $ns == 0 ) {
|
|
|
|
|
// An interwiki; try an alternate encoding with '-' for ':'
|
|
|
|
|
$dbk = "$name-" . $dbk;
|
2007-11-26 20:26:00 +00:00
|
|
|
}
|
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
2015-02-05 05:08:14 +00:00
|
|
|
$destNS = $ns;
|
2015-02-13 05:06:13 +00:00
|
|
|
if ( $sourceNs == NS_TALK && MWNamespace::isSubject( $ns ) ) {
|
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
2015-02-05 05:08:14 +00:00
|
|
|
// This is an associated talk page moved with the --move-talk feature.
|
|
|
|
|
$destNS = MWNamespace::getTalk( $destNS );
|
|
|
|
|
}
|
|
|
|
|
$newTitle = Title::makeTitleSafe( $destNS, $dbk );
|
|
|
|
|
if ( !$newTitle || !$newTitle->canExist() ) {
|
2005-06-08 13:08:34 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
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
2015-02-05 05:08:14 +00:00
|
|
|
return $newTitle;
|
2005-06-08 13:08:34 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
/**
|
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
2015-02-05 05:08:14 +00:00
|
|
|
* Get an alternative title to move a page to. This is used if the
|
|
|
|
|
* preferred destination title already exists.
|
2010-06-12 21:00:32 +00:00
|
|
|
*
|
2016-02-03 15:53:07 +00:00
|
|
|
* @param LinkTarget $linkTarget
|
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
2015-02-05 05:08:14 +00:00
|
|
|
* @param array $options Associative array of validated command-line options
|
|
|
|
|
* @return Title|bool
|
2009-08-02 19:35:17 +00:00
|
|
|
*/
|
2016-02-03 15:53:07 +00:00
|
|
|
private function getAlternateTitle( LinkTarget $linkTarget, $options ) {
|
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
2015-02-05 05:08:14 +00:00
|
|
|
$prefix = $options['add-prefix'];
|
|
|
|
|
$suffix = $options['add-suffix'];
|
|
|
|
|
if ( $prefix == '' && $suffix == '' ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
while ( true ) {
|
2016-02-03 15:53:07 +00:00
|
|
|
$dbk = $prefix . $linkTarget->getDBkey() . $suffix;
|
|
|
|
|
$title = Title::makeTitleSafe( $linkTarget->getNamespace(), $dbk );
|
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
2015-02-05 05:08:14 +00:00
|
|
|
if ( !$title ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if ( !$title->exists() ) {
|
|
|
|
|
return $title;
|
2008-01-29 01:28:27 +00:00
|
|
|
}
|
2005-06-08 16:36:08 +00:00
|
|
|
}
|
2005-06-08 13:08:34 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
/**
|
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
2015-02-05 05:08:14 +00:00
|
|
|
* Move a page
|
2010-06-12 21:00:32 +00:00
|
|
|
*
|
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
2015-02-05 05:08:14 +00:00
|
|
|
* @param integer $id The page_id
|
2016-02-03 15:53:07 +00:00
|
|
|
* @param LinkTarget $newLinkTarget The new title link target
|
2011-10-18 17:32:20 +00:00
|
|
|
* @return bool
|
2009-08-02 19:35:17 +00:00
|
|
|
*/
|
2016-02-03 15:53:07 +00:00
|
|
|
private function movePage( $id, LinkTarget $newLinkTarget ) {
|
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
2015-02-05 05:08:14 +00:00
|
|
|
$this->db->update( 'page',
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2016-02-03 15:53:07 +00:00
|
|
|
"page_namespace" => $newLinkTarget->getNamespace(),
|
|
|
|
|
"page_title" => $newLinkTarget->getDBkey(),
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
[
|
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
2015-02-05 05:08:14 +00:00
|
|
|
"page_id" => $id,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2007-11-26 17:58:08 +00:00
|
|
|
__METHOD__ );
|
2014-04-23 18:09:13 +00:00
|
|
|
|
2015-02-13 05:06:13 +00:00
|
|
|
// Update *_from_namespace in links tables
|
2016-02-17 09:09:32 +00:00
|
|
|
$fromNamespaceTables = [
|
|
|
|
|
[ 'pagelinks', 'pl' ],
|
|
|
|
|
[ 'templatelinks', 'tl' ],
|
|
|
|
|
[ 'imagelinks', 'il' ] ];
|
2015-02-13 05:06:13 +00:00
|
|
|
foreach ( $fromNamespaceTables as $tableInfo ) {
|
|
|
|
|
list( $table, $fieldPrefix ) = $tableInfo;
|
|
|
|
|
$this->db->update( $table,
|
|
|
|
|
// SET
|
2016-02-17 09:09:32 +00:00
|
|
|
[ "{$fieldPrefix}_from_namespace" => $newLinkTarget->getNamespace() ],
|
2015-02-13 05:06:13 +00:00
|
|
|
// WHERE
|
2016-02-17 09:09:32 +00:00
|
|
|
[ "{$fieldPrefix}_from" => $id ],
|
2015-02-13 05:06:13 +00:00
|
|
|
__METHOD__ );
|
|
|
|
|
}
|
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
2015-02-05 05:08:14 +00:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if we can merge a page.
|
|
|
|
|
* We check if an inaccessible revision would become the latest and
|
|
|
|
|
* deny the merge if so -- it's theoretically possible to update the
|
|
|
|
|
* latest revision, but opens a can of worms -- search engine updates,
|
|
|
|
|
* recentchanges review, etc.
|
|
|
|
|
*
|
|
|
|
|
* @param integer $id The page_id
|
2016-02-03 15:53:07 +00:00
|
|
|
* @param LinkTarget $linkTarget The new link target
|
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
2015-02-05 05:08:14 +00:00
|
|
|
* @param string $logStatus This is set to the log status message on failure
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2016-02-03 15:53:07 +00:00
|
|
|
private function canMerge( $id, LinkTarget $linkTarget, &$logStatus ) {
|
|
|
|
|
$latestDest = Revision::newFromTitle( $linkTarget, 0, Revision::READ_LATEST );
|
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
2015-02-05 05:08:14 +00:00
|
|
|
$latestSource = Revision::newFromPageId( $id, 0, Revision::READ_LATEST );
|
|
|
|
|
if ( $latestSource->getTimestamp() > $latestDest->getTimestamp() ) {
|
|
|
|
|
$logStatus = 'cannot merge since source is later';
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Merge page histories
|
|
|
|
|
*
|
2017-02-19 05:03:13 +00:00
|
|
|
* @param stdClass $row Page row
|
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
2015-02-05 05:08:14 +00:00
|
|
|
* @param Title $newTitle The new title
|
2015-12-31 00:10:31 +00:00
|
|
|
* @return bool
|
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
2015-02-05 05:08:14 +00:00
|
|
|
*/
|
2015-02-13 05:06:13 +00:00
|
|
|
private function mergePage( $row, Title $newTitle ) {
|
|
|
|
|
$id = $row->page_id;
|
|
|
|
|
|
|
|
|
|
// Construct the WikiPage object we will need later, while the
|
|
|
|
|
// page_id still exists. Note that this cannot use makeTitleSafe(),
|
|
|
|
|
// we are deliberately constructing an invalid title.
|
|
|
|
|
$sourceTitle = Title::makeTitle( $row->page_namespace, $row->page_title );
|
|
|
|
|
$sourceTitle->resetArticleID( $id );
|
|
|
|
|
$wikiPage = new WikiPage( $sourceTitle );
|
|
|
|
|
$wikiPage->loadPageData( 'fromdbmaster' );
|
|
|
|
|
|
2016-03-19 00:08:06 +00:00
|
|
|
$destId = $newTitle->getArticleID();
|
2015-12-31 00:10:31 +00:00
|
|
|
$this->beginTransaction( $this->db, __METHOD__ );
|
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
2015-02-05 05:08:14 +00:00
|
|
|
$this->db->update( 'revision',
|
|
|
|
|
// SET
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'rev_page' => $destId ],
|
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
2015-02-05 05:08:14 +00:00
|
|
|
// WHERE
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'rev_page' => $id ],
|
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
2015-02-05 05:08:14 +00:00
|
|
|
__METHOD__ );
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->db->delete( 'page', [ 'page_id' => $id ], __METHOD__ );
|
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
2015-02-05 05:08:14 +00:00
|
|
|
|
2016-08-22 23:15:24 +00:00
|
|
|
$this->commitTransaction( $this->db, __METHOD__ );
|
|
|
|
|
|
2015-10-14 07:40:50 +00:00
|
|
|
/* Call LinksDeletionUpdate to delete outgoing links from the old title,
|
|
|
|
|
* and update category counts.
|
|
|
|
|
*
|
|
|
|
|
* Calling external code with a fake broken Title is a fairly dubious
|
|
|
|
|
* idea. It's necessary because it's quite a lot of code to duplicate,
|
|
|
|
|
* but that also makes it fragile since it would be easy for someone to
|
|
|
|
|
* accidentally introduce an assumption of title validity to the code we
|
|
|
|
|
* are calling.
|
|
|
|
|
*/
|
2016-09-02 04:30:34 +00:00
|
|
|
DeferredUpdates::addUpdate( new LinksDeletionUpdate( $wikiPage ) );
|
|
|
|
|
DeferredUpdates::doUpdates();
|
2015-02-13 05:06:13 +00:00
|
|
|
|
2005-06-08 13:08:34 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-24 01:34:01 +00:00
|
|
|
$maintClass = NamespaceDupes::class;
|
2013-05-07 23:00:15 +00:00
|
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|