Index: trunk/phase3/thumb.php |
— | — | @@ -173,6 +173,17 @@ |
174 | 174 | try { |
175 | 175 | $thumbName = $img->thumbName( $params ); |
176 | 176 | if ( strlen( $thumbName ) ) { // valid params? |
| 177 | + // For 404 handled thumbnails, we only use the the base name of the URI |
| 178 | + // for the thumb params and the parent directory for the source file name. |
| 179 | + // Check that the zone relative path matches up so squid caches won't pick |
| 180 | + // up thumbs that would not be purged on source file deletion (bug 34231). |
| 181 | + if ( isset( $params['rel404'] ) // thumbnail was handled via 404 |
| 182 | + && $params['rel404'] !== $img->getThumbRel( $thumbName ) ) |
| 183 | + { |
| 184 | + wfThumbError( 404, 'The source file for the specified thumbnail does not exist.' ); |
| 185 | + wfProfileOut( __METHOD__ ); |
| 186 | + return; |
| 187 | + } |
177 | 188 | $thumbPath = $img->getThumbPath( $thumbName ); |
178 | 189 | if ( $img->getRepo()->fileExists( $thumbPath ) ) { |
179 | 190 | $img->getRepo()->streamFile( $thumbPath, $headers ); |
— | — | @@ -244,18 +255,18 @@ |
245 | 256 | $hashDirRegex .= "$subdirRegex/"; |
246 | 257 | } |
247 | 258 | |
248 | | - $thumbUrlRegex = "!^$zoneUrlRegex(/archive|/temp|)/$hashDirRegex([^/]*)/([^/]*)$!"; |
| 259 | + $thumbUrlRegex = "!^$zoneUrlRegex/((archive/|temp/)?$hashDirRegex([^/]*)/([^/]*))$!"; |
249 | 260 | |
250 | 261 | // Check if this is a valid looking thumbnail request... |
251 | 262 | if ( preg_match( $thumbUrlRegex, $uri, $matches ) ) { |
252 | | - list( /* all */, $archOrTemp, $filename, $thumbname ) = $matches; |
| 263 | + list( /* all */, $rel, $archOrTemp, $filename, $thumbname ) = $matches; |
253 | 264 | $filename = urldecode( $filename ); |
254 | 265 | $thumbname = urldecode( $thumbname ); |
255 | 266 | |
256 | | - $params = array( 'f' => $filename ); |
257 | | - if ( $archOrTemp == '/archive' ) { |
| 267 | + $params = array( 'f' => $filename, 'rel404' => $rel ); |
| 268 | + if ( $archOrTemp == 'archive/' ) { |
258 | 269 | $params['archived'] = 1; |
259 | | - } elseif ( $archOrTemp == '/temp' ) { |
| 270 | + } elseif ( $archOrTemp == 'temp/' ) { |
260 | 271 | $params['temp'] = 1; |
261 | 272 | } |
262 | 273 | |