Skip to content

Commit

Permalink
Go through all slugs and make them legal values.
Browse files Browse the repository at this point in the history
Upgrade gallery3 module to version 23
  • Loading branch information
bharat committed Jan 29, 2010
1 parent 844d40a commit 98bcb95
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
23 changes: 22 additions & 1 deletion modules/gallery/helpers/gallery_installer.php
Expand Up @@ -450,7 +450,7 @@ static function upgrade($version) {

// 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();
Expand All @@ -463,6 +463,27 @@ static function upgrade($version) {
}
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() {
Expand Down
2 changes: 1 addition & 1 deletion modules/gallery/module.info
@@ -1,4 +1,4 @@
name = "Gallery 3"
description = "Gallery core application"
version = 22
version = 23

0 comments on commit 98bcb95

Please sign in to comment.