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.
 * See 78143 for a patch that makes it even easier

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.

I'm leaning towards the vhost reading include files approach. Here's what I think would be reasonable and extensible:


 * new apache::site::include resource type
 * This resource would ensure the availablity of an /etc/apache2/site-conf.d/[sitename]/ directory and manage adding a file to it
 * modify mediawiki-apache-site.erb to include files from the site include dir
 * add a usage of apache::site::include in role::thumb_on_404 to include needed rewrite rules