summaryrefslogtreecommitdiff
path: root/modules/gallery
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2010-01-29 14:20:34 -0800
committerBharat Mediratta <bharat@menalto.com>2010-01-29 14:20:34 -0800
commit98bcb95b1065a044909c4c4ff15d93fafc793df7 (patch)
tree34837ceb515e67eccd6bd41ada861c1ce5d7ef0c /modules/gallery
parent844d40a759db80108d20684303680d2e489af9d0 (diff)
Go through all slugs and make them legal values.
Upgrade gallery3 module to version 23
Diffstat (limited to 'modules/gallery')
-rw-r--r--modules/gallery/helpers/gallery_installer.php23
-rw-r--r--modules/gallery/module.info2
2 files changed, 23 insertions, 2 deletions
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index 93948045..8227fdc9 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -450,7 +450,7 @@ class gallery_installer {
// Update the graphics rules table so that the maximum height for resizes is 640 not 480.
// Fixes ticket #671
- if ( $version == 21) {
+ if ($version == 21) {
$resize_rule = ORM::factory("graphics_rule")
->where("id", "=", "2")
->find();
@@ -463,6 +463,27 @@ class gallery_installer {
}
module::set_version("gallery", $version = 22);
}
+
+ // Update slug values to be legal. We should have done this in the 11->12 upgrader, but I was
+ // lazy. Mea culpa!
+ if ($version == 22) {
+ foreach (db::build()
+ ->from("items")
+ ->select("id", "slug")
+ ->where(new Database_Expression("`slug` REGEXP '[^_A-Za-z0-9-]'"), "=", 1)
+ ->execute() as $row) {
+ $new_slug = item::convert_filename_to_slug($row->slug);
+ if (empty($new_slug)) {
+ $new_slug = rand();
+ }
+ db::build()
+ ->update("items")
+ ->set("slug", $new_slug)
+ ->where("id", "=", $row->id)
+ ->execute();
+ }
+ module::set_version("gallery", $version = 23);
+ }
}
static function uninstall() {
diff --git a/modules/gallery/module.info b/modules/gallery/module.info
index 107d9a12..ee169cf1 100644
--- a/modules/gallery/module.info
+++ b/modules/gallery/module.info
@@ -1,4 +1,4 @@
name = "Gallery 3"
description = "Gallery core application"
-version = 22
+version = 23