User:BDavis (WMF)/Notes/Thumb.php with Vagrant

= Enable Use of thumb.php in Vagrant VM =

Create a Vagrant "role" that enables thumb.php to handle 404 image requests in the wikimedia instance.

Manual
### thumb.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /w/thumb.php?f=$1&width=$2 [PT,QSA,B] ### ^^^^ this works but doesn't match wiki docs ### PT instead of L
 * Add config to LocalSettings.php:
 * Configure 404 handler in /etc/apache2/sites-enabled/devwiki (Manual:Thumb.php):

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

Note that I used the MediaWiki <= 1.19 syntax. I couldn't get  to work properly. It seems like the PathRouter setup isn't quite right to handle it. I also had to change from  to   to get the alias for   to take effect.

With these changes in place my vm instance is generating new thumbs on the fly. They are also saved to disk in /svr/images

Puppet
Basic idea: create a new role that:
 * 1) sets needed values in LocalSettings.php
 * 2) adds rewrites to apache vhost config

Augmenting LocalSettings is we documented and supported.

Messing with the vhost config is a little less easy. There are a couple ways it might be handled.
 * 1) The mediawiki class could be changed to take more parameters. This could be a simple flag for this feature or a more general system.
 * 2) The template for the vhost could be altered to read includes from some filesystem location into the  scope.