From 9b7542b9f1beb96f16123beebdd13728783f6dcd Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 21 Feb 2010 17:14:19 -0800 Subject: Add Menu::add_before() --- modules/gallery/libraries/Menu.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php index 7c76ab04..fef07916 100644 --- a/modules/gallery/libraries/Menu.php +++ b/modules/gallery/libraries/Menu.php @@ -184,7 +184,7 @@ class Menu_Core extends Menu_Element { } /** - * Add a new element to this menu + * Add a new element to this menu, after the specific element */ public function add_after($target_id, $new_menu_element) { $copy = array(); @@ -198,6 +198,21 @@ class Menu_Core extends Menu_Element { return $this; } + /** + * Add a new element to this menu, before the specific element + */ + public function add_before($target_id, $new_menu_element) { + $copy = array(); + foreach ($this->elements as $id => $menu_element) { + if ($id == $target_id) { + $copy[$new_menu_element->id] = $new_menu_element; + } + $copy[$id] = $menu_element; + } + $this->elements = $copy; + return $this; + } + /** * Remove an element from the menu */ -- cgit v1.2.3 From 5ddd7c9677b644396981de7df8176a3b168ffe21 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Sun, 21 Feb 2010 20:04:06 -0800 Subject: Fix Kohana's internal cache for Gallery's usage pattern. Adds a core.internal_cache_read_only config variable to Kohana's internals. Kohana's internal_cache for find_file wasn't working in Gallery because the cache would be emptied on each request after reading it from disk and before most lookups would run. 1. Bootstrap sets initial core.modules (= include path): forge, kohana23_compat, gallery. 2. Kohana::setup() loads find_file cache from disk. 3. Gallery loads list of active modules and themes, and updates the core.modules value (=include path), which forces the internal find_file cache to be empties (which makes sense). 4. Request processing starts, and thus 80% of all Kohana::find_file() triggered is_file() invocations start off with an empty find_file cache. In the case of my small Gallery installation, we're talking about 3100 is_file() invocations per request with or without internal_cache enabled. With this fix, this number is down to 800 invocations. The basic idea is that we treat the cache as read only and don't write any (possibly dirty) values to it in memory until we're sure that the include path won't change later on in the request processing. Once we know the list of active modules and themes, we can update core.modules and finally flip the read-only state of the cache and start writing to it. --- application/config/config.php | 6 ++++ modules/gallery/helpers/gallery_event.php | 1 + system/core/Kohana.php | 47 ++++++++++++++++++++----------- 3 files changed, 37 insertions(+), 17 deletions(-) (limited to 'modules') diff --git a/application/config/config.php b/application/config/config.php index aecc400c..1c5bccb7 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -67,6 +67,12 @@ $config["url_suffix"] = ""; * can give significant speed improvements at the expense of delayed updating. */ $config["internal_cache"] = FALSE; +/** + * Enable or disable writing to the internal cache. Used by Gallery to treat + * the cache as read-only until all active modules and themes are in the + * include path. + */ +$config["internal_cache_read_only"] = TRUE; $config["internal_cache_path"] = VARPATH . "tmp/"; /** diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 36f91142..a6783bc6 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -25,6 +25,7 @@ class gallery_event_Core { static function gallery_ready() { identity::load_user(); theme::load_themes(); + Kohana_Config::instance()->set('core.internal_cache_read_only', false); locales::set_request_locale(); } diff --git a/system/core/Kohana.php b/system/core/Kohana.php index ae056d0e..1ed6d725 100644 --- a/system/core/Kohana.php +++ b/system/core/Kohana.php @@ -365,13 +365,17 @@ abstract class Kohana_Core { // Add SYSPATH as the last path Kohana::$include_paths[] = SYSPATH; - // Clear cached include paths - self::$internal_cache['find_file_paths'] = array(); - if ( ! isset(self::$write_cache['find_file_paths'])) + if ( ! Kohana::config('core.internal_cache_read_only')) { - // Write cache at shutdown - self::$write_cache['find_file_paths'] = TRUE; - } + // Clear cached include paths + self::$internal_cache['find_file_paths'] = array(); + + if ( ! isset(self::$write_cache['find_file_paths'])) + { + // Write cache at shutdown + self::$write_cache['find_file_paths'] = TRUE; + } + } } @@ -818,13 +822,17 @@ abstract class Kohana_Core { } } - if ( ! isset(Kohana::$write_cache['find_file_paths'])) + if ( ! Kohana::config('core.internal_cache_read_only')) { - // Write cache at shutdown - Kohana::$write_cache['find_file_paths'] = TRUE; - } + Kohana::$internal_cache['find_file_paths'][$search] = $found; - return Kohana::$internal_cache['find_file_paths'][$search] = $found; + if ( ! isset(Kohana::$write_cache['find_file_paths'])) + { + // Write cache at shutdown + Kohana::$write_cache['find_file_paths'] = TRUE; + } + } + return $found; } /** @@ -900,8 +908,7 @@ abstract class Kohana_Core { public static function message($key, $args = array()) { // Extract the main group from the key - $group = explode('.', $key, 2); - $group = $group[0]; + list ($group, $subkey) = explode('.', $key, 2); if ( ! isset(Kohana::$internal_cache['messages'][$group])) { @@ -913,17 +920,23 @@ abstract class Kohana_Core { include $file[0]; } - if ( ! isset(Kohana::$write_cache['messages'])) + if ( ! isset(Kohana::$write_cache['messages']) && ! Kohana::config('core.internal_cache_read_only')) { // Write language cache Kohana::$write_cache['messages'] = TRUE; } - - Kohana::$internal_cache['messages'][$group] = $messages; + if ( ! Kohana::config('core.internal_cache_read_only')) + { + Kohana::$internal_cache['messages'][$group] = $messages; + } + } + else + { + $messages = Kohana::$internal_cache['messages'][$group]; } // Get the line from cache - $line = Kohana::key_string(Kohana::$internal_cache['messages'], $key); + $line = Kohana::key_string($messages, $subkey); if ($line === NULL) { -- cgit v1.2.3 From 6cbe0f78aa80a2810908a76ca163f1dfff2f0726 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Sun, 21 Feb 2010 21:07:55 -0800 Subject: Revert "Fix Kohana's internal cache for Gallery's usage pattern." This reverts commit 5ddd7c9677b644396981de7df8176a3b168ffe21. --- application/config/config.php | 6 ---- modules/gallery/helpers/gallery_event.php | 1 - system/core/Kohana.php | 47 +++++++++++-------------------- 3 files changed, 17 insertions(+), 37 deletions(-) (limited to 'modules') diff --git a/application/config/config.php b/application/config/config.php index 1c5bccb7..aecc400c 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -67,12 +67,6 @@ $config["url_suffix"] = ""; * can give significant speed improvements at the expense of delayed updating. */ $config["internal_cache"] = FALSE; -/** - * Enable or disable writing to the internal cache. Used by Gallery to treat - * the cache as read-only until all active modules and themes are in the - * include path. - */ -$config["internal_cache_read_only"] = TRUE; $config["internal_cache_path"] = VARPATH . "tmp/"; /** diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index a6783bc6..36f91142 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -25,7 +25,6 @@ class gallery_event_Core { static function gallery_ready() { identity::load_user(); theme::load_themes(); - Kohana_Config::instance()->set('core.internal_cache_read_only', false); locales::set_request_locale(); } diff --git a/system/core/Kohana.php b/system/core/Kohana.php index 1ed6d725..ae056d0e 100644 --- a/system/core/Kohana.php +++ b/system/core/Kohana.php @@ -365,17 +365,13 @@ abstract class Kohana_Core { // Add SYSPATH as the last path Kohana::$include_paths[] = SYSPATH; - if ( ! Kohana::config('core.internal_cache_read_only')) + // Clear cached include paths + self::$internal_cache['find_file_paths'] = array(); + if ( ! isset(self::$write_cache['find_file_paths'])) { - // Clear cached include paths - self::$internal_cache['find_file_paths'] = array(); - - if ( ! isset(self::$write_cache['find_file_paths'])) - { - // Write cache at shutdown - self::$write_cache['find_file_paths'] = TRUE; - } - } + // Write cache at shutdown + self::$write_cache['find_file_paths'] = TRUE; + } } @@ -822,17 +818,13 @@ abstract class Kohana_Core { } } - if ( ! Kohana::config('core.internal_cache_read_only')) + if ( ! isset(Kohana::$write_cache['find_file_paths'])) { - Kohana::$internal_cache['find_file_paths'][$search] = $found; - - if ( ! isset(Kohana::$write_cache['find_file_paths'])) - { - // Write cache at shutdown - Kohana::$write_cache['find_file_paths'] = TRUE; - } + // Write cache at shutdown + Kohana::$write_cache['find_file_paths'] = TRUE; } - return $found; + + return Kohana::$internal_cache['find_file_paths'][$search] = $found; } /** @@ -908,7 +900,8 @@ abstract class Kohana_Core { public static function message($key, $args = array()) { // Extract the main group from the key - list ($group, $subkey) = explode('.', $key, 2); + $group = explode('.', $key, 2); + $group = $group[0]; if ( ! isset(Kohana::$internal_cache['messages'][$group])) { @@ -920,23 +913,17 @@ abstract class Kohana_Core { include $file[0]; } - if ( ! isset(Kohana::$write_cache['messages']) && ! Kohana::config('core.internal_cache_read_only')) + if ( ! isset(Kohana::$write_cache['messages'])) { // Write language cache Kohana::$write_cache['messages'] = TRUE; } - if ( ! Kohana::config('core.internal_cache_read_only')) - { - Kohana::$internal_cache['messages'][$group] = $messages; - } - } - else - { - $messages = Kohana::$internal_cache['messages'][$group]; + + Kohana::$internal_cache['messages'][$group] = $messages; } // Get the line from cache - $line = Kohana::key_string($messages, $subkey); + $line = Kohana::key_string(Kohana::$internal_cache['messages'], $key); if ($line === NULL) { -- cgit v1.2.3 From 8e7eda9cc62c64e77fffabacae7441f8ea076c9d Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Sun, 21 Feb 2010 23:23:48 -0800 Subject: Fix progress bar / maintenance tasks for locales that use comma as decimal separator, such as German. --- modules/gallery/controllers/admin_maintenance.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/admin_maintenance.php b/modules/gallery/controllers/admin_maintenance.php index d90fe0ea..c16c5c41 100644 --- a/modules/gallery/controllers/admin_maintenance.php +++ b/modules/gallery/controllers/admin_maintenance.php @@ -209,9 +209,10 @@ class Admin_Maintenance_Controller extends Admin_Controller { message::success(t("Task failed")); break; } + // Using sprintf("%F") to avoid comma as decimal separator. print json_encode(array("result" => "success", "task" => array( - "percent_complete" => $task->percent_complete, + "percent_complete" => sprintf("%F", $task->percent_complete), "status" => (string) $task->status, "done" => (bool) $task->done), "location" => url::site("admin/maintenance"))); @@ -219,7 +220,7 @@ class Admin_Maintenance_Controller extends Admin_Controller { } else { print json_encode(array("result" => "in_progress", "task" => array( - "percent_complete" => $task->percent_complete, + "percent_complete" => sprintf("%F", $task->percent_complete), "status" => (string) $task->status, "done" => (bool) $task->done))); } -- cgit v1.2.3 From 6591ea25771f2ab31fea4bf3b7a6fd76c586e098 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Sun, 21 Feb 2010 23:48:23 -0800 Subject: Fix delete() function of DB based Cache driver. It expected a scalar key / tag value, but it was always an array of keys / tags. (compare to system/libraries/Cache.php and the File.php driver) --- modules/gallery/libraries/drivers/Cache/Database.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/gallery/libraries/drivers/Cache/Database.php b/modules/gallery/libraries/drivers/Cache/Database.php index 82a09ab9..085c5c35 100644 --- a/modules/gallery/libraries/drivers/Cache/Database.php +++ b/modules/gallery/libraries/drivers/Cache/Database.php @@ -153,15 +153,17 @@ class Cache_Database_Driver extends Cache_Driver { * @param bool delete a tag * @return bool */ - public function delete($id, $tag=false) { + public function delete($keys, $is_tag=false) { $db = db::build() ->delete("caches"); - if ($id === true) { + if ($keys === true) { // Delete all caches - } else if ($tag === true) { - $db->where("tags", "LIKE", "%<$id>%"); + } else if ($is_tag === true) { + foreach ($keys as $tag) { + $db->where("tags", "LIKE", "%<$tag>%"); + } } else { - $db->where("key", "=", $id); + $db->where("key", "IN", $keys); } $status = $db->execute(); -- cgit v1.2.3 From 334cd2368de24a76cd49681a14295350e85714d0 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Sun, 21 Feb 2010 23:50:01 -0800 Subject: Performance improvement: Load all translations of a locale as one serialized array from the Cache. Until now, we loaded hundreds of translation messages row by row, and unserializing one by one at bootstrap time. That amounted to a significant percentage of the complete request time. This approach is more than 10x faster. --- modules/gallery/controllers/l10n_client.php | 2 ++ modules/gallery/helpers/gallery_task.php | 2 ++ modules/gallery/libraries/Gallery_I18n.php | 45 ++++++++++++++++++++--------- 3 files changed, 36 insertions(+), 13 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/l10n_client.php b/modules/gallery/controllers/l10n_client.php index e20bab50..be0aaa11 100644 --- a/modules/gallery/controllers/l10n_client.php +++ b/modules/gallery/controllers/l10n_client.php @@ -80,6 +80,8 @@ class L10n_Client_Controller extends Controller { $entry->save(); + Gallery_I18n::clear_cache($locale); + print json_encode(new stdClass()); } diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php index 3e6278e5..617f7f48 100644 --- a/modules/gallery/helpers/gallery_task.php +++ b/modules/gallery/helpers/gallery_task.php @@ -201,6 +201,8 @@ class gallery_task_Core { $total = $num_fetched + $num_remaining; $task->percent_complete = 70 + 30 * ((float) $num_fetched / $total); } else { + Gallery_I18n::clear_cache(); + $task->done = true; $task->state = "success"; $task->status = t("Translations installed/updated"); diff --git a/modules/gallery/libraries/Gallery_I18n.php b/modules/gallery/libraries/Gallery_I18n.php index ac0588e3..0e9c0bdc 100644 --- a/modules/gallery/libraries/Gallery_I18n.php +++ b/modules/gallery/libraries/Gallery_I18n.php @@ -150,33 +150,43 @@ class Gallery_I18n_Core { private function lookup($locale, $message) { if (!isset($this->_cache[$locale])) { - $this->_cache[$locale] = array(); - // TODO: Load data from locale file instead of the DB. + $this->_cache[$locale] = self::load_translations($locale); + } + + $key = self::get_message_key($message); + + if (isset($this->_cache[$locale][$key])) { + return $this->_cache[$locale][$key]; + } else { + return null; + } + } + + private static function load_translations($locale) { + $cache_key = "translation|" . $locale; + $cache = Cache::instance(); + $translations = $cache->get($cache_key); + if (empty($translations)) { foreach (db::build() ->select("key", "translation") ->from("incoming_translations") ->where("locale", "=", $locale) ->execute() as $row) { - $this->_cache[$locale][$row->key] = unserialize($row->translation); + $translations[$row->key] = unserialize($row->translation); } - + // Override incoming with outgoing... foreach (db::build() ->select("key", "translation") ->from("outgoing_translations") ->where("locale", "=", $locale) ->execute() as $row) { - $this->_cache[$locale][$row->key] = unserialize($row->translation); + $translations[$row->key] = unserialize($row->translation); } + + $cache->set($cache_key, $translations, array("translation"), 0); } - - $key = self::get_message_key($message); - - if (isset($this->_cache[$locale][$key])) { - return $this->_cache[$locale][$key]; - } else { - return null; - } + return $translations; } public function has_translation($message, $options=null) { @@ -256,6 +266,15 @@ class Gallery_I18n_Core { return $this->_call_log; } + public static function clear_cache($locale=null) { + $cache = Cache::instance(); + if ($locale) { + $cache->delete("translation|" . $locale); + } else { + $cache->delete_tag("translation"); + } + } + private static function get_plural_key($locale, $count) { $parts = explode('_', $locale); $language = $parts[0]; -- cgit v1.2.3 From 6ce01328422cc587dedf555d0ba3eb8a0ee05a9f Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Mon, 22 Feb 2010 00:30:54 -0800 Subject: Fix for ticket #1027: Add index on cache key column. (and fix the packager to truncate the cache table before packaging) --- installer/install.sql | 3 ++- modules/gallery/controllers/packager.php | 1 + modules/gallery/helpers/gallery_installer.php | 12 +++++++++++- modules/gallery/module.info | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/installer/install.sql b/installer/install.sql index 28a9caa5..ebe3651d 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -42,6 +42,7 @@ CREATE TABLE {caches} ( `expiration` int(9) NOT NULL, `cache` longblob, PRIMARY KEY (`id`), + KEY `key` (`key`), KEY `tags` (`tags`) ) DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; @@ -239,7 +240,7 @@ CREATE TABLE {modules} ( UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=10 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -INSERT INTO {modules} VALUES (1,1,'gallery',29); +INSERT INTO {modules} VALUES (1,1,'gallery',30); INSERT INTO {modules} VALUES (2,1,'user',3); INSERT INTO {modules} VALUES (3,1,'comment',2); INSERT INTO {modules} VALUES (4,1,'organize',1); diff --git a/modules/gallery/controllers/packager.php b/modules/gallery/controllers/packager.php index 66626483..aef032a0 100644 --- a/modules/gallery/controllers/packager.php +++ b/modules/gallery/controllers/packager.php @@ -82,6 +82,7 @@ class Packager_Controller extends Controller { module::set_var("gallery", "blocks_{$key}", serialize($blocks)); } + Database::instance()->query("TRUNCATE {caches}"); Database::instance()->query("TRUNCATE {sessions}"); Database::instance()->query("TRUNCATE {logs}"); db::build() diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index b594ddcf..6f8a6688 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -32,6 +32,10 @@ class gallery_installer { PRIMARY KEY (`id`)) DEFAULT CHARSET=utf8;"); + // Using a simple index instead of a unique key for the + // key column to avoid handling of concurrency issues + // on insert. Thus allowing concurrent inserts on the + // same cache key, as does Memcache / xcache. $db->query("CREATE TABLE {caches} ( `id` int(9) NOT NULL auto_increment, `key` varchar(255) NOT NULL, @@ -39,6 +43,7 @@ class gallery_installer { `expiration` int(9) NOT NULL, `cache` longblob, PRIMARY KEY (`id`), + KEY (`key`), KEY (`tags`)) DEFAULT CHARSET=utf8;"); @@ -290,7 +295,7 @@ class gallery_installer { module::set_var("gallery", "credits", (string) $powered_by_string); module::set_var("gallery", "simultaneous_upload_limit", 5); module::set_var("gallery", "admin_area_timeout", 90 * 60); - module::set_version("gallery", 29); + module::set_version("gallery", 30); } static function upgrade($version) { @@ -545,6 +550,11 @@ class gallery_installer { module::set_var("gallery", "credits", "Powered by %gallery_version"); module::set_version("gallery", $version = 29); } + + if ($version == 29) { + $db->query("ALTER TABLE {caches} ADD KEY (`key`);"); + module::set_version("gallery", $version = 30); + } } static function uninstall() { diff --git a/modules/gallery/module.info b/modules/gallery/module.info index 39615e1c..df2be978 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ name = "Gallery 3" description = "Gallery core application" -version = 29 +version = 30 -- cgit v1.2.3 From f7b39e7db71058c89ada225aac43d9c7b24377da Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Mon, 22 Feb 2010 12:31:46 -0800 Subject: Fix server-add for German and other locales that use comma as decimal separator. --- modules/server_add/controllers/server_add.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index f68335df..4cdaa275 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -109,9 +109,11 @@ class Server_Add_Controller extends Admin_Controller { } $task = task::run($task_id); + // Prevent the JavaScript code from breaking by forcing a period as + // decimal separator for all locales with sprintf("%F", $value). print json_encode(array("done" => (bool)$task->done, "status" => $task->status, - "percent_complete" => $task->percent_complete)); + "percent_complete" => sprintf("%F", $task->percent_complete))); } /** -- cgit v1.2.3 From a9f8b9479379dac14128114f35991a8a51d281ae Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 22 Feb 2010 21:08:59 -0800 Subject: Fix cut/paste typo --- modules/g2_import/views/admin_g2_import.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/g2_import/views/admin_g2_import.html.php b/modules/g2_import/views/admin_g2_import.html.php index 5c520172..05cbab71 100644 --- a/modules/g2_import/views/admin_g2_import.html.php +++ b/modules/g2_import/views/admin_g2_import.html.php @@ -47,7 +47,7 @@
  • - Using the same value will speed up your import.", + Using the same value will speed up your import.", array("g2_pixels" => $g2_sizes["resize"]["size"], "g3_pixels" => $resize_size, "url" => html::mark_clean(url::site("admin/theme_options")))) ?> -- cgit v1.2.3 From ce39dc768c63fa5631450918180c1602363b7810 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 22 Feb 2010 21:21:04 -0800 Subject: Normalize invalid/missing G2 email addresses --- modules/g2_import/helpers/g2_import.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index faf08291..9a91770a 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -304,20 +304,27 @@ class g2_import_Core { if ($user) { $message = t("Loaded existing user: '%name'.", array("name" => $user->name)); } else { + $email = $g2_user->getEmail(); + if (empty($email) || !valid::email($email)) { + $email = "unknown@unknown.com"; + } $user = identity::create_user($g2_user->getUsername(), $g2_user->getfullname(), // Note: The API expects a password in cleartext. // Just use the hashed password as an unpredictable // value here. The user will have to reset the password. - $g2_user->getHashedPassword(), $g2_user->getEmail()); + $g2_user->getHashedPassword(), $email); if (class_exists("User_Model") && $user instanceof User_Model) { // This will work if G2's password is a PasswordHash password as well. $user->hashed_password = $g2_user->getHashedPassword(); } $message = t("Created user: '%name'.", array("name" => $user->name)); + if ($email == "unknown@unknown.com") { + $message .= t("\n\tFixed invalid email (was '%invalid_email')", + array("invalid_email" => $g2_user->getEmail())); + } } $user->hashed_password = $g2_user->getHashedPassword(); - $user->email = $g2_user->getEmail() ? $g2_user->getEmail() : "unknown@unknown.com"; $user->locale = $g2_user->getLanguage(); foreach ($g2_groups as $g2_group_id => $g2_group_name) { if ($g2_group_id == $g2_admin_group_id) { -- cgit v1.2.3 From adb1db6b7d1d10772b893047d8297a89ca9c615e Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Mon, 22 Feb 2010 22:00:23 -0800 Subject: Fix typo in selector expression. The handling of view-only albums is still not great, but at least the code is closer to doing what it's supposed to. --- modules/organize/js/organize.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js index 5b90f402..5a483caf 100644 --- a/modules/organize/js/organize.js +++ b/modules/organize/js/organize.js @@ -270,7 +270,7 @@ if ($(event.currentTarget).hasClass("ui-state-focus")) { return; } - var parent = $(event.currentTarget).parents(".g-organize-branch"); + var parent = $(event.currentTarget).parents(".g-organize-album"); if ($(parent).hasClass("g-view-only")) { return; } -- cgit v1.2.3 From 6afc5ccf5c5d70b3aef4024f892141a07779c25f Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Tue, 23 Feb 2010 10:02:27 -0800 Subject: Fix translation cache for installations with 0 translations in the DB. --- modules/gallery/libraries/Gallery_I18n.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/libraries/Gallery_I18n.php b/modules/gallery/libraries/Gallery_I18n.php index 0e9c0bdc..f1e77744 100644 --- a/modules/gallery/libraries/Gallery_I18n.php +++ b/modules/gallery/libraries/Gallery_I18n.php @@ -166,7 +166,8 @@ class Gallery_I18n_Core { $cache_key = "translation|" . $locale; $cache = Cache::instance(); $translations = $cache->get($cache_key); - if (empty($translations)) { + if (!isset($translations) || !is_array($translations)) { + $translations = array(); foreach (db::build() ->select("key", "translation") ->from("incoming_translations") -- cgit v1.2.3 From fb5503be09047def6efd24a74188ad55af7a80f2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 23 Feb 2010 11:10:32 -0800 Subject: Name this release "Santa Fe". Fixes ticket #683. --- modules/gallery/helpers/gallery.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index 84f8a7fb..a43b180b 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class gallery_Core { - const VERSION = "3.0 git (pre-RC1)"; + const VERSION = "3.0 RC1 (Santa Fe)"; /** * If Gallery is in maintenance mode, then force all non-admins to get routed to a "This site is -- cgit v1.2.3 From 8ab580cec1909fb93ba01fb635e1392a76317623 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 23 Feb 2010 11:50:39 -0800 Subject: Verified --- modules/gallery/tests/xss_data.txt | 41 +++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 23 deletions(-) (limited to 'modules') diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index 44233459..a3ca31f4 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -218,8 +218,8 @@ modules/gallery/views/upgrader.html.php 77 DIRTY $modul modules/gallery/views/upgrader.html.php 99 DIRTY_ATTR $done?"muted":"" modules/gallery/views/upgrader.html.php 102 DIRTY_ATTR $done?"muted":"" modules/gallery/views/user_languages_block.html.php 2 DIRTY form::dropdown("g-select-session-locale",$installed_locales,$selected) -modules/gallery/views/user_profile.html.php 36 DIRTY_ATTR $user->avatar_url(40,$theme->url(,true)) -modules/gallery/views/user_profile.html.php 47 DIRTY $info->view +modules/gallery/views/user_profile.html.php 34 DIRTY_ATTR $user->avatar_url(40,$theme->url(,true)) +modules/gallery/views/user_profile.html.php 43 DIRTY $info->view modules/image_block/views/image_block_block.html.php 3 DIRTY_JS $item->url() modules/image_block/views/image_block_block.html.php 4 DIRTY $item->thumb_img(array("class"=>"g-thumbnail")) modules/info/views/info_block.html.php 22 DIRTY date("M j, Y H:i:s",$item->captured) @@ -250,11 +250,11 @@ modules/organize/views/organize_tree.html.php 2 DIRTY_ATTR acce modules/organize/views/organize_tree.html.php 3 DIRTY_ATTR $album->id modules/organize/views/organize_tree.html.php 6 DIRTY_ATTR $selected&&$album->id==$selected->id?"ui-state-focus":"" modules/organize/views/organize_tree.html.php 7 DIRTY_ATTR $album->id -modules/organize/views/organize_tree.html.php 13 DIRTY View::factory("organize_tree.html",array("selected"=>$selected,"album"=>$child)); -modules/organize/views/organize_tree.html.php 15 DIRTY_ATTR access::can("edit",$child)?"":"g-view-only" -modules/organize/views/organize_tree.html.php 16 DIRTY_ATTR $child->id -modules/organize/views/organize_tree.html.php 18 DIRTY_ATTR $selected&&$child->id==$selected->id?"ui-state-focus":"" +modules/organize/views/organize_tree.html.php 15 DIRTY View::factory("organize_tree.html",array("selected"=>$selected,"album"=>$child)); +modules/organize/views/organize_tree.html.php 17 DIRTY_ATTR access::can("edit",$child)?"":"g-view-only" modules/organize/views/organize_tree.html.php 18 DIRTY_ATTR $child->id +modules/organize/views/organize_tree.html.php 20 DIRTY_ATTR $selected&&$child->id==$selected->id?"ui-state-focus":"" +modules/organize/views/organize_tree.html.php 20 DIRTY_ATTR $child->id modules/recaptcha/views/admin_recaptcha.html.php 11 DIRTY $form modules/recaptcha/views/admin_recaptcha.html.php 23 DIRTY_JS $public_key modules/recaptcha/views/form_recaptcha.html.php 7 DIRTY_JS $public_key @@ -274,21 +274,16 @@ modules/rss/views/feed.mrss.php 42 DIRTY_ATTR $chi modules/rss/views/feed.mrss.php 48 DIRTY_ATTR $child->thumb_url(true) modules/rss/views/feed.mrss.php 49 DIRTY_ATTR $child->thumb_height modules/rss/views/feed.mrss.php 50 DIRTY_ATTR $child->thumb_width -modules/rss/views/feed.mrss.php 54 DIRTY_ATTR $child->resize_url(true) -modules/rss/views/feed.mrss.php 55 DIRTY_ATTR @filesize($child->resize_path()) -modules/rss/views/feed.mrss.php 56 DIRTY_ATTR $child->mime_type -modules/rss/views/feed.mrss.php 57 DIRTY_ATTR $child->resize_height -modules/rss/views/feed.mrss.php 58 DIRTY_ATTR $child->resize_width -modules/rss/views/feed.mrss.php 61 DIRTY_ATTR $child->file_url(true) -modules/rss/views/feed.mrss.php 62 DIRTY_ATTR @filesize($child->file_path()) -modules/rss/views/feed.mrss.php 63 DIRTY_ATTR $child->mime_type -modules/rss/views/feed.mrss.php 64 DIRTY_ATTR $child->height -modules/rss/views/feed.mrss.php 65 DIRTY_ATTR $child->width -modules/rss/views/feed.mrss.php 70 DIRTY_ATTR $child->file_url(true) -modules/rss/views/feed.mrss.php 71 DIRTY_ATTR @filesize($child->file_path()) -modules/rss/views/feed.mrss.php 72 DIRTY_ATTR $child->height -modules/rss/views/feed.mrss.php 73 DIRTY_ATTR $child->width -modules/rss/views/feed.mrss.php 74 DIRTY_ATTR $child->mime_type +modules/rss/views/feed.mrss.php 57 DIRTY_ATTR $child->resize_url(true) +modules/rss/views/feed.mrss.php 58 DIRTY_ATTR @filesize($child->resize_path()) +modules/rss/views/feed.mrss.php 59 DIRTY_ATTR $child->mime_type +modules/rss/views/feed.mrss.php 60 DIRTY_ATTR $child->resize_height +modules/rss/views/feed.mrss.php 61 DIRTY_ATTR $child->resize_width +modules/rss/views/feed.mrss.php 65 DIRTY_ATTR $child->file_url(true) +modules/rss/views/feed.mrss.php 66 DIRTY_ATTR @filesize($child->file_path()) +modules/rss/views/feed.mrss.php 67 DIRTY_ATTR $child->mime_type +modules/rss/views/feed.mrss.php 68 DIRTY_ATTR $child->height +modules/rss/views/feed.mrss.php 69 DIRTY_ATTR $child->width modules/rss/views/rss_block.html.php 6 DIRTY_JS rss::url($url) modules/search/views/search.html.php 27 DIRTY_ATTR $item_class modules/search/views/search.html.php 28 DIRTY_JS $item->url() @@ -320,8 +315,8 @@ modules/user/views/admin_users.html.php 87 DIRTY ($user modules/user/views/admin_users.html.php 123 DIRTY_ATTR $group->id modules/user/views/admin_users.html.php 123 DIRTY_ATTR ($group->special?"g-default-group":"") modules/user/views/admin_users.html.php 125 DIRTY $v -modules/user/views/admin_users_group.html.php 22 DIRTY_JS $user->id -modules/user/views/admin_users_group.html.php 22 DIRTY_JS $group->id +modules/user/views/admin_users_group.html.php 24 DIRTY_JS $user->id +modules/user/views/admin_users_group.html.php 24 DIRTY_JS $group->id modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $width modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $height modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $url -- cgit v1.2.3 From 212da35cdc5c68ad06ff2f0e5d820ccbcf328a89 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Tue, 23 Feb 2010 12:48:03 -0800 Subject: Fix Cache tests for recent Cache/Database.php driver fix. Cache::delete($arg) allows for scalars and arrays, but Cache drivers' delete($arg) function always expects an array. --- modules/gallery/tests/Cache_Test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/tests/Cache_Test.php b/modules/gallery/tests/Cache_Test.php index 1023568b..a942a292 100644 --- a/modules/gallery/tests/Cache_Test.php +++ b/modules/gallery/tests/Cache_Test.php @@ -118,7 +118,7 @@ class Cache_Test extends Gallery_Unit_Test_Case { $value3 = array("field5" => "value5", "field6" => "value6"); $this->_driver->set(array($id3 => $value3), array("tag3", "tag4"), 84600); - $this->_driver->delete($id1); + $this->_driver->delete(array($id1)); $this->assert_false($this->_driver->exists($id1), "$id1 should have been deleted"); $this->assert_true($this->_driver->exists($id2), "$id2 should not have been deleted"); @@ -138,7 +138,7 @@ class Cache_Test extends Gallery_Unit_Test_Case { $value3 = array("field5" => "value5", "field6" => "value6"); $this->_driver->set(array($id3 => $value3), array("tag3", "tag4"), 84600); - $data = $this->_driver->delete("tag3", true); + $data = $this->_driver->delete_tag(array("tag3")); $this->assert_true($this->_driver->exists($id1), "$id1 should not have been deleted"); $this->assert_false($this->_driver->exists($id2), "$id2 should have been deleted"); -- cgit v1.2.3 From d4423eb34970f0068af463ebea17a748910ca835 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 23 Feb 2010 13:50:57 -0800 Subject: Reset the active user to admin in all test cases where we change the user to something else. --- modules/comment/tests/Comment_Model_Test.php | 3 +++ modules/gallery/tests/Access_Helper_Test.php | 9 +++++---- modules/gallery/tests/Item_Helper_Test.php | 3 +-- modules/gallery/tests/Item_Rest_Helper_Test.php | 4 ++++ modules/tag/tests/Tags_Rest_Helper_Test.php | 4 ++++ 5 files changed, 17 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/comment/tests/Comment_Model_Test.php b/modules/comment/tests/Comment_Model_Test.php index f0449c05..798e4f6d 100644 --- a/modules/comment/tests/Comment_Model_Test.php +++ b/modules/comment/tests/Comment_Model_Test.php @@ -18,6 +18,9 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Comment_Model_Test extends Gallery_Unit_Test_Case { + public function teardown() { + identity::set_active_user(identity::admin_user()); + } public function cant_view_comments_for_unviewable_items_test() { $album = test::random_album(); diff --git a/modules/gallery/tests/Access_Helper_Test.php b/modules/gallery/tests/Access_Helper_Test.php index 5331117d..6eca396c 100644 --- a/modules/gallery/tests/Access_Helper_Test.php +++ b/modules/gallery/tests/Access_Helper_Test.php @@ -20,6 +20,10 @@ class Access_Helper_Test extends Gallery_Unit_Test_Case { private $_group; + public function setup() { + identity::set_active_user(identity::guest()); + } + public function teardown() { try { $group = identity::lookup_group_by_name("access_test"); @@ -41,10 +45,7 @@ class Access_Helper_Test extends Gallery_Unit_Test_Case { // Reset some permissions that we mangle below access::allow(identity::everybody(), "view", item::root()); - } - - public function setup() { - identity::set_active_user(identity::guest()); + identity::set_active_user(identity::admin_user()); } public function groups_and_permissions_are_bound_to_columns_test() { diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php index 50587702..90106562 100644 --- a/modules/gallery/tests/Item_Helper_Test.php +++ b/modules/gallery/tests/Item_Helper_Test.php @@ -18,8 +18,7 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Item_Helper_Test extends Gallery_Unit_Test_Case { - - public function setup() { + public function teardown() { identity::set_active_user(identity::admin_user()); } diff --git a/modules/gallery/tests/Item_Rest_Helper_Test.php b/modules/gallery/tests/Item_Rest_Helper_Test.php index 6d1dd864..7b86c153 100644 --- a/modules/gallery/tests/Item_Rest_Helper_Test.php +++ b/modules/gallery/tests/Item_Rest_Helper_Test.php @@ -18,6 +18,10 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Item_Rest_Helper_Test extends Gallery_Unit_Test_Case { + public function teardown() { + identity::set_active_user(identity::admin_user()); + } + public function resolve_test() { $album = test::random_album(); $resolved = rest::resolve(rest::url("item", $album)); diff --git a/modules/tag/tests/Tags_Rest_Helper_Test.php b/modules/tag/tests/Tags_Rest_Helper_Test.php index cdf7bfdf..dbad0b02 100644 --- a/modules/tag/tests/Tags_Rest_Helper_Test.php +++ b/modules/tag/tests/Tags_Rest_Helper_Test.php @@ -26,6 +26,10 @@ class Tags_Rest_Helper_Test extends Gallery_Unit_Test_Case { } } + public function teardown() { + identity::set_active_user(identity::admin_user()); + } + public function get_test() { $t1 = tag::add(item::root(), "t1"); $t2 = tag::add(item::root(), "t2"); -- cgit v1.2.3 From 1d8862d957e8f08552d448cd17b3c00c61b7fc05 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Wed, 24 Feb 2010 01:28:38 -0800 Subject: Fix for ticket #1034: Fix db cache driver delete() call which was missed in a recent refactoring / fix. --- modules/gallery/libraries/drivers/Cache/Database.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/libraries/drivers/Cache/Database.php b/modules/gallery/libraries/drivers/Cache/Database.php index 085c5c35..ff982396 100644 --- a/modules/gallery/libraries/drivers/Cache/Database.php +++ b/modules/gallery/libraries/drivers/Cache/Database.php @@ -130,7 +130,7 @@ class Cache_Database_Driver extends Cache_Driver { // Make sure the expiration is valid and that the hash matches if ($cache->expiration != 0 && $cache->expiration <= time()) { // Cache is not valid, delete it now - $this->delete($cache->id); + $this->delete(array($cache->id)); } else { // Disable notices for unserializing $ER = error_reporting(~E_NOTICE); -- cgit v1.2.3 From 7d7da6eb0a953c61ceb424d9837f850ca2c8b0ce Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 24 Feb 2010 11:49:53 -0800 Subject: Remove redundant print statement. rest::reply() does the print so having the extra print statement could lead to problems. --- modules/rest/controllers/rest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/rest/controllers/rest.php b/modules/rest/controllers/rest.php index 7cdd97c9..b8d9a889 100644 --- a/modules/rest/controllers/rest.php +++ b/modules/rest/controllers/rest.php @@ -68,7 +68,7 @@ class Rest_Controller extends Controller { } try { - print rest::reply(call_user_func(array($handler_class, $handler_method), $request)); + rest::reply(call_user_func(array($handler_class, $handler_method), $request)); } catch (ORM_Validation_Exception $e) { foreach ($e->validation->errors() as $key => $value) { $msgs[] = "$key: $value"; -- cgit v1.2.3 From c38bee203b8e89cfb1446ecacd133f3c679ffbcc Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Wed, 24 Feb 2010 16:21:54 -0800 Subject: Add Faroese to the language list. Verified that it uses the default plural rules, thus no changes in Gallery_I18n.php or on the server side required. --- modules/gallery/helpers/locales.php | 1 + 1 file changed, 1 insertion(+) (limited to 'modules') diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php index e72d7ed9..62b08fb9 100644 --- a/modules/gallery/helpers/locales.php +++ b/modules/gallery/helpers/locales.php @@ -81,6 +81,7 @@ class locales_Core { $l["eu_ES"] = "Euskara"; // Basque $l["fa_IR"] = "فارس"; // Farsi $l["fi_FI"] = "Suomi"; // Finnish + $l["fo_FO"] = "Føroyskt"; // Faroese $l["fr_FR"] = "Français"; // French $l["ga_IE"] = "Gaeilge"; // Irish $l["he_IL"] = "עברית"; // Hebrew -- cgit v1.2.3 From 39b8810c3b37538e015c9d8cb7b46c59d87fb8c7 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Wed, 24 Feb 2010 16:39:18 -0800 Subject: Fix multi-column layout of language admin. --- modules/gallery/views/admin_languages.html.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/gallery/views/admin_languages.html.php b/modules/gallery/views/admin_languages.html.php index 07134475..d4b7b0c1 100644 --- a/modules/gallery/views/admin_languages.html.php +++ b/modules/gallery/views/admin_languages.html.php @@ -49,13 +49,14 @@ $display_name): ?> - - - - - - - + +
    + + + + + + "> -- cgit v1.2.3 From ed0f93a965bc2640411edaf2054791037ad36ed3 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Thu, 25 Feb 2010 18:26:20 -0800 Subject: Fix typo, thanks cajun100 for reporting! --- modules/server_add/views/admin_server_add.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/server_add/views/admin_server_add.html.php b/modules/server_add/views/admin_server_add.html.php index 6dbb8637..933ab7f8 100644 --- a/modules/server_add/views/admin_server_add.html.php +++ b/modules/server_add/views/admin_server_add.html.php @@ -1,6 +1,6 @@
    -

    +

    -- cgit v1.2.3