Index: branches/resourceloader/phase3/includes/ResourceLoaderModule.php |
— | — | @@ -305,6 +305,25 @@ |
306 | 306 | return self::concatScripts( $this->loaders ); |
307 | 307 | } |
308 | 308 | |
| 309 | + public function getmtime() { |
| 310 | + $fields = array( $this->scripts, $this->styles, $this->debugScripts, |
| 311 | + $this->languageScripts, $this->skinScripts, $this->skinStyles, |
| 312 | + $this->loaders |
| 313 | + ); |
| 314 | + return self::getMaxMtime( $fields ); |
| 315 | + } |
| 316 | + |
| 317 | + protected static function getMaxMtime( $arr ) { |
| 318 | + if ( is_array( $arr ) ) { |
| 319 | + if ( $arr ) { |
| 320 | + return max( array_map( array( 'ResourceLoaderModule', 'getMaxMtime' ), $arr ) ); |
| 321 | + } else { |
| 322 | + return 1; // wfTimestamp() interprets 0 as "now" |
| 323 | + } |
| 324 | + } |
| 325 | + return filemtime( $arr ); |
| 326 | + } |
| 327 | + |
309 | 328 | /** |
310 | 329 | * Get the contents of a set of files and concatenate them, with |
311 | 330 | * newlines in between. Each file is used only once. |
— | — | @@ -329,6 +348,29 @@ |
330 | 349 | return Skin::newFromKey( $skin )->generateUserJs(); |
331 | 350 | } |
332 | 351 | |
| 352 | + public function getmtime() { |
| 353 | + // HACK: We duplicate the message names from generateUserJs() |
| 354 | + // here and weird things (i.e. mtime moving backwards) can happen |
| 355 | + // when a MediaWiki:Something.js page is deleted |
| 356 | + $jsPages = array( Title::makeTitle( NS_MEDIAWIKI, 'Common.js' ) ); |
| 357 | + foreach ( Skin::getSkinNames() as $skinname ) { |
| 358 | + $jsPages[] = Title::makeTitleSafe( NS_MEDIAWIKI, ucfirst( $skinname) . '.js' ); |
| 359 | + } |
| 360 | + |
| 361 | + // Do batch existence check |
| 362 | + // TODO: This would work better if page_touched were loaded by this as well |
| 363 | + $lb = new LinkBatch( $jsPages ); |
| 364 | + $lb->execute(); |
| 365 | + |
| 366 | + $retval = 1; // wfTimestamp() interprets 0 as "now" |
| 367 | + foreach ( $jsPages as $jsPage ) { |
| 368 | + if ( $jsPage->exists() ) { |
| 369 | + $retval = max( $retval, $jsPage->getTouched() ); |
| 370 | + } |
| 371 | + } |
| 372 | + return $retval; |
| 373 | + } |
| 374 | + |
333 | 375 | // Dummy overrides to return emptyness |
334 | 376 | public function getScript() { return ''; } |
335 | 377 | public function getStyle() { return ''; } |