require_once( dirname( __FILE__ ) . '/Maintenance.php' );
class NamespaceConflictChecker extends Maintenance {
+
+ /**
+ * @var DatabaseBase
+ */
+ protected $db;
+
public function __construct() {
parent::__construct();
$this->mDescription = "";
$this->addOption( 'fix', 'Attempt to automatically fix errors' );
- $this->addOption( 'suffix', "Dupes will be renamed with correct namespace with\n" .
- "\t\t<text> Appended after the article name", false, true );
- $this->addOption( 'prefix', "Do an explicit check for the given title prefix\n" .
- "\t\tappended after the article name", false, true );
+ $this->addOption( 'suffix', "Dupes will be renamed with correct namespace with " .
+ "<text> appended after the article name", false, true );
+ $this->addOption( 'prefix', "Do an explicit check for the given title prefix " .
+ "appended after the article name", false, true );
}
public function execute() {
* @todo Document
* @param $fix Boolean: whether or not to fix broken entries
* @param $suffix String: suffix to append to renamed articles
+ *
+ * @return bool
*/
private function checkAll( $fix, $suffix = '' ) {
- global $wgContLang, $wgNamespaceAliases, $wgCanonicalNamespaceNames;
- global $wgCapitalLinks;
+ global $wgContLang, $wgNamespaceAliases, $wgCapitalLinks;
$spaces = array();
}
// Now pull in all canonical and alias namespaces...
- foreach ( $wgCanonicalNamespaceNames as $ns => $name ) {
+ foreach ( MWNamespace::getCanonicalNamespaces() as $ns => $name ) {
// This includes $wgExtraNamespaces
if ( $name !== '' ) {
$spaces[$name] = $ns;
* @param $name String
* @param $fix Boolean: whether to fix broken entries
* @param $suffix String: suffix to append to renamed articles
+ * @return bool
*/
private function checkNamespace( $ns, $name, $fix, $suffix = '' ) {
$conflicts = $this->getConflicts( $ns, $name );
/**
* @todo: do this for reals
+ * @param $key
+ * @param $prefix
+ * @param $fix
+ * @param $suffix string
+ * @return bool
*/
private function checkPrefix( $key, $prefix, $fix, $suffix = '' ) {
$this->output( "Checking prefix \"$prefix\" vs namespace $key\n" );
*
* @param $ns Integer: namespace id (id for new namespace?)
* @param $name String: prefix that is being made a namespace
+ *
+ * @return array
*/
private function getConflicts( $ns, $name ) {
$page = 'page';
/**
* Report any conflicts we find
+ *
+ * @return bool
*/
private function reportConflict( $row, $suffix ) {
$newTitle = Title::makeTitleSafe( $row->namespace, $row->title );
* @param $row Object: row from the page table to fix
* @param $resolvable Boolean
* @param $suffix String: suffix to append to the fixed page
+ * @return bool
*/
private function resolveConflict( $row, $resolvable, $suffix ) {
if ( !$resolvable ) {
* @param $row Object: row from the old broken entry
* @param $table String: table to update
* @param $prefix String: prefix for column name, like page or ar
+ * @return bool
*/
private function resolveConflictOn( $row, $table, $prefix ) {
$this->output( "... resolving on $table... " );