BryanDavis has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/223493

Change subject: Fix thumb on 404 role for multiwiki reality
......................................................................

Fix thumb on 404 role for multiwiki reality

Fix bug in ::role::thumb_on_404 where 404 handling was configured for
all wikis but apache rewrite rules were only setup for the default wiki
by restricting the wiki config to the default wiki as well. The
::role::thumb_on_404::multiwiki Puppet define can be used to add thumb
on 404 configuration for additional wikis (eg commons via ::role::commons).

Bug: T56202
Change-Id: I63a8893642bf3b8bd3268fa1a2063356f2dd2bdd
---
M puppet/modules/role/manifests/thumb_on_404.pp
M puppet/modules/role/manifests/thumb_on_404/multiwiki.pp
M puppet/modules/role/templates/thumb_on_404/apache2.conf.erb
3 files changed, 43 insertions(+), 28 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vagrant 
refs/changes/93/223493/1

diff --git a/puppet/modules/role/manifests/thumb_on_404.pp 
b/puppet/modules/role/manifests/thumb_on_404.pp
index 07f9407..12c18d8 100644
--- a/puppet/modules/role/manifests/thumb_on_404.pp
+++ b/puppet/modules/role/manifests/thumb_on_404.pp
@@ -6,19 +6,8 @@
 
     require_package('imagemagick')
 
-    # Enable dynamic thumbnail generation via the thumb.php
-    # script for 404 thumb images.
-    mediawiki::settings { 'thumb.php on 404':
-        values => {
-            wgThumbnailScriptPath      => false,
-            wgGenerateThumbnailOnParse => false,
-            wgUseImageMagick           => true,
-        },
-    }
-
-    $images_path = '/images'
-    apache::site_conf { 'thumb.php on 404':
-        site    => $::mediawiki::wiki_name,
-        content => template('role/thumb_on_404/apache2.conf.erb'),
+    role::thumb_on_404::multiwiki { $::mediawiki::wiki_name:
+        images_path => '/images',
+        wiki        => $::mediawiki::wiki_db,
     }
 }
diff --git a/puppet/modules/role/manifests/thumb_on_404/multiwiki.pp 
b/puppet/modules/role/manifests/thumb_on_404/multiwiki.pp
index 7660e12..80cb9a2 100644
--- a/puppet/modules/role/manifests/thumb_on_404/multiwiki.pp
+++ b/puppet/modules/role/manifests/thumb_on_404/multiwiki.pp
@@ -1,13 +1,37 @@
 # == Define: ::role::thumb_on_404::multiwiki
 # Configure a multiwiki instance with thumbs on 404.
 # See commons.pp
-define role::thumb_on_404::multiwiki {
+#
+# === Parameters
+# [*images_path*]
+#   URL path to site images. Default "/${title}images".
+#
+# [*wiki*]
+#   Wiki to configure. Default $title.
+#
+# === Example
+# role::thumb_on_404::multiwiki { 'commons' }
+#
+define role::thumb_on_404::multiwiki(
+    $images_path = "/${title}images",
+    $wiki        = $title,
+) {
     require ::role::mediawiki
 
-    $images_path = "/${title}images"
+    # Enable dynamic thumbnail generation via the thumb.php
+    # script for 404 thumb images.
+    mediawiki::settings { "${wiki}:thumb.php_on_404":
+        values => {
+            wgThumbnailScriptPath      => false,
+            wgGenerateThumbnailOnParse => false,
+            wgUseImageMagick           => true,
+        },
+    }
 
-    apache::site_conf { "${title}:thumb.php on 404":
-        site    => $::mediawiki::wiki_name,
+    apache::site_conf { "${wiki}:thumb.php on 404":
+        site    => $wiki,
         content => template('role/thumb_on_404/apache2.conf.erb'),
     }
+
+    #Mediawiki::Wiki <| wikidb == $wiki |> -> Role::Thumb_on_404::Multiwiki <| 
wiki == $wiki |>
 }
diff --git a/puppet/modules/role/templates/thumb_on_404/apache2.conf.erb 
b/puppet/modules/role/templates/thumb_on_404/apache2.conf.erb
index b34b4ed..c962fe4 100644
--- a/puppet/modules/role/templates/thumb_on_404/apache2.conf.erb
+++ b/puppet/modules/role/templates/thumb_on_404/apache2.conf.erb
@@ -1,15 +1,17 @@
-RewriteEngine On
-
-# needs to be in a location block otherwise apache would not apply aliases 
before testing the RewriteCond
 <Location <%= @images_path %>>
-  # call thumb.php for thumb images not on disk
-  RewriteCond %{REQUEST_FILENAME} !-f
-  RewriteCond %{REQUEST_FILENAME} !-d
-  RewriteRule ^<%= @images_path 
%>/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/[^/]*([0-9]+)px-.*$ 
/w/thumb_handler.php [PT,QSA,B]
+  # Wrap rewrite rules in a location block so apache will apply aliases before
+  # testing the RewriteCond
+  RewriteEngine On
+  RewriteBase <%= @images_path %>/
 
-  # call thumb.php for thumb archive images not on disk
+  # Call thumb.php for thumb images not on disk
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
-  RewriteRule ^<%= @images_path 
%>/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/[^/]*([0-9]+)px-.*$ 
/w/thumb_handler.php [PT,QSA,B]
+  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]
 </Location>
-
+# vim:sw=2:ts=2:sts=2:ft=apache:

-- 
To view, visit https://gerrit.wikimedia.org/r/223493
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I63a8893642bf3b8bd3268fa1a2063356f2dd2bdd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/vagrant
Gerrit-Branch: master
Gerrit-Owner: BryanDavis <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to