From: jenkins-bot Date: Thu, 16 Jul 2015 19:52:16 +0000 (+0000) Subject: Merge "Improve serialization of Message, Title" X-Git-Tag: 1.31.0-rc.0~10745 X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_del%27%2C%20idvote=vote.voteid%29%20%7D%7D?a=commitdiff_plain;h=6c5470467e0123978ed5cb3fca3353d9c433440c;hp=-c;p=lhc%2Fweb%2Fwiklou.git Merge "Improve serialization of Message, Title" --- 6c5470467e0123978ed5cb3fca3353d9c433440c diff --combined includes/Title.php index 1ab88a6dd4,902d58f6b5..fac45d0c7a --- a/includes/Title.php +++ b/includes/Title.php @@@ -313,7 -313,7 +313,7 @@@ class Title $filteredText = Sanitizer::decodeCharReferencesAndNormalize( $text ); $t = new Title(); - $t->mDbkeyform = str_replace( ' ', '_', $filteredText ); + $t->mDbkeyform = strtr( $filteredText, ' ', '_' ); $t->mDefaultNamespace = intval( $defaultNamespace ); $t->secureAndSplit(); @@@ -345,10 -345,10 +345,10 @@@ # but some URLs used it as a space replacement and they still come # from some external search tools. if ( strpos( self::legalChars(), '+' ) === false ) { - $url = str_replace( '+', ' ', $url ); + $url = strtr( $url, '+', ' ' ); } - $t->mDbkeyform = str_replace( ' ', '_', $url ); + $t->mDbkeyform = strtr( $url, ' ', '_' ); try { $t->secureAndSplit(); @@@ -509,10 -509,10 +509,10 @@@ $t->mInterwiki = $interwiki; $t->mFragment = $fragment; $t->mNamespace = $ns = intval( $ns ); - $t->mDbkeyform = str_replace( ' ', '_', $title ); + $t->mDbkeyform = strtr( $title, ' ', '_' ); $t->mArticleID = ( $ns >= 0 ) ? -1 : 0; $t->mUrlform = wfUrlencode( $t->mDbkeyform ); - $t->mTextform = str_replace( '_', ' ', $title ); + $t->mTextform = strtr( $title, '_', ' ' ); $t->mContentModel = false; # initialized lazily in getContentModel() return $t; } @@@ -1419,7 -1419,7 +1419,7 @@@ * @param string $fragment Text */ public function setFragment( $fragment ) { - $this->mFragment = str_replace( '_', ' ', substr( $fragment, 1 ) ); + $this->mFragment = strtr( substr( $fragment, 1 ), '_', ' ' ); } /** @@@ -1449,7 -1449,7 +1449,7 @@@ */ public function getPrefixedDBkey() { $s = $this->prefix( $this->mDbkeyform ); - $s = str_replace( ' ', '_', $s ); + $s = strtr( $s, ' ', '_' ); return $s; } @@@ -1462,7 -1462,7 +1462,7 @@@ public function getPrefixedText() { if ( $this->mPrefixedText === null ) { $s = $this->prefix( $this->mTextform ); - $s = str_replace( '_', ' ', $s ); + $s = strtr( $s, '_', ' ' ); $this->mPrefixedText = $s; } return $this->mPrefixedText; @@@ -1610,7 -1610,7 +1610,7 @@@ */ public function getSubpageUrlForm() { $text = $this->getSubpageText(); - $text = wfUrlencode( str_replace( ' ', '_', $text ) ); + $text = wfUrlencode( strtr( $text, ' ', '_' ) ); return $text; } @@@ -1621,7 -1621,7 +1621,7 @@@ */ public function getPrefixedURL() { $s = $this->prefix( $this->mDbkeyform ); - $s = wfUrlencode( str_replace( ' ', '_', $s ) ); + $s = wfUrlencode( strtr( $s, ' ', '_' ) ); return $s; } @@@ -3370,7 -3370,7 +3370,7 @@@ $this->mDbkeyform = $parts['dbkey']; $this->mUrlform = wfUrlencode( $this->mDbkeyform ); - $this->mTextform = str_replace( '_', ' ', $this->mDbkeyform ); + $this->mTextform = strtr( $this->mDbkeyform, '_', ' ' ); # We already know that some pages won't be in the database! if ( $this->isExternal() || $this->mNamespace == NS_SPECIAL ) { @@@ -4738,7 -4738,7 +4738,7 @@@ } } else { // Even if there are no subpages in namespace, we still don't want "/" in MediaWiki message keys - $editnoticeText = $editnotice_ns . '-' . str_replace( '/', '-', $this->getDBkey() ); + $editnoticeText = $editnotice_ns . '-' . strtr( $this->getDBkey(), '/', '-' ); $msg = wfMessage( $editnoticeText ); if ( $msg->exists() ) { $html = $msg->parseAsBlock(); @@@ -4759,4 -4759,26 +4759,26 @@@ Hooks::run( 'TitleGetEditNotices', array( $this, $oldid, &$notices ) ); return $notices; } + + /** + * @return array + */ + public function __sleep() { + return array( + 'mNamespace', + 'mDbkeyform', + 'mFragment', + 'mInterwiki', + 'mLocalInterwiki', + 'mUserCaseDBKey', + 'mDefaultNamespace', + ); + } + + public function __wakeup() { + $this->mArticleID = ( $this->mNamespace >= 0 ) ? -1 : 0; + $this->mUrlform = wfUrlencode( $this->mDbkeyform ); + $this->mTextform = strtr( $this->mDbkeyform, '_', ' ' ); + } + }