Index: trunk/phase3/includes/db/DatabaseError.php |
— | — | @@ -220,16 +220,23 @@ |
221 | 221 | * @return string |
222 | 222 | */ |
223 | 223 | private function fileCachedPage() { |
224 | | - global $wgTitle, $wgOut; |
| 224 | + global $wgTitle, $wgOut, $wgRequest; |
225 | 225 | |
226 | 226 | if ( $wgOut->isDisabled() ) { |
227 | 227 | return; // Done already? |
228 | 228 | } |
229 | 229 | |
230 | | - if ( $wgTitle ) { |
231 | | - $t =& $wgTitle; |
| 230 | + if ( $wgTitle ) { // use $wgTitle if we managed to set it |
| 231 | + $t = $wgTitle->getPrefixedDBkey(); |
232 | 232 | } else { |
233 | | - $t = Title::newFromText( $this->msg( 'mainpage', 'Main Page' ) ); |
| 233 | + # Fallback to the raw title URL param. We can't use the Title |
| 234 | + # class is it may hit the interwiki table and give a DB error. |
| 235 | + # We may get a cache miss due to not sanitizing the title though. |
| 236 | + $t = str_replace( ' ', '_', $wgRequest->getVal( 'title' ) ); |
| 237 | + if ( $t == '' ) { // fallback to main page |
| 238 | + $t = Title::newFromText( |
| 239 | + $this->msg( 'mainpage', 'Main Page' ) )->getPrefixedDBkey(); |
| 240 | + } |
234 | 241 | } |
235 | 242 | |
236 | 243 | $cache = HTMLFileCache::newFromTitle( $t, 'view' ); |
Index: trunk/phase3/includes/cache/HTMLFileCache.php |
— | — | @@ -7,18 +7,20 @@ |
8 | 8 | class HTMLFileCache extends FileCacheBase { |
9 | 9 | /** |
10 | 10 | * Construct an ObjectFileCache from a Title and an action |
11 | | - * @param $title Title |
| 11 | + * @param $title Title|string Title object or prefixed DB key string |
12 | 12 | * @param $action string |
13 | 13 | * @return HTMLFileCache |
14 | 14 | */ |
15 | | - public static function newFromTitle( Title $title, $action ) { |
| 15 | + public static function newFromTitle( $title, $action ) { |
16 | 16 | $cache = new self(); |
17 | 17 | |
18 | 18 | $allowedTypes = self::cacheablePageActions(); |
19 | 19 | if ( !in_array( $action, $allowedTypes ) ) { |
20 | 20 | throw new MWException( "Invalid filecache type given." ); |
21 | 21 | } |
22 | | - $cache->mKey = $title->getPrefixedDBkey(); |
| 22 | + $cache->mKey = ( $title instanceof Title ) |
| 23 | + ? $title->getPrefixedDBkey() |
| 24 | + : (string)$title; |
23 | 25 | $cache->mType = (string)$action; |
24 | 26 | $cache->mExt = 'html'; |
25 | 27 | |