+ public function execute() {
+ global $wgTitle;
+
+ $this->db = wfGetDB( DB_MASTER );
+ $wgTitle = Title::newFromText( 'Namespace title conflict cleanup script' );
+
+ $fix = $this->hasOption( 'fix' );
+ $suffix = $this->getOption( 'suffix', '' );
+ $prefix = $this->getOption( 'prefix', '' );
+ $key = intval( $this->getOption( 'key', 0 ) );
+
+ if ( $prefix ) {
+ $retval = $this->checkPrefix( $key, $prefix, $fix, $suffix );
+ } else {
+ $retval = $this->checkAll( $fix, $suffix );
+ }
+
+ if ( $retval ) {
+ $this->output( "\nLooks good!\n" );
+ } else {
+ $this->output( "\nOh noeees\n" );
+ }
+ }
+
+ /**
+ * @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, $wgCapitalLinks;
+
+ $spaces = array();
+
+ // List interwikis first, so they'll be overridden
+ // by any conflicting local namespaces.
+ foreach ( $this->getInterwikiList() as $prefix ) {
+ $name = $wgContLang->ucfirst( $prefix );
+ $spaces[$name] = 0;
+ }
+
+ // Now pull in all canonical and alias namespaces...
+ foreach ( MWNamespace::getCanonicalNamespaces() as $ns => $name ) {
+ // This includes $wgExtraNamespaces
+ if ( $name !== '' ) {
+ $spaces[$name] = $ns;
+ }
+ }
+ foreach ( $wgContLang->getNamespaces() as $ns => $name ) {
+ if ( $name !== '' ) {
+ $spaces[$name] = $ns;
+ }
+ }
+ foreach ( $wgNamespaceAliases as $name => $ns ) {
+ $spaces[$name] = $ns;
+ }
+ foreach ( $wgContLang->getNamespaceAliases() as $name => $ns ) {
+ $spaces[$name] = $ns;
+ }
+
+ // We'll need to check for lowercase keys as well,
+ // since we're doing case-sensitive searches in the db.
+ foreach ( $spaces as $name => $ns ) {
+ $moreNames = array();
+ $moreNames[] = $wgContLang->uc( $name );
+ $moreNames[] = $wgContLang->ucfirst( $wgContLang->lc( $name ) );
+ $moreNames[] = $wgContLang->ucwords( $name );
+ $moreNames[] = $wgContLang->ucwords( $wgContLang->lc( $name ) );
+ $moreNames[] = $wgContLang->ucwordbreaks( $name );
+ $moreNames[] = $wgContLang->ucwordbreaks( $wgContLang->lc( $name ) );
+ if ( !$wgCapitalLinks ) {
+ foreach ( $moreNames as $altName ) {
+ $moreNames[] = $wgContLang->lcfirst( $altName );
+ }
+ $moreNames[] = $wgContLang->lcfirst( $name );
+ }
+ foreach ( array_unique( $moreNames ) as $altName ) {
+ if ( $altName !== $name ) {
+ $spaces[$altName] = $ns;
+ }
+ }
+ }
+
+ ksort( $spaces );
+ asort( $spaces );
+