r107941 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107940‎ | r107941 | r107942 >
Date:21:20, 3 January 2012
Author:brion
Status:ok
Tags:
Comment:
Revert r107773 - increases parsercache fragmentation without clear benefit
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/includes/parser/LinkHolderArray.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -211,8 +211,6 @@
212212 {{NAMESPACE}} relative to correct title.
213213 * (bug 30485 and bug 33434) Style rules for wikitable are now more specific and
214214 prevent inheritance to nested tables which caused various issues
215 -* (bug 32686) Tooltip on links to non-existing pages are now always in user's
216 - language
217215 * (bug 33454) ISO-8601 week-based year number (format character 'o') is now
218216 calculated correctly with respect to timezone
219217 * (bug 32219) InstantCommons now fetches content from Wikimedia Commons using
Index: trunk/phase3/includes/parser/LinkHolderArray.php
@@ -363,8 +363,7 @@
364364 if ( $colours[$pdbk] == 'new' ) {
365365 $linkCache->addBadLinkObj( $title );
366366 $output->addLink( $title, 0 );
367 - $type = array( 'broken',
368 - 'language' => $this->parent->getOptions()->getUserLangObj() );
 367+ $type = array( 'broken' );
369368 } else {
370369 if ( $colours[$pdbk] != '' ) {
371370 $attribs['class'] = $colours[$pdbk];
Index: trunk/phase3/includes/Linker.php
@@ -154,20 +154,15 @@
155155 * @param $query array The query string to append to the URL
156156 * you're linking to, in key => value array form. Query keys and values
157157 * will be URL-encoded.
158 - * @param $options string|array String or array:
159 - * - Either with numerical index and following values:
160 - * - 'known': Page is known to exist, so don't check if it does.
161 - * - 'broken': Page is known not to exist, so don't check if it does.
162 - * - 'noclasses': Don't add any classes automatically (includes "new",
 158+ * @param $options string|array String or array of strings:
 159+ * 'known': Page is known to exist, so don't check if it does.
 160+ * 'broken': Page is known not to exist, so don't check if it does.
 161+ * 'noclasses': Don't add any classes automatically (includes "new",
163162 * "stub", "mw-redirect", "extiw"). Only use the class attribute
164163 * provided, if any, so you get a simple blue link with no funny i-
165164 * cons.
166 - * - 'forcearticlepath': Use the article path always, even with a querystring.
 165+ * 'forcearticlepath': Use the article path always, even with a querystring.
167166 * Has compatibility issues on some setups, so avoid wherever possible.
168 - * - Or with following indexes:
169 - * - 'language': the value of that index is the language to use; currently
170 - * only used for the tooltip when linking to a page that doesn't exist
171 - * (since 1.19)
172167 * @return string HTML <a> attribute
173168 */
174169 public static function link(
@@ -194,7 +189,7 @@
195190
196191 # If we don't know whether the page exists, let's find out.
197192 wfProfileIn( __METHOD__ . '-checkPageExistence' );
198 - if ( !in_array( 'known', $options, true ) && !in_array( 'broken', $options, true ) ) {
 193+ if ( !in_array( 'known', $options ) and !in_array( 'broken', $options ) ) {
199194 if ( $target->isKnown() ) {
200195 $options[] = 'known';
201196 } else {
@@ -204,14 +199,14 @@
205200 wfProfileOut( __METHOD__ . '-checkPageExistence' );
206201
207202 $oldquery = array();
208 - if ( in_array( 'forcearticlepath', $options, true ) && $query ) {
 203+ if ( in_array( "forcearticlepath", $options ) && $query ) {
209204 $oldquery = $query;
210205 $query = array();
211206 }
212207
213208 # Note: we want the href attribute first, for prettiness.
214209 $attribs = array( 'href' => self::linkUrl( $target, $query, $options ) );
215 - if ( in_array( 'forcearticlepath', $options, true ) && $oldquery ) {
 210+ if ( in_array( 'forcearticlepath', $options ) && $oldquery ) {
216211 $attribs['href'] = wfAppendQuery( $attribs['href'], wfArrayToCgi( $oldquery ) );
217212 }
218213
@@ -251,7 +246,7 @@
252247 wfProfileIn( __METHOD__ );
253248 # We don't want to include fragments for broken links, because they
254249 # generally make no sense.
255 - if ( in_array( 'broken', $options, true ) && $target->mFragment !== '' ) {
 250+ if ( in_array( 'broken', $options ) && $target->mFragment !== '' ) {
256251 $target = clone $target;
257252 $target->mFragment = '';
258253 }
@@ -259,7 +254,7 @@
260255 # If it's a broken link, add the appropriate query pieces, unless
261256 # there's already an action specified, or unless 'edit' makes no sense
262257 # (i.e., for a nonexistent special page).
263 - if ( in_array( 'broken', $options, true ) && empty( $query['action'] )
 258+ if ( in_array( 'broken', $options ) && empty( $query['action'] )
264259 && !$target->isSpecialPage() ) {
265260 $query['action'] = 'edit';
266261 $query['redlink'] = '1';
@@ -279,22 +274,24 @@
280275 * @return array
281276 */
282277 private static function linkAttribs( $target, $attribs, $options ) {
283 - global $wgUser;
284 -
285278 wfProfileIn( __METHOD__ );
286 -
 279+ global $wgUser;
287280 $defaults = array();
288281
289 - if ( !in_array( 'noclasses', $options, true ) ) {
 282+ if ( !in_array( 'noclasses', $options ) ) {
290283 wfProfileIn( __METHOD__ . '-getClasses' );
291284 # Now build the classes.
292285 $classes = array();
293286
 287+ if ( in_array( 'broken', $options ) ) {
 288+ $classes[] = 'new';
 289+ }
 290+
294291 if ( $target->isExternal() ) {
295292 $classes[] = 'extiw';
296 - } elseif ( in_array( 'broken', $options, true ) ) {
297 - $classes[] = 'new';
298 - } else { # Avoid useless calls to LinkCache (see r50387)
 293+ }
 294+
 295+ if ( !in_array( 'broken', $options ) ) { # Avoid useless calls to LinkCache (see r50387)
299296 $colour = self::getLinkColour( $target, $wgUser->getStubThreshold() );
300297 if ( $colour !== '' ) {
301298 $classes[] = $colour; # mw-redirect or stub
@@ -310,14 +307,10 @@
311308 if ( $target->getPrefixedText() == '' ) {
312309 # A link like [[#Foo]]. This used to mean an empty title
313310 # attribute, but that's silly. Just don't output a title.
314 - } elseif ( in_array( 'known', $options, true ) ) {
 311+ } elseif ( in_array( 'known', $options ) ) {
315312 $defaults['title'] = $target->getPrefixedText();
316313 } else {
317 - $msg = wfMessage( 'red-link-title', $target->getPrefixedText() );
318 - if ( isset( $options['language'] ) ) {
319 - $msg->inLanguage( $options['language'] );
320 - }
321 - $defaults['title'] = $msg->text();
 314+ $defaults['title'] = wfMsg( 'red-link-title', $target->getPrefixedText() );
322315 }
323316
324317 # Finally, merge the custom attribs with the default ones, and iterate

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r107773* (bug 32686) Tooltip on links to non-existing pages are now always in user's...ialex14:01, 1 January 2012

Status & tagging log