Page MenuHomePhabricator

Instant Commons broken when using thumb.php
Open, LowPublic

Description

So, on my dev wiki, instantcommons thumbnails don't work. I have rewrites setup to use thumb.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/w/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /w/thumb.php?f=$1&width=$2 [L,QSA,B]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/w/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /w/thumb.php?f=$1&width=$2&archived=1 [L,QSA,B]

# Proofread Page
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/w/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/page([0-9]+)-?([0-9]+)px-.*$ /w/thumb.php?f=$1&page=$2&width=$3 [L,QSA]

Thumbnails exist on disk

reedy@ubuntu64-web-esxi:/var/www/wiki/mediawiki/core/images/thumb/e/e6/Mantelaffe-mit-Baby-Zoo-Muenster.jpg$ ls -al
total 9400
drwxr-xr-x 2 www-data www-data    4096 Oct 15 16:38 .
drwxr-xr-x 3 www-data www-data    4096 Oct 15 16:37 ..
-rw-r--r-- 1 www-data www-data   15288 Oct 15 16:37 159px-Mantelaffe-mit-Baby-Zoo-Muenster.jpg
-rw-r--r-- 1 www-data www-data   65691 Oct 15 16:37 397px-Mantelaffe-mit-Baby-Zoo-Muenster.jpg
-rw-r--r-- 1 www-data www-data  135923 Oct 15 16:37 595px-Mantelaffe-mit-Baby-Zoo-Muenster.jpg
-rw-r--r-- 1 www-data www-data  237324 Oct 15 16:38 793px-Mantelaffe-mit-Baby-Zoo-Muenster.jpg
-rw-r--r-- 1 www-data www-data    7302 Oct 15 16:38 79px-Mantelaffe-mit-Baby-Zoo-Muenster.jpg
-rw-r--r-- 1 www-data www-data 9143824 Oct 15 16:37 Mantelaffe-mit-Baby-Zoo-Muenster.jpg
reedy@ubuntu64-web-esxi:/var/www/wiki/mediawiki/core/images/thumb/e/e6/Mantelaffe-mit-Baby-Zoo-Muenster.jpg$

Visiting http://10.0.0.190/w/images/thumb/e/e6/Mantelaffe-mit-Baby-Zoo-Muenster.jpg/397px-Mantelaffe-mit-Baby-Zoo-Muenster.jpg gives

The source file 'Mantelaffe-mit-Baby-Zoo-Muenster.jpg' does not exist.

Event Timeline

Reedy raised the priority of this task from to Needs Triage.
Reedy updated the task description. (Show Details)
Reedy added subscribers: Reedy, aaron.
Reedy set Security to None.

MediaWiki-Vagrant uses this rewrite code for thumb-on-404 handling which looks a bit different:

<Directory /srv/images>
  # Wrap rewrite rules in a location block so apache will apply aliases before
  # testing the RewriteCond
  RewriteEngine On
  RewriteBase /images/

  # Call thumb.php for thumb images not on disk
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/[^/]*([0-9]+)px-.*$ /w/thumb_handler.php [PT,QSA,B]

  # Call thumb.php for thumb archive images not on disk
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/[^/]*([0-9]+)px-.*$ /w/thumb_handler.php [PT,QSA,B]
</Directory>

The equivalent mw-vagrant thumb link is: http://127.0.0.1:8080/images/thumb/e/e6/Mantelaffe-mit-Baby-Zoo-Muenster.jpg/318px-Mantelaffe-mit-Baby-Zoo-Muenster.jpg

Locally this gives me "The source file 'Mantelaffe-mit-Baby-Zoo-Muenster.jpg' does not exist." as well. Log output:

Start request GET /images/thumb/e/e6/Mantelaffe-mit-Baby-Zoo-Muenster.jpg/318px-Mantelaffe-mit-Baby-Zoo-Muenster.jpg
HTTP HEADERS:
DNT: 1
CONTENT-LENGTH:
HOST: 127.0.0.1:8080
CONTENT-TYPE:
CONNECTION: keep-alive
ACCEPT-LANGUAGE: en-US,en;q=0.5
ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
USER-AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:41.0) Gecko/20100101 Firefox/41.0
AUTHORIZATION:
COOKIE: wikiUserName=Admin; centralauth_LoggedOut=1441845691; centralauth_User=Admin; wikiUserID=1; wiki_session=80703dacd7354452547a3482b75cdd71; centralauth_Session=31c7e8167e81bb63fc32cb0bd2a50c3f; uls-previous-language-autonym=English
ACCEPT-ENCODING: gzip, deflate
[redis] Creating a new RedisConnectionPool instance with id d70d28fd70891a6f32c19060fdf71767aaa0c97e.
[caches] main: RedisBagOStuff, message: RedisBagOStuff, parser: RedisBagOStuff
[caches] LocalisationCache: using store LCStoreCDB
Fully initialised
Connected to database 0 at 127.0.0.1
[queries] wiki: BEGIN
[queries] wiki: SELECT  img_size,img_width,img_height,img_bits,img_media_type,img_major_mime,img_minor_mime,img_metadata,img_timestamp,img_sha1,img_user,img_user_text,img_description  FROM `image`   WHERE img_name = 'Mantelaffe-mit-Baby-Zoo-Muenster.jpg'  LIMIT 1
MediaHandler::getHandler: no handler found for .
Pulling file metadata from cache key wiki:file:e6068f707695f5ba363fd2fb0bddb051
[queries] wiki: SELECT  rd_namespace,rd_title  FROM `page`,`redirect`   WHERE page_namespace = '6' AND page_title = 'Mantelaffe-mit-Baby-Zoo-Muenster.jpg' AND (rd_from = page_id)  LIMIT 1
Request ended normally

Hitting http://127.0.0.1:8080/wiki/File:Mantelaffe-mit-Baby-Zoo-Muenster.jpg on my mw-vagrant instance to create the File page via instant commons works (test above was without doing that). This generates several local thumbs:

$ ls -l /srv/images/thumb/e/e6/Mantelaffe-mit-Baby-Zoo-Muenster.jpg
total 9392
-rw-r--r-- 1 www-data www-data   15288 Oct 15 16:08 159px-Mantelaffe-mit-Baby-Zoo-Muenster.jpg
-rw-r--r-- 1 www-data www-data   65691 Oct 15 16:08 397px-Mantelaffe-mit-Baby-Zoo-Muenster.jpg
-rw-r--r-- 1 www-data www-data  135923 Oct 15 16:08 595px-Mantelaffe-mit-Baby-Zoo-Muenster.jpg
-rw-r--r-- 1 www-data www-data  237324 Oct 15 16:08 793px-Mantelaffe-mit-Baby-Zoo-Muenster.jpg
-rw-r--r-- 1 www-data www-data    7302 Oct 15 16:08 79px-Mantelaffe-mit-Baby-Zoo-Muenster.jpg
-rw-r--r-- 1 www-data www-data 9143824 Oct 15 16:08 Mantelaffe-mit-Baby-Zoo-Muenster.jpg

Requesting these existing thumbs works: http://127.0.0.1:8080/images/thumb/e/e6/Mantelaffe-mit-Baby-Zoo-Muenster.jpg/397px-Mantelaffe-mit-Baby-Zoo-Muenster.jpg

Requesting another randomly sized thumb (eg http://127.0.0.1:8080/images/thumb/e/e6/Mantelaffe-mit-Baby-Zoo-Muenster.jpg/142px-Mantelaffe-mit-Baby-Zoo-Muenster.jpg) continues to return a "The source file 'Mantelaffe-mit-Baby-Zoo-Muenster.jpg' does not exist." error message.

404 handler is configured per repo; it is not enabled for InstantCommons. Even if you did enable it, it wouldn't work due to T27958. (See T114098#1717456 for a hotlinking configuration that does work.)

The real bug here is that the thumbnail does not get generated when you save the article (if it would, the 404 handler would never be invoked in the first place). Maybe you switched on InstantCommons only after the articles were saved? I don't think any kind of parser cache invalidation exists for changes in repo configuration.

Restricted Application added a subscriber: StudiesWorld. · View Herald Transcript
MarkTraceur subscribed.