From 80e9fcaf47af6a041db385f18b0be00c15708da7 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 1 Sep 2010 22:00:26 -0700 Subject: Don't use $.remove() to get rid of items from the uploadify queue; that breaks uploadify and causes it to be unable to upload any new items. Fixes ticket #1324. --- modules/gallery/views/form_uploadify.html.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'modules/gallery/views') diff --git a/modules/gallery/views/form_uploadify.html.php b/modules/gallery/views/form_uploadify.html.php index 36f5f284..893bb3b9 100644 --- a/modules/gallery/views/form_uploadify.html.php +++ b/modules/gallery/views/form_uploadify.html.php @@ -60,7 +60,7 @@ $("#g-add-photos-status ul").append( "
  • " + fileObj.name + " - " + for_js() ?> + "
  • "); - setTimeout(function() { $("#q" + queueID).slideUp("slow") }, 5000); + setTimeout(function() { $("#q" + queueID).slideUp("slow").remove() }, 5000); success_count++; update_status(); return true; @@ -87,8 +87,8 @@ .replace("__TYPE__", errorObj.type)); } $("#g-add-photos-status ul").append( - "
  • " + fileObj.name + msg + "
  • "); - $("#g-uploadify" + queueID).remove(); + "
  • " + fileObj.name + msg + "
  • "); + $("#g-uploadify").uploadifyCancel(queueID); error_count++; update_status(); }, -- cgit v1.2.3 From fc856b6abaa24d27cba5273147da11fc2446c1ba Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 6 Sep 2010 14:08:05 -0700 Subject: Add retry logic to the task framework. We retry 4 times with increasing backoff and if that fails, we put up a manual "retry" link. Fixes ticket #1270. --- .../gallery/views/admin_maintenance_task.html.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'modules/gallery/views') diff --git a/modules/gallery/views/admin_maintenance_task.html.php b/modules/gallery/views/admin_maintenance_task.html.php index 76756b66..013ac01f 100644 --- a/modules/gallery/views/admin_maintenance_task.html.php +++ b/modules/gallery/views/admin_maintenance_task.html.php @@ -3,6 +3,7 @@ var target_value; var animation = null; var delta = 1; + var consecutive_error_count = 0; animate_progress_bar = function() { var current_value = parseInt($(".g-progress-bar div").css("width").replace("%", "")); if (target_value > current_value) { @@ -26,12 +27,15 @@ $.fn.gallery_hover_init(); } + var FAILED_MSG = Retry or check the task log for details")->for_js() ?>; + var ERROR_MSG = for_js() ?>; update = function() { $.ajax({ url: id?csrf=$csrf")) ?>, dataType: "json", success: function(data) { target_value = data.task.percent_complete; + consecutive_error_count = 0; if (!animation) { animate_progress_bar(); } @@ -42,6 +46,22 @@ } else { setTimeout(update, 100); } + }, + error: function(req, textStatus, errorThrown) { + if (textStatus == "timeout" || textStatus == "parsererror") { + consecutive_error_count++; + if (consecutive_error_count == 5) { + $("#g-status").html(FAILED_MSG); + $("#g-pause-button").hide(); + $("#g-done-button").show(); + consecutive_error_count = 0; // in case of a manual retry + $("#g-status a").attr("href", "javascript:update()"); + } else { + $("#g-status").html(ERROR_MSG.replace("__COUNT__", consecutive_error_count)); + // Give a little time to back off before retrying + setTimeout(update, 1500 * consecutive_error_count); + } + } } }); } -- cgit v1.2.3 From cb22f23be64096234197cdb1c97d7a42ba504aa4 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 6 Sep 2010 14:16:26 -0700 Subject: Show the "view log" button for tasks that are running, in case they're paused/abandoned for some reason and we want to know more details. --- modules/gallery/views/admin_maintenance.html.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'modules/gallery/views') diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php index 4bfc57f0..c28def1d 100644 --- a/modules/gallery/views/admin_maintenance.html.php +++ b/modules/gallery/views/admin_maintenance.html.php @@ -109,16 +109,21 @@ owner()->name) ?> - id?csrf=$csrf") ?>" - class="g-button g-right ui-icon-left ui-state-default ui-corner-all"> - - state == "stalled"): ?> id?csrf=$csrf") ?>"> + get_log()): ?> + id?csrf=$csrf") ?>" class="g-dialog-link g-button ui-state-default ui-corner-all"> + + + + id?csrf=$csrf") ?>" + class="g-button ui-icon-left ui-state-default ui-corner-all"> + + @@ -183,7 +188,7 @@ get_log()): ?> id?csrf=$csrf") ?>" class="g-dialog-link g-button ui-state-default ui-corner-all"> - + -- cgit v1.2.3 From 391a90e3cedd1cca7631f9a4d786c6c513b1dd48 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 8 Sep 2010 20:36:22 -0700 Subject: Detect when a module fails to upgrade properly and put up an informative message to help the user know that she needs to get a newer copy of the module. Fixes ticket #1189. --- modules/gallery/controllers/upgrader.php | 12 ++++++-- modules/gallery/css/upgrader.css | 28 +++++++++++++++++ modules/gallery/helpers/module.php | 6 +++- modules/gallery/views/upgrader.html.php | 53 ++++++++++++++++++++++---------- 4 files changed, 79 insertions(+), 20 deletions(-) (limited to 'modules/gallery/views') diff --git a/modules/gallery/controllers/upgrader.php b/modules/gallery/controllers/upgrader.php index cb940b46..a3cfac48 100644 --- a/modules/gallery/controllers/upgrader.php +++ b/modules/gallery/controllers/upgrader.php @@ -39,10 +39,12 @@ class Upgrader_Controller extends Controller { } } + $failed = Input::instance()->get("failed"); $view = new View("upgrader.html"); $view->can_upgrade = identity::active_user()->admin || $session->get("can_upgrade"); $view->upgrade_token = $upgrade_token; $view->available = module::available(); + $view->failed = $failed ? explode(",", $failed) : array(); $view->done = $available_upgrades == 0; print $view; } @@ -65,20 +67,26 @@ class Upgrader_Controller extends Controller { } // Then upgrade the rest + $failed = array(); foreach (module::available() as $id => $module) { if ($id == "gallery") { continue; } if ($module->active && $module->code_version != $module->version) { - module::upgrade($id); + try { + module::upgrade($id); + } catch (Exception $e) { + // @todo assume it's MODULE_FAILED_TO_UPGRADE for now + $failed[] = $id; + } } } if (php_sapi_name() == "cli") { print "Upgrade complete\n"; } else { - url::redirect("upgrader"); + url::redirect("upgrader?failed=" . join(",", $failed)); } } } diff --git a/modules/gallery/css/upgrader.css b/modules/gallery/css/upgrader.css index d1b74c31..8610016e 100644 --- a/modules/gallery/css/upgrader.css +++ b/modules/gallery/css/upgrader.css @@ -58,6 +58,10 @@ tr.upgradeable td.gallery { color: #00d; } +tr.failed td { + color: red; +} + p { font-size: .9em; } @@ -120,12 +124,28 @@ div#dialog div { opacity: 0.5; } +.failed { + color: red; +} + pre { display: inline; margin: 0px; padding: 0px; } +div#upgrade_button { + margin-bottom: 20px; +} + +div#welcome_message { + margin-left: 30px; +} + +#logo { + margin-left: 14px; +} + .rtl { direction: rtl; } @@ -153,3 +173,11 @@ pre { .rtl div#dialog a.close { float: left; } + +.rtl div#welcome_message { + padding-right: 30px; +} + +.rtl #logo { + padding-right: 12px; +} diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index e3fb8684..be9c4249 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -214,10 +214,10 @@ class module_Core { static function upgrade($module_name) { $version_before = module::get_version($module_name); $installer_class = "{$module_name}_installer"; + $available = module::available(); if (method_exists($installer_class, "upgrade")) { call_user_func_array(array($installer_class, "upgrade"), array($version_before)); } else { - $available = module::available(); if (isset($available->$module_name->code_version)) { module::set_version($module_name, $available->$module_name->code_version); } else { @@ -234,6 +234,10 @@ class module_Core { "version_before" => $version_before, "version_after" => $version_after))); } + + if ($version_after != $available->$module_name->code_version) { + throw new Exception("@todo MODULE_FAILED_TO_UPGRADE"); + } } /** diff --git a/modules/gallery/views/upgrader.html.php b/modules/gallery/views/upgrader.html.php index 0ce24ef8..c2d8a552 100644 --- a/modules/gallery/views/upgrader.html.php +++ b/modules/gallery/views/upgrader.html.php @@ -10,7 +10,7 @@ >
    - " /> + " />
    +
    -

    "> - -

    +
    +

    "> + +

    +
    + + +
    + +
    + +
    + "> + + +
    + + "> @@ -68,7 +99,7 @@ $module): ?> active): ?> - " > + " > @@ -85,18 +116,6 @@
    name) ?>
    - -
    - -
    - -
    - "> - - -
    - -

    "> -- cgit v1.2.3 From 67f45cfa781ef4b446676e199470e421f5463812 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Sep 2010 01:46:45 -0700 Subject: Add CSRF protection to the upgrader. And update the CLI output so that it tells you which modules failed to upgrade properly. Fixes ticket #1359. --- modules/gallery/controllers/upgrader.php | 21 ++++++++++++++++++--- modules/gallery/views/upgrader.html.php | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'modules/gallery/views') diff --git a/modules/gallery/controllers/upgrader.php b/modules/gallery/controllers/upgrader.php index 6613d671..b2646874 100644 --- a/modules/gallery/controllers/upgrader.php +++ b/modules/gallery/controllers/upgrader.php @@ -54,8 +54,16 @@ class Upgrader_Controller extends Controller { // @todo this may screw up some module installers, but we don't have a better answer at // this time. $_SERVER["HTTP_HOST"] = "example.com"; - } else if (!identity::active_user()->admin && !Session::instance()->get("can_upgrade", false)) { - access::forbidden(); + } else { + if (!identity::active_user()->admin && !Session::instance()->get("can_upgrade", false)) { + access::forbidden(); + } + + try { + access::verify_csrf(); + } catch (Exception $e) { + url::redirect("upgrader"); + } } $available = module::available(); @@ -87,7 +95,14 @@ class Upgrader_Controller extends Controller { site_status::clear("upgrade_now"); if (php_sapi_name() == "cli") { - print "Upgrade complete\n"; + if ($failed) { + print "Upgrade completed ** WITH FAILURES **\n"; + print "The following modules were not successfully upgraded:\n"; + print " " . implode($failed, "\n ") . "\n"; + print "Try getting newer versions or deactivating those modules\n"; + } else { + print "Upgrade complete\n"; + } } else { url::redirect("upgrader?failed=" . join(",", $failed)); } diff --git a/modules/gallery/views/upgrader.html.php b/modules/gallery/views/upgrader.html.php index c2d8a552..554cf30d 100644 --- a/modules/gallery/views/upgrader.html.php +++ b/modules/gallery/views/upgrader.html.php @@ -84,7 +84,7 @@

    -- cgit v1.2.3 From 14ae1fde25eb8b22a2fc92453ba12c8e74aba433 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Sep 2010 10:41:47 -0700 Subject: Use the actual csrf token, not the placeholder (url::site doesn't replace that). Fixes ticket #1361 --- modules/gallery/views/upgrader.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gallery/views') diff --git a/modules/gallery/views/upgrader.html.php b/modules/gallery/views/upgrader.html.php index 554cf30d..1ec49c77 100644 --- a/modules/gallery/views/upgrader.html.php +++ b/modules/gallery/views/upgrader.html.php @@ -84,7 +84,7 @@ -- cgit v1.2.3 From 4b8d6beb5e59402d68b1daf5e4f7220066d1b707 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 14 Sep 2010 19:40:54 -0700 Subject: Report the graphics toolkit in the platform block. --- modules/gallery/views/admin_block_platform.html.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'modules/gallery/views') diff --git a/modules/gallery/views/admin_block_platform.html.php b/modules/gallery/views/admin_block_platform.html.php index b1b8a2f9..379ab0aa 100644 --- a/modules/gallery/views/admin_block_platform.html.php +++ b/modules/gallery/views/admin_block_platform.html.php @@ -18,4 +18,7 @@
  • $load_average)) ?>
  • +
  • + module::get_var("gallery", "graphics_toolkit"))) ?> +
  • -- cgit v1.2.3 From de2f9baeee0a05968ef0c3809c90e335180cffd0 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 16 Sep 2010 19:34:42 -0700 Subject: Add a link to http://codex.gallery2.org/Gallery3:Choosing_A_Graphics_Toolkit to help users choose a graphics toolkit. Fixes ticket #1372. --- modules/gallery/views/admin_graphics.html.php | 1 + 1 file changed, 1 insertion(+) (limited to 'modules/gallery/views') diff --git a/modules/gallery/views/admin_graphics.html.php b/modules/gallery/views/admin_graphics.html.php index 3a48e087..ae76f1e1 100644 --- a/modules/gallery/views/admin_graphics.html.php +++ b/modules/gallery/views/admin_graphics.html.php @@ -16,6 +16,7 @@

    + We can help!", array("url" => "http://codex.gallery2.org/Gallery3:Choosing_A_Graphics_Toolkit")) ?>

    -- cgit v1.2.3