Have Title::makeTitle() do the space to underscore replacement so it can be used...
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 24 Nov 2004 10:27:49 +0000 (10:27 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 24 Nov 2004 10:27:49 +0000 (10:27 +0000)
includes/Title.php

index d79aa5c..2d7f17c 100644 (file)
@@ -172,6 +172,9 @@ class Title {
         * Create a new Title from a namespace index and a DB key.
         * It's assumed that $ns and $title are *valid*, for instance when
         * they came directly from the database or a special page name.
+        * For convenience, spaces are converted to underscores so that
+        * eg user_text fields can be used directly.
+        *
         * @param int $ns the namespace of the article
         * @param string $title the unprefixed database key form
         * @return Title the new object
@@ -183,9 +186,9 @@ class Title {
                $t->mInterwiki = '';
                $t->mFragment = '';
                $t->mNamespace = IntVal( $ns );
-               $t->mDbkeyform = $title;
+               $t->mDbkeyform = str_replace( ' ', '_', $title );
                $t->mArticleID = ( $ns >= 0 ) ? -1 : 0;
-               $t->mUrlform = wfUrlencode( $title );
+               $t->mUrlform = wfUrlencode( $t->mDbkeyform );
                $t->mTextform = str_replace( '_', ' ', $title );
                return $t;
        }