r70434 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70433‎ | r70434 | r70435 >
Date:22:32, 3 August 2010
Author:platonides
Status:ok (Comments)
Tags:
Comment:
http://www.mediawiki.org/wiki/User:Catrope/Stub_threshold shows us people setting it to insanely large values trying to disable it.
r70433 addressed the UI. Here we proxy its access via a new method getStubThreshold() that disables it if a page of such size cannot be
created (by an user), so we can serve them parser cached articles again.
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/includes/parser/LinkHolderArray.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -2079,6 +2079,20 @@
20802080 }
20812081
20822082 /**
 2083+ * Get the user preferred stub threshold
 2084+ */
 2085+ function getStubThreshold() {
 2086+ global $wgMaxArticleSize; # Maximum article size, in Kb
 2087+ $threshold = intval( $this->getOption( 'stubthreshold' ) );
 2088+ if ( $threshold > $wgMaxArticleSize * 1024 ) {
 2089+ # If they have set an impossible value, disable the preference
 2090+ # so we can use the parser cache again.
 2091+ $threshold = 0;
 2092+ }
 2093+ return $threshold;
 2094+ }
 2095+
 2096+ /**
20832097 * Get the permissions this user has.
20842098 * @return \type{\arrayof{\string}} Array of permission names
20852099 */
@@ -2686,10 +2700,11 @@
26872701 }
26882702
26892703 // stubthreshold is only included below for completeness,
2690 - // it will always be 0 when this function is called by parsercache.
 2704+ // since it disables the parser cache, its value will always
 2705+ // be 0 when this function is called by parsercache.
26912706
26922707 $confstr = $this->getOption( 'math' );
2693 - $confstr .= '!' . $this->getOption( 'stubthreshold' );
 2708+ $confstr .= '!' . $this->getStubThreshold();
26942709 if ( $wgUseDynamicDates ) {
26952710 $confstr .= '!' . $this->getDatePreference();
26962711 }
@@ -2700,6 +2715,9 @@
27012716 $extra = $wgContLang->getExtraHashOptions();
27022717 $confstr .= $extra;
27032718
 2719+ // Since the skin could be overloading link(), it should be
 2720+ // included here but in practice, none of our skins do that.
 2721+
27042722 $confstr .= $wgRenderHashAppend;
27052723
27062724 // Give a chance for extensions to modify the hash, if they have
Index: trunk/phase3/includes/Article.php
@@ -891,7 +891,7 @@
892892 # Should the parser cache be used?
893893 $useParserCache = $this->useParserCache( $oldid );
894894 wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
895 - if ( $wgUser->getOption( 'stubthreshold' ) ) {
 895+ if ( $wgUser->getStubThreshold() ) {
896896 wfIncrStats( 'pcache_miss_stub' );
897897 }
898898
@@ -1450,7 +1450,7 @@
14511451 global $wgUser, $wgEnableParserCache;
14521452
14531453 return $wgEnableParserCache
1454 - && intval( $wgUser->getOption( 'stubthreshold' ) ) == 0
 1454+ && $wgUser->getStubThreshold() == 0
14551455 && $this->exists()
14561456 && empty( $oldid )
14571457 && !$this->mTitle->isCssOrJsPage()
@@ -4589,13 +4589,13 @@
45904590
45914591 // Should the parser cache be used?
45924592 $useParserCache = $wgEnableParserCache &&
4593 - intval( $wgUser->getOption( 'stubthreshold' ) ) == 0 &&
 4593+ $wgUser->getStubThreshold() == 0 &&
45944594 $this->exists() &&
45954595 $oldid === null;
45964596
45974597 wfDebug( __METHOD__ . ': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
45984598
4599 - if ( $wgUser->getOption( 'stubthreshold' ) ) {
 4599+ if ( $wgUser->getStubThreshold() ) {
46004600 wfIncrStats( 'pcache_miss_stub' );
46014601 }
46024602
Index: trunk/phase3/includes/parser/LinkHolderArray.php
@@ -99,7 +99,7 @@
100100 function getStubThreshold() {
101101 global $wgUser;
102102 if ( !isset( $this->stubThreshold ) ) {
103 - $this->stubThreshold = $wgUser->getOption('stubthreshold');
 103+ $this->stubThreshold = $wgUser->getStubThreshold();
104104 }
105105 return $this->stubThreshold;
106106 }
Index: trunk/phase3/includes/Linker.php
@@ -267,7 +267,7 @@
268268 }
269269
270270 if ( !in_array( 'broken', $options ) ) { # Avoid useless calls to LinkCache (see r50387)
271 - $colour = $this->getLinkColour( $target, $wgUser->getOption( 'stubthreshold' ) );
 271+ $colour = $this->getLinkColour( $target, $wgUser->getStubThreshold() );
272272 if ( $colour !== '' ) {
273273 $classes[] = $colour; # mw-redirect or stub
274274 }
@@ -337,7 +337,7 @@
338338 global $wgUser;
339339 wfDeprecated( __METHOD__ );
340340
341 - $threshold = intval( $wgUser->getOption( 'stubthreshold' ) );
 341+ $threshold = $wgUser->getStubThreshold();
342342 $colour = ( $size < $threshold ) ? 'stub' : '';
343343 // FIXME: replace deprecated makeColouredLinkObj by link()
344344 return $this->makeColouredLinkObj( $nt, $colour, $text, $query, $trail, $prefix );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r70433Use Disabled for the value 0 of stub threshold since there seems to be some c...platonides22:13, 3 August 2010

Comments

#Comment by Simetrical (talk | contribs)   21:51, 4 August 2010

According to Roan's data, this improves matters for about 15 people on the entire English Wikipedia. Surely it's not worth the added code complexity?

#Comment by Platonides (talk | contribs)   22:26, 4 August 2010

Where are you seeing that complexity?

Few people have done such thing, but the cost of the added comparison is negligible imho.

#Comment by Simetrical (talk | contribs)   18:19, 5 August 2010

Changing 20 lines of code for the sake of a minor improvement in editing experience for 15 people is not really justifiable, IMO. But it's not enough code to be worth arguing over either, so I don't care strongly.

#Comment by Platonides (talk | contribs)   19:08, 5 August 2010

Certainly, the checks shouldn't be repeated on a dozen lines in Article...

#Comment by Aaron Schulz (talk | contribs)   03:26, 5 August 2010

Suggest revert.

#Comment by Tim Starling (talk | contribs)   11:25, 14 December 2010

Marking OK, tolerable.

Status & tagging log