Some categories have a namespace at begin, which is not handled correct
when just using Title::newFromText
Change-Id: I7e12b66028a8e8292473e3a58e2b271c7f3a2274
$exList = $this->msg( 'uncategorized-categories-exceptionlist' )
->inContentLanguage()->plain();
$proposedTitles = explode( "\n", $exList );
$exList = $this->msg( 'uncategorized-categories-exceptionlist' )
->inContentLanguage()->plain();
$proposedTitles = explode( "\n", $exList );
- foreach ( $proposedTitles as $count => $title ) {
- if ( strpos( $title, '*' ) !== 0 ) {
+ foreach ( $proposedTitles as $count => $titleStr ) {
+ if ( strpos( $titleStr, '*' ) !== 0 ) {
- $title = preg_replace( "/^\\*\\s*/", '', $title );
- $title = Title::newFromText( $title, NS_CATEGORY );
+ $titleStr = preg_replace( "/^\\*\\s*/", '', $titleStr );
+ $title = Title::newFromText( $titleStr, NS_CATEGORY );
+ if ( $title && $title->getNamespace() !== NS_CATEGORY ) {
+ $title = Title::makeTitleSafe( NS_CATEGORY, $titleStr );
+ }
if ( $title ) {
$this->exceptionList[] = $title->getDBKey();
}
if ( $title ) {
$this->exceptionList[] = $title->getDBKey();
}