Ultimate cron upgrade fails from version 1.9 to 2.0 when running the Drush command as is errors on the table cache_ultimate_cron doesn't exist and causes the cron listing to not load.

I had to completely uninstall ultimate cron and reinstall to get it to work but I loose my settings. Please can there be a clean upgrade?

Comments

rviner created an issue. See original summary.

arnested’s picture

Assigned: Unassigned » arnested
rviner’s picture

Version: 7.x-2.0 » 7.x-2.1
arnested’s picture

I just had a look into this.

I think the problem could be that you must install ctools before you upgrade Ultimate Cron to 7.x-2.x.

Could you verify my assumption? If so I'll add it to the upgrade section on the module page and to hook_requirements().

arnested’s picture

A change could look something like this:

diff --git a/ultimate_cron.install b/ultimate_cron.install
index 747fdc8..f386842 100755
--- a/ultimate_cron.install
+++ b/ultimate_cron.install
@@ -271,6 +271,18 @@ function ultimate_cron_requirements($phase) {
     case 'install':
       return $response;

+    case 'update':
+      if (!module_exists('ctools')) {
+        $t = get_t();
+        $ctools['title'] = 'Ultimate Cron';
+        $ctools['value'] = $t('Error');
+        $ctools['severity'] = REQUIREMENT_ERROR;
+        $ctools['value'] = $t('Chaos tool suite (ctools) is not enabled!');
+        $ctools['description'] = $t('You must install and enable Chaos tool suite (ctools) before upgrading Ultimate Cron.');
+        $response['ultimate_cron'] = $ctools;
+      }
+      return $response;
+
     case 'runtime':
       $t = get_t();
       $response['title'] = 'Ultimate Cron';
diff --git a/ultimate_cron.module b/ultimate_cron.module
index 6db5d04..ea0e295 100755
--- a/ultimate_cron.module
+++ b/ultimate_cron.module
@@ -724,7 +724,12 @@ function ultimate_cron_ultimate_cron_job_list() {
  * Implements hook_flush_caches().
  */
 function ultimate_cron_flush_caches() {
-  return array('cache_ultimate_cron');
+  $bin = 'cache_ultimate_cron';
+  $cache = _cache_get_object($bin);
+  if (($cache instanceof DrupalDatabaseCache) && !db_table_exists($bin)) {
+    return array();
+  }
+  return array($bin);
 }

 /**

The change to ultimate_cron_flush_caches() to catch for the situation where some cache clear runs before the cache table has been created.

That would at least catch the situation where someone tries to enable ctools but has already upgrade the ultimate_cron code to 7.x-2.x (and you're using database cache).

I'm not sure adding that overhead to each cache clear is worth it, though.

rviner’s picture

I can confirm your fix does work, thanks.

Note: I did already have ctools installed when I attempted to upgrade previously so the fix in my case comes within the change to ultimate_cron_flush_caches function.

arnested’s picture

Ok, good to know.

The only way I was able to trigger this so far was when missing ctools.

So the problem appears to be something triggering a cache clear before running all the update hooks of Ultimate Cron 2.x.

A couple of questions just to try to narrow it down:

  1. Do you do update any thing else together with Ultimate Cron? If yes, try to update only Ultimate Cron.
  2. Could you look in the database for the current registered schema_version of Ultimate Cron before the update? (SELECT schema_version FROM system WHERE name = "ultimate_cron";)
rviner’s picture

1. I'm only updating ultimate cron on its own.

2. The schema version before the update is 7108.

Since you can only reproduce the issue without ctools installed I've carried out further testing and it only seems to be an issue on one of my sites with a lot of modules enabled so it must be some other module conflict (not sure what). However haven't ever come across this issue when upgrading any other Drupal module.

I tested this on a much simpler site than the one I tried to upgrade and it worked first time.

arnested’s picture

Thank you, @rviner.

Weird. Nothing wrong with schema_version or anything else apparently. Except not working :-)

Ultimate Cron 7.x-2.x creates a new cache table in update hook ultimate_cron_update_7202(). The cache table is then added hook_flush_caches()/ultimate_cron_flush_caches() (as should be).

The problem must be that something on this one particular site triggers a clear cache before ultimate_cron_update_7202() get a chance to run.

Any chance you'll be able to debug into when/where that happens?

rviner’s picture

I've got to the bottom of the issue, updating it manually worked so the Drush version needed updating as it was still on version 5 and therefore none of the update hooks ran.

Thanks for helping me narrow down the issue, not sure why it didn't crop up on any other module upgrade.

  • arnested committed 4866622 on 7.x-2.x
    Issue #2802955 by arnested: Upgrade fails from version 1.9 - 2.0
    
arnested’s picture

Status: Active » Fixed

Glad you found your way around this!

I add a update requirements check on the existence of ctools. Although this was not your root cause it was at least a potential error for some users.

I'll close this and create a 7.x-2.2 release.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.