r85342 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85341‎ | r85342 | r85343 >
Date:17:05, 4 April 2011
Author:demon
Status:ok
Tags:
Comment:
MFT r82465, r82468, r82474 (second try), followup to r85211
Modified paths:
  • /branches/REL1_17/phase3 (modified) (history)
  • /branches/REL1_17/phase3/includes (modified) (history)
  • /branches/REL1_17/phase3/includes/EditPage.php (modified) (history)
  • /branches/REL1_17/phase3/includes/OutputPage.php (modified) (history)
  • /branches/REL1_17/phase3/includes/resourceloader/ResourceLoaderContext.php (modified) (history)
  • /branches/REL1_17/phase3/includes/resourceloader/ResourceLoaderModule.php (modified) (history)
  • /branches/REL1_17/phase3/includes/resourceloader/ResourceLoaderWikiModule.php (modified) (history)
  • /branches/REL1_17/phase3/skins/common/IE80Fixes.css (added) (history)

Diff [purge]

Index: branches/REL1_17/phase3/includes/OutputPage.php
@@ -2381,14 +2381,29 @@
23822382 }
23832383 $links = '';
23842384 foreach ( $groups as $group => $modules ) {
2385 - $query['modules'] = implode( '|', array_keys( $modules ) );
23862385 // Special handling for user-specific groups
23872386 if ( ( $group === 'user' || $group === 'private' ) && $wgUser->isLoggedIn() ) {
23882387 $query['user'] = $wgUser->getName();
23892388 }
 2389+
 2390+ // Create a fake request based on the one we are about to make so modules return
 2391+ // correct timestamp and emptiness data
 2392+ $context = new ResourceLoaderContext( $resourceLoader, new FauxRequest( $query ) );
 2393+ // Drop modules that know they're empty
 2394+ foreach ( $modules as $key => $module ) {
 2395+ if ( $module->isKnownEmpty( $context ) ) {
 2396+ unset( $modules[$key] );
 2397+ }
 2398+ }
 2399+ // If there are no modules left, skip this group
 2400+ if ( $modules === array() ) {
 2401+ continue;
 2402+ }
 2403+
 2404+ $query['modules'] = implode( '|', array_keys( $modules ) );
 2405+
23902406 // Support inlining of private modules if configured as such
23912407 if ( $group === 'private' && $wgResourceLoaderInlinePrivateModules ) {
2392 - $context = new ResourceLoaderContext( $resourceLoader, new FauxRequest( $query ) );
23932408 if ( $only == 'styles' ) {
23942409 $links .= Html::inlineStyle(
23952410 $resourceLoader->makeModuleResponse( $context, $modules )
@@ -2406,9 +2421,6 @@
24072422 // on-wiki like site or user pages, or user preferences; we need to find the highest
24082423 // timestamp of these user-changable modules so we can ensure cache misses on change
24092424 if ( $group === 'user' || $group === 'site' ) {
2410 - // Create a fake request based on the one we are about to make so modules return
2411 - // correct times
2412 - $context = new ResourceLoaderContext( $resourceLoader, new FauxRequest( $query ) );
24132425 // Get the maximum timestamp
24142426 $timestamp = 1;
24152427 foreach ( $modules as $module ) {
Property changes on: branches/REL1_17/phase3/includes/OutputPage.php
___________________________________________________________________
Modified: svn:mergeinfo
24162428 Merged /trunk/phase3/includes/includes/OutputPage.php:r82474
24172429 Merged /trunk/phase3/includes/OutputPage.php:r82468,82474
Index: branches/REL1_17/phase3/includes/resourceloader/ResourceLoaderContext.php
@@ -131,7 +131,7 @@
132132 }
133133
134134 public function getHash() {
135 - if ( isset( $this->hash ) ) {
 135+ if ( !isset( $this->hash ) ) {
136136 $this->hash = implode( '|', array(
137137 $this->getLanguage(), $this->getDirection(), $this->skin, $this->user,
138138 $this->debug, $this->only, $this->version
Index: branches/REL1_17/phase3/includes/resourceloader/ResourceLoaderModule.php
@@ -223,4 +223,17 @@
224224 // 0 would mean now
225225 return 1;
226226 }
 227+
 228+ /**
 229+ * Check whether this module is known to be empty. If a child class
 230+ * has an easy and cheap way to determine that this module is
 231+ * definitely going to be empty, it should override this method to
 232+ * return true in that case. Callers may optimize the request for this
 233+ * module away if this function returns true.
 234+ * @param $context ResourceLoaderContext: Context object
 235+ * @return Boolean
 236+ */
 237+ public function isKnownEmpty( ResourceLoaderContext $context ) {
 238+ return false;
 239+ }
227240 }
Index: branches/REL1_17/phase3/includes/resourceloader/ResourceLoaderWikiModule.php
@@ -33,8 +33,8 @@
3434
3535 /* Protected Members */
3636
37 - // In-object cache for modified time
38 - protected $modifiedTime = array();
 37+ // In-object cache for title mtimes
 38+ protected $titleMtimes = array();
3939
4040 /* Abstract Protected Methods */
4141
@@ -113,29 +113,59 @@
114114 }
115115
116116 public function getModifiedTime( ResourceLoaderContext $context ) {
 117+ $modifiedTime = 1; // wfTimestamp() interprets 0 as "now"
 118+ $mtimes = $this->getTitleMtimes( $context );
 119+ if ( count( $mtimes ) ) {
 120+ $modifiedTime = max( $modifiedTime, max( $mtimes ) );
 121+ }
 122+ return $modifiedTime;
 123+ }
 124+
 125+ public function isKnownEmpty( ResourceLoaderContext $context ) {
 126+ return count( $this->getTitleMtimes( $context ) ) == 0;
 127+ }
 128+
 129+ /**
 130+ * @param $context ResourceLoaderContext
 131+ * @return bool
 132+ */
 133+ public function getFlip( $context ) {
 134+ global $wgContLang;
 135+
 136+ return $wgContLang->getDir() !== $context->getDirection();
 137+ }
 138+
 139+ /**
 140+ * Get the modification times of all titles that would be loaded for
 141+ * a given context.
 142+ * @param $context ResourceLoaderContext: Context object
 143+ * @return array( prefixed DB key => UNIX timestamp ), nonexistent titles are dropped
 144+ */
 145+ protected function getTitleMtimes( ResourceLoaderContext $context ) {
117146 $hash = $context->getHash();
118 - if ( isset( $this->modifiedTime[$hash] ) ) {
119 - return $this->modifiedTime[$hash];
 147+ if ( isset( $this->titleMtimes[$hash] ) ) {
 148+ return $this->titleMtimes[$hash];
120149 }
121 -
 150+
 151+ $this->titleMtimes[$hash] = array();
122152 $batch = new LinkBatch;
123153 foreach ( $this->getPages( $context ) as $titleText => $options ) {
124154 $batch->addObj( Title::newFromText( $titleText ) );
125155 }
126 -
127 - $modifiedTime = 1; // wfTimestamp() interprets 0 as "now"
 156+
128157 if ( !$batch->isEmpty() ) {
129158 $dbr = wfGetDB( DB_SLAVE );
130 - $latest = $dbr->selectField( 'page', 'MAX(page_touched)',
 159+ $res = $dbr->select( 'page',
 160+ array( 'page_namespace', 'page_title', 'page_touched' ),
131161 $batch->constructSet( 'page', $dbr ),
132 - __METHOD__ );
133 -
134 - if ( $latest ) {
135 - $modifiedTime = wfTimestamp( TS_UNIX, $latest );
 162+ __METHOD__
 163+ );
 164+ foreach ( $res as $row ) {
 165+ $title = Title::makeTitle( $row->page_namespace, $row->page_title );
 166+ $this->titleMtimes[$hash][$title->getPrefixedDBkey()] =
 167+ wfTimestamp( TS_UNIX, $row->page_touched );
136168 }
137169 }
138 -
139 - $this->modifiedTime[$hash] = $modifiedTime;
140 - return $modifiedTime;
 170+ return $this->titleMtimes[$hash];
141171 }
142172 }
Index: branches/REL1_17/phase3/includes/EditPage.php
@@ -340,6 +340,8 @@
341341 if ( $wgUser->getOption( 'uselivepreview', false ) ) {
342342 $wgOut->addModules( 'mediawiki.legacy.preview' );
343343 }
 344+ // Bug #19334: textarea jumps when editing articles in IE8
 345+ $wgOut->addStyle( 'common/IE80Fixes.css', 'screen', 'IE 8' );
344346
345347 $permErrors = $this->getEditPermissionErrors();
346348 if ( $permErrors ) {
Property changes on: branches/REL1_17/phase3/includes
___________________________________________________________________
Modified: svn:mergeinfo
347349 Merged /trunk/phase3/includes:r82474
Index: branches/REL1_17/phase3/skins/common/IE80Fixes.css
@@ -0,0 +1,15 @@
 2+/**
 3+ * Fixes textarea scrolling bug (bug #19334). The bug only occurs when a
 4+ * percentage width is given, so instead of width: 100%, use min-width: 100%;
 5+ * max-width: 100%. We also need to give a fixed width for the actual width
 6+ * property for the hack to work, although the actual value (500px here) ends
 7+ * up being ignored; min/max-width take precedence.
 8+ *
 9+ * More info: http://grantovich.net/posts/2009/06/that-weird-ie8-textarea-bug/
 10+ */
 11+#wpTextbox1 {
 12+ height: 390px;
 13+ width: 500px;
 14+ min-width: 100%;
 15+ max-width: 100%;
 16+}
Property changes on: branches/REL1_17/phase3/skins/common/IE80Fixes.css
___________________________________________________________________
Added: svn:eol-style
117 + native
Property changes on: branches/REL1_17/phase3
___________________________________________________________________
Modified: svn:mergeinfo
218 Merged /trunk/phase3:r82474

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r82465Fix logic error in r73204 (!) causing ResourceLoaderContext::getHash() to alw...catrope16:48, 19 February 2011
r82468(bug 27302) Avoid unnecessary requests for user and site modules if the relev...catrope17:07, 19 February 2011
r82474Revert r74387: it may not fix the IE8 jumping bug in all cases, but it defini...catrope19:21, 19 February 2011
r85211MFT: r82297, r82307, r82309, r82312, r82315, r82337, r82391, r82392, r82403, ...demon21:01, 2 April 2011

Status & tagging log