summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/comment/helpers/comment_rss.php2
-rw-r--r--modules/gallery/controllers/admin_advanced_settings.php30
-rw-r--r--modules/gallery/helpers/gallery_installer.php25
-rw-r--r--modules/gallery/helpers/gallery_task.php108
-rw-r--r--modules/gallery/models/item.php2
-rw-r--r--modules/gallery/module.info2
-rw-r--r--modules/gallery/tests/Item_Model_Test.php6
-rw-r--r--modules/gallery/views/admin_advanced_settings.html.php2
-rw-r--r--modules/gallery/views/movieplayer.html.php2
-rw-r--r--modules/tag/helpers/tag_event.php3
10 files changed, 139 insertions, 43 deletions
diff --git a/modules/comment/helpers/comment_rss.php b/modules/comment/helpers/comment_rss.php
index be1968dc..1a7ed53c 100644
--- a/modules/comment/helpers/comment_rss.php
+++ b/modules/comment/helpers/comment_rss.php
@@ -36,7 +36,7 @@ class comment_rss_Core {
}
if ($item && comment_rss::feed_visible("per_item")) {
- $feeds["comment/item/$item->id"] =
+ $feeds["comment/per_item/$item->id"] =
t("Comments on %title", array("title" => html::purify($item->title)));
}
return $feeds;
diff --git a/modules/gallery/controllers/admin_advanced_settings.php b/modules/gallery/controllers/admin_advanced_settings.php
index 1ce47529..752a2e81 100644
--- a/modules/gallery/controllers/admin_advanced_settings.php
+++ b/modules/gallery/controllers/admin_advanced_settings.php
@@ -30,24 +30,28 @@ class Admin_Advanced_Settings_Controller extends Admin_Controller {
}
public function edit($module_name, $var_name) {
- $value = module::get_var($module_name, $var_name);
- $form = new Forge("admin/advanced_settings/save/$module_name/$var_name", "", "post");
- $group = $form->group("edit_var")->label(t("Edit setting"));
- $group->input("module_name")->label(t("Module"))->value($module_name)->disabled(1);
- $group->input("var_name")->label(t("Setting"))->value($var_name)->disabled(1);
- $group->textarea("value")->label(t("Value"))->value($value);
- $group->submit("")->value(t("Save"));
- print $form;
+ if (module::is_installed($module_name)) {
+ $value = module::get_var($module_name, $var_name);
+ $form = new Forge("admin/advanced_settings/save/$module_name/$var_name", "", "post");
+ $group = $form->group("edit_var")->label(t("Edit setting"));
+ $group->input("module_name")->label(t("Module"))->value($module_name)->disabled(1);
+ $group->input("var_name")->label(t("Setting"))->value($var_name)->disabled(1);
+ $group->textarea("value")->label(t("Value"))->value($value);
+ $group->submit("")->value(t("Save"));
+ print $form;
+ }
}
public function save($module_name, $var_name) {
access::verify_csrf();
- module::set_var($module_name, $var_name, Input::instance()->post("value"));
- message::success(
- t("Saved value for %var (%module_name)",
- array("var" => $var_name, "module_name" => $module_name)));
+ if (module::is_installed($module_name)) {
+ module::set_var($module_name, $var_name, Input::instance()->post("value"));
+ message::success(
+ t("Saved value for %var (%module_name)",
+ array("var" => $var_name, "module_name" => $module_name)));
- json::reply(array("result" => "success"));
+ json::reply(array("result" => "success"));
+ }
}
}
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index e1e4e7a9..e556b49a 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -313,7 +313,7 @@ class gallery_installer {
module::set_var("gallery", "extra_binary_paths", "/usr/local/bin:/opt/local/bin:/opt/bin");
module::set_var("gallery", "timezone", null);
- module::set_version("gallery", 49);
+ module::set_version("gallery", 50);
}
static function upgrade($version) {
@@ -405,7 +405,7 @@ class gallery_installer {
// for now because we don't want a lengthy operation here.
$db->query("UPDATE {items} SET `slug` = `name`");
- // Flush all path caches becuase we're going to start urlencoding them.
+ // Flush all path caches because we're going to start urlencoding them.
$db->query("UPDATE {items} SET `relative_url_cache` = NULL, `relative_path_cache` = NULL");
module::set_version("gallery", $version = 12);
}
@@ -692,6 +692,27 @@ class gallery_installer {
module::set_var("gallery", "timezone", null);
module::set_version("gallery", $version = 49);
}
+
+ if ($version == 49) {
+ // In v49 we changed the Item_Model validation code to disallow files with two dots in them,
+ // but we didn't rename any files which fail to validate, so as soon as you do anything to
+ // change those files (eg. as a side effect of getting the url or file path) it fails to
+ // validate. Fix those here. This might be slow, but if it times out it can just pick up
+ // where it left off.
+ foreach (db::build()
+ ->from("items")
+ ->select("id")
+ ->where("type", "<>", "album")
+ ->where(db::expr("`name` REGEXP '\\\\..*\\\\.'"), "=", 1)
+ ->order_by("id", "asc")
+ ->execute() as $row) {
+ set_time_limit(30);
+ $item = ORM::factory("item", $row->id);
+ $item->name = legal_file::smash_extensions($item->name);
+ $item->save();
+ }
+ module::set_version("gallery", $version = 50);
+ }
}
static function uninstall() {
diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php
index 9a35ce67..65a72884 100644
--- a/modules/gallery/helpers/gallery_task.php
+++ b/modules/gallery/helpers/gallery_task.php
@@ -26,9 +26,11 @@ class gallery_task_Core {
const FIX_STATE_RUN_DUPE_SLUGS = 5;
const FIX_STATE_START_DUPE_NAMES = 6;
const FIX_STATE_RUN_DUPE_NAMES = 7;
- const FIX_STATE_START_MISSING_ACCESS_CACHES = 8;
- const FIX_STATE_RUN_MISSING_ACCESS_CACHES = 9;
- const FIX_STATE_DONE = 10;
+ const FIX_STATE_START_REBUILD_ITEM_CACHES = 8;
+ const FIX_STATE_RUN_REBUILD_ITEM_CACHES = 9;
+ const FIX_STATE_START_MISSING_ACCESS_CACHES = 10;
+ const FIX_STATE_RUN_MISSING_ACCESS_CACHES = 11;
+ const FIX_STATE_DONE = 12;
static function available_tasks() {
$dirty_count = graphics::find_dirty_images_query()->count_records();
@@ -337,10 +339,15 @@ class gallery_task_Core {
$total = $task->get("total");
if (empty($total)) {
+ $item_count = db::build()->count_records("items");
+ $total = 0;
+
// mptt: 2 operations for every item
- $total = 2 * db::build()->count_records("items");
+ $total += 2 * $item_count;
+
// album audit (permissions and bogus album covers): 1 operation for every album
$total += db::build()->where("type", "=", "album")->count_records("items");
+
// one operation for each missing slug, name and access cache
foreach (array("find_dupe_slugs", "find_dupe_names", "find_missing_access_caches") as $func) {
foreach (self::$func() as $row) {
@@ -348,6 +355,9 @@ class gallery_task_Core {
}
}
+ // one operation to rebuild path and url caches;
+ $total += 1 * $item_count;
+
$task->set("total", $total);
$task->set("state", $state = self::FIX_STATE_START_MPTT);
$task->set("ptr", 1);
@@ -556,37 +566,76 @@ class gallery_task_Core {
$completed++;
if (empty($stack)) {
- $state = self::FIX_STATE_START_MISSING_ACCESS_CACHES;
+ $state = self::FIX_STATE_START_REBUILD_ITEM_CACHES;
}
break;
- case self::FIX_STATE_START_MISSING_ACCESS_CACHES:
+ case self::FIX_STATE_START_REBUILD_ITEM_CACHES:
$stack = array();
- foreach (self::find_missing_access_caches() as $row) {
+ foreach (self::find_empty_item_caches(500) as $row) {
$stack[] = $row->id;
}
- if ($stack) {
+ $task->set("stack", implode(" ", $stack));
+ $state = self::FIX_STATE_RUN_REBUILD_ITEM_CACHES;
+ break;
+
+ case self::FIX_STATE_RUN_REBUILD_ITEM_CACHES:
+ $stack = explode(" ", $task->get("stack"));
+ if (!empty($stack)) {
+ $id = array_pop($stack);
+ $item = ORM::factory("item", $id);
+ $item->relative_path(); // this rebuilds the cache and saves the item as a side-effect
$task->set("stack", implode(" ", $stack));
- $state = self::FIX_STATE_RUN_MISSING_ACCESS_CACHES;
- } else {
- $state = self::FIX_STATE_DONE;
+ $completed++;
+ }
+
+ if (empty($stack)) {
+ // Try refilling the stack
+ foreach (self::find_empty_item_caches(500) as $row) {
+ $stack[] = $row->id;
+ }
+ $task->set("stack", implode(" ", $stack));
+
+ if (empty($stack)) {
+ $state = self::FIX_STATE_START_MISSING_ACCESS_CACHES;
+ }
+ }
+ break;
+
+ case self::FIX_STATE_START_MISSING_ACCESS_CACHES:
+ $stack = array();
+ foreach (self::find_missing_access_caches_limited(500) as $row) {
+ $stack[] = $row->id;
}
+ $task->set("stack", implode(" ", $stack));
+ $state = self::FIX_STATE_RUN_MISSING_ACCESS_CACHES;
break;
case self::FIX_STATE_RUN_MISSING_ACCESS_CACHES:
$stack = explode(" ", $task->get("stack"));
- $id = array_pop($stack);
- $access_cache = ORM::factory("access_cache");
- $access_cache->item_id = $id;
- $access_cache->save();
- $task->set("stack", implode(" ", $stack));
- $completed++;
+ if (!empty($stack)) {
+ $id = array_pop($stack);
+ $access_cache = ORM::factory("access_cache");
+ $access_cache->item_id = $id;
+ $access_cache->save();
+ $task->set("stack", implode(" ", $stack));
+ $completed++;
+ }
+
if (empty($stack)) {
- // The new cache rows are there, but they're incorrectly populated so we have to fix
- // them. If this turns out to be too slow, we'll have to refactor
- // access::recalculate_permissions to allow us to do it in slices.
- access::recalculate_album_permissions(item::root());
- $state = self::FIX_STATE_DONE;
+ // Try refilling the stack
+ foreach (self::find_missing_access_caches_limited(500) as $row) {
+ $stack[] = $row->id;
+ }
+ $task->set("stack", implode(" ", $stack));
+
+ if (empty($stack)) {
+ // The new cache rows are there, but they're incorrectly populated so we have to fix
+ // them. If this turns out to be too slow, we'll have to refactor
+ // access::recalculate_permissions to allow us to do it in slices.
+ access::recalculate_album_permissions(item::root());
+ $state = self::FIX_STATE_DONE;
+ }
}
break;
}
@@ -632,12 +681,27 @@ class gallery_task_Core {
->execute();
}
+ static function find_empty_item_caches($limit) {
+ return db::build()
+ ->select("items.id")
+ ->from("items")
+ ->where("relative_path_cache", "is", null)
+ ->or_where("relative_url_cache", "is", null)
+ ->limit($limit)
+ ->execute();
+ }
+
static function find_missing_access_caches() {
+ return self::find_missing_access_caches_limited(1 << 16);
+ }
+
+ static function find_missing_access_caches_limited($limit) {
return db::build()
->select("items.id")
->from("items")
->join("access_caches", "items.id", "access_caches.item_id", "left")
->where("access_caches.id", "is", null)
+ ->limit($limit)
->execute();
}
} \ No newline at end of file
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index 903dadad..931da382 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -806,7 +806,7 @@ class Item_Model_Core extends ORM_MPTT {
// Do not accept files with double extensions, they can cause problems on some
// versions of Apache.
- if (substr_count($this->name, ".") > 1) {
+ if (!$this->is_album() && substr_count($this->name, ".") > 1) {
$v->add_error("name", "illegal_data_file_extension");
}
diff --git a/modules/gallery/module.info b/modules/gallery/module.info
index 42345531..a905a241 100644
--- a/modules/gallery/module.info
+++ b/modules/gallery/module.info
@@ -1,6 +1,6 @@
name = "Gallery 3"
description = "Gallery core application"
-version = 49
+version = 50
author_name = "Gallery Team"
author_url = "http://codex.gallery2.org/Gallery:Team"
info_url = "http://codex.gallery2.org/Gallery3:Modules:gallery"
diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php
index 876fc137..8ae8a5dd 100644
--- a/modules/gallery/tests/Item_Model_Test.php
+++ b/modules/gallery/tests/Item_Model_Test.php
@@ -520,4 +520,10 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$this->assert_true(false, "Shouldn't get here");
}
}
+
+ public function albums_can_have_two_dots_in_name_test() {
+ $album = test::random_album_unsaved(item::root());
+ $album->name = $album->name . ".foo.bar";
+ $album->save();
+ }
}
diff --git a/modules/gallery/views/admin_advanced_settings.html.php b/modules/gallery/views/admin_advanced_settings.html.php
index 8d21d890..6745f0df 100644
--- a/modules/gallery/views/admin_advanced_settings.html.php
+++ b/modules/gallery/views/admin_advanced_settings.html.php
@@ -19,7 +19,7 @@
</tr>
<? foreach ($vars as $var): ?>
<tr class="setting-row <?= text::alternate("g-odd", "g-even") ?>">
- <td> <?= $var->module_name ?> </td>
+ <td> <?= html::clean($var->module_name) ?> </td>
<td> <?= html::clean($var->name) ?> </td>
<td>
<a href="<?= url::site("admin/advanced_settings/edit/$var->module_name/" . html::clean($var->name)) ?>"
diff --git a/modules/gallery/views/movieplayer.html.php b/modules/gallery/views/movieplayer.html.php
index 96d6532c..343eafe8 100644
--- a/modules/gallery/views/movieplayer.html.php
+++ b/modules/gallery/views/movieplayer.html.php
@@ -14,7 +14,7 @@
},
plugins: {
pseudostreaming: {
- url: "<?= url::abs_file("lib/flowplayer.pseudostreaming.swf") ?>"
+ url: "<?= url::abs_file("lib/flowplayer.pseudostreaming-byterange.swf") ?>"
},
controls: {
autoHide: 'always',
diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php
index d2757219..b54fbfb9 100644
--- a/modules/tag/helpers/tag_event.php
+++ b/modules/tag/helpers/tag_event.php
@@ -126,7 +126,8 @@ class tag_event_Core {
.gallery_autocomplete(
'$autocomplete_url',
{max: 30, multiple: true, multipleSeparator: ',', cacheLength: 1}
- )
+ );
+ $('input[name=tags]')
.change(function (event) {
$('#g-uploadify').uploadifySettings('scriptData', {'tags': $(this).val()});
});");