r41507 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41506‎ | r41507 | r41508 >
Date:16:59, 1 October 2008
Author:brion
Status:old
Tags:
Comment:
Reverting r41410 -- broke interwikis totally in parser tests.

4 previously passing test(s) now FAILING! :(
* Inline interwiki link [Introduced between 30-Sep-2008 00:18:19, 1.14alpha (r41405) and 01-Oct-2008 16:31:38, 1.14alpha (r41504)]
* Inline interwiki link with empty title (bug 2372) [Introduced between 30-Sep-2008 00:18:19, 1.14alpha (r41405) and 01-Oct-2008 16:31:38, 1.14alpha (r41504)]
* Interwiki link encoding conversion (bug 1636) [Introduced between 30-Sep-2008 00:18:19, 1.14alpha (r41405) and 01-Oct-2008 16:31:38, 1.14alpha (r41504)]
* Interwiki link with fragment (bug 2130) [Introduced between 30-Sep-2008 00:18:19, 1.14alpha (r41405) and 01-Oct-2008 16:31:38, 1.14alpha (r41504)]
Modified paths:
  • /trunk/phase3/includes/Interwiki.php (modified) (history)
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Interwiki.php
@@ -40,9 +40,7 @@
4141 return Interwiki::getInterwikiCached( $key );
4242 }
4343 $iw = new Interwiki;
44 - if(! $iw->load( $prefix ) ){
45 - return false;
46 - }
 44+ $iw->load( $prefix );
4745 if( self::CACHE_LIMIT && count( self::$smCache ) >= self::CACHE_LIMIT ){
4846 array_shift( self::$smCache );
4947 }
@@ -86,8 +84,6 @@
8785 list( $local, $url ) = explode( ' ', $value, 2 );
8886 $s->mURL = $url;
8987 $s->mLocal = (int)$local;
90 - }else{
91 - return false;
9288 }
9389 if( self::CACHE_LIMIT && count( self::$smCache ) >= self::CACHE_LIMIT ){
9490 array_shift( self::$smCache );
@@ -97,6 +93,16 @@
9894 }
9995
10096 /**
 97+ * Clear all member variables in the current object. Does not clear
 98+ * the block from the DB.
 99+ */
 100+ function clear() {
 101+ $this->mURL = '';
 102+ $this->mLocal = $this->mTrans = 0;
 103+ $this->mPrefix = null;
 104+ }
 105+
 106+ /**
101107 * Get the DB object
102108 *
103109 * @return Database
@@ -117,19 +123,25 @@
118124 global $wgMemc;
119125 $key = wfMemcKey( 'interwiki', $prefix );
120126 $mc = $wgMemc->get( $key );
121 - if( $mc && is_array( $mc ) && $this->loadFromArray( $mc ) ){ // is_array is hack for old keys
122 - wfDebug("Succeeded\n");
123 - return true;
 127+ if( $mc && is_array( $mc ) ){ // is_array is hack for old keys
 128+ if( $this->loadFromArray( $mc ) ){
 129+ wfDebug("Succeeded\n");
 130+ return true;
 131+ }
 132+ }else{
 133+ $db =& $this->getDB();
 134+
 135+ $res = $db->resultObject( $db->select( 'interwiki', '*', array( 'iw_prefix' => $prefix ),
 136+ __METHOD__ ) );
 137+ if ( $this->loadFromResult( $res ) ) {
 138+ $mc = array( 'url' => $this->mURL, 'local' => $this->mLocal, 'trans' => $this->mTrans );
 139+ $wgMemc->add( $key, $mc );
 140+ return true;
 141+ }
124142 }
125143
126 - $db =& $this->getDB();
127 - $res = $db->resultObject( $db->select( 'interwiki', '*', array( 'iw_prefix' => $prefix ),
128 - __METHOD__ ) );
129 - if ( $this->loadFromResult( $res ) ) {
130 - $mc = array( 'url' => $this->mURL, 'local' => $this->mLocal, 'trans' => $this->mTrans );
131 - $wgMemc->add( $key, $mc );
132 - return true;
133 - }
 144+ # Give up
 145+ $this->clear();
134146 return false;
135147 }
136148
Index: trunk/phase3/includes/Linker.php
@@ -203,18 +203,9 @@
204204 }
205205 }
206206 wfProfileOut( __METHOD__ . '-checkPageExistence' );
207 -
208 - $oldquery = array();
209 - if( in_array( "forcearticlepath", $options ) && $query ){
210 - $oldquery = $query;
211 - $query = array();
212 - }
213207
214208 # Note: we want the href attribute first, for prettiness.
215209 $attribs = array( 'href' => $this->linkUrl( $target, $query, $options ) );
216 - if( in_array( 'forcearticlepath', $options ) && $oldquery ){
217 - $attribs['href'] = wfAppendQuery( $attribs['href'], wfArrayToCgi( $oldquery ) );
218 - }
219210 $attribs = array_merge(
220211 $attribs,
221212 $this->linkAttribs( $target, $customAttribs, $options )
Index: trunk/phase3/includes/Title.php
@@ -2054,7 +2054,7 @@
20552055 # Ordinary namespace
20562056 $dbkey = $m[2];
20572057 $this->mNamespace = $ns;
2058 - } elseif( Interwiki::fetch( $p ) ) {
 2058+ } elseif( new Interwiki( $p ) ) {
20592059 if( !$firstPass ) {
20602060 # Can't make a local interwiki link to an interwiki link.
20612061 # That's just crazy!

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r8484Test case for bug 1636vibber06:04, 21 April 2005
r8486* (bug 1636) Refs like ţ were misinterpreted as octal in some placesvibber06:20, 21 April 2005
r8487* (bug 1636) Refs like ţ were misinterpreted as octal in some places...vibber06:28, 21 April 2005
r8488* (bug 1636) Refs like ţ were misinterpreted as octal in some placesvibber06:29, 21 April 2005
r9308Add test for bug 2130vibber22:39, 2 June 2005
r9310* (bug 2130) Fixed interwiki links with fragmentsvibber05:46, 3 June 2005
r9390* (bug 2372) Fix rendering of empty-title inline interwiki linksvibber01:54, 11 June 2005
r41405Revert r41352-41355, r41362-41363: unauthorized schema change breaks parser t...brion00:07, 30 September 2008
r41410* Add Linker::link flag for using article path...mattj01:56, 30 September 2008
r41504Add Arabic (ar) and Egyptian Arabic (arz)...mfarag16:29, 1 October 2008

Status & tagging log