Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Call to undefined function rules_set_cache() in modules/all/rules/rules.install,line 517
When I try to run update 7214 I get the above error.
it's defined in rules.module:468:function rules_set_cache($cid, $data).
Comment | File | Size | Author |
---|---|---|---|
#25 | rules-2449513-25.patch | 945 bytes | brad.bulger |
| |||
#24 | rules-2449513-24.patch | 918 bytes | stefan.r |
| |||
#18 | rules-fix-for-undefined-function-during-db-updates-2449513-18.patch | 938 bytes | marblegravy |
#3 | rules-install-fail-2449513-3.patch | 1.28 KB | brad.bulger |
Comments
Comment #1
cayerdis CreditAttribution: cayerdis commentedI had disabled the rules modules in my test site once I enabled it I was able to update it.
Comment #2
podarokThe same is for my installation
Comment #3
brad.bulger CreditAttribution: brad.bulger commentedSame as comment 1 - the module is there because the contributed modules directory is shared with another site, but Rules is not enabled. It shouldn't cause a fatal error when that's the case.
I added a module_exists() check.
Comment #4
marblegravy CreditAttribution: marblegravy commentedHit the same issue as others here with the update failing because Rules is installed but not enabled. In my case I have installed the updated version of the module and am running db updates via drush during a build process.
Looking at Brad's patch I'd be concerned that this would just cause Rules to never be updated (if you wanted to enable it later for example) but not sure what a better solution would be...
Comment #5
brad.bulger CreditAttribution: brad.bulger commentedthat's a good point. i guess the problem would be if you had Rules running previously, so that you had whitelist information in that variable. when you enabled Rules again, that whitelist information would be lost, abandoned in the old variable. maybe a call from the hook_enable() function to check for a non-empty "rules_event_whitelist" variable, that would run this same code?
Comment #6
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedComment #7
marcoka CreditAttribution: marcoka commentedconfirmed. i had this on all my sites when updating 2.6 to 2.9
using multisite!
Comment #8
kienan CreditAttribution: kienan commentedI encountered the same issue with sites that didn't have rules enabled, but it was present in the site/all directory. The patch in #3 solved my issue, but I understand the hesitation about using it.
I'm not well versed with the api/functions available in rules, but is a potential solution to delete the variable from the db, and then only perform the cache cleanup if rules is enabled?
Comment #9
marcoka CreditAttribution: marcoka commentedmy question is, as i ignored the error, if i can fix that later or if it will be fixed in the update of a newxt version?
Comment #10
mvcthis error will come up whenever rules is disabled but not uninstalled. the best workaround here would be to uninstall rules.
i'm not sure the test in the patch above is safe, since it will update the database schema version in the system table without having actually run any updates. if a user later enables this module they would have to manually run these database upgrades, or uninstall & re-install, which would mean losing any custom configuration they had done.
all of this is really a general problem with drupal update hooks. there's no clean way to run module specific code like this. unfortunately, the update hook can't depend on any other code from the module being available. fixing this would probably mean putting (renamed) copies of the relevant functions into the .install file. but just uninstalling rules where it's no longer needed is enough for my client, so i'm afraid someone else will have to write that.
Comment #11
Jan-E CreditAttribution: Jan-E commentedIn a multi-site install you just cannot uninstall rules. We ran into this error when one of the multi-sites needed rules, the other did not. I remmed out all statements in function rules_update_7214() to get past the error. No nice solution, but rules_update_7214 was blocking other updates.
Comment #12
mvcwhat i mean is that the status of the rules module should not be "disabled", it should be either "installed" or "uninstalled". update.php will update the schema of disabled modules but not of uninstalled modules. the problem came up when the rules database schema was still in the db, but not being used.
the only reason to leave a module disabled but not uninstalled is when you expect to use it again later and you don't want to lose the configuration & data.
Comment #13
Jan-E CreditAttribution: Jan-E commentedNo, there is another reason. In Drupal multi-site you will have a lot of modules that are installed because they are needed in one of the sites. They are not necessarily enabled in the other sites of the multi-site. To make it real clear:
http://axelfunke.nl and http://platformarbeidsverhoudingen.nl run under the same Drupal instance. The have some modules in common, but not all. All of these modules (and some more) are installed, but not always enabled. In Drupal multi-site it is a common practice to have modules disabled although they are installed.
Comment #14
mvcJan-E: in fact I am familiar with the drupal multi-site setup; I help maintain a server which currently runs 128 drupal sites spread over 9 platforms. many modules are in use (installed) on one or more of these sites but not on others.
the problem here is that the rules module *used* to be installed on one of your sites. it's now no longer in use, but if you look at the database, all the tables are still there. you need to get back to the state *before* you enabled rules on the site that doesn't use it.
please read http://cms.about.com/od/drupal-glossary/fl/Drupal-Modules-Disabling-vs-U... for a description of the difference between the "uninstalled" and "disabled" states, http://drupal.stackexchange.com/questions/22/do-non-enabled-drupal-modul... for an explanation of why leaving unused modules as disabled but not uninstalled can cause performance issues, #1199946: Disabled modules are broken beyond repair so the "disable" functionality needs to be removed for a description of why none of this makes any sense and is a source of annoying problems in D7, and https://www.drupal.org/node/2193013 for a description of how and why this was fixed in D8 by eliminating the state "disabled" entirely so that things will in the future work as you describe.
Comment #15
bwoods CreditAttribution: bwoods at AOL commentedI just wanted to chime in and say that I agree with mvc in this matter. If, for some reason, you don't want to lose your rules config when uninstalling, you could make a backup of the rules db tables.
Also, as mvc explained in comment #14, when you uninstall Rules from one site within a multi-site install, it will not affect a different site, assuming that you have not set rules tables to be shared across multiple sites in your settings.php file.
Comment #16
marblegravy CreditAttribution: marblegravy commentedDespite the arguments about best practice when disabling modules, the fact is that some people are getting caught out by this update.
This patch will basically check to see if the module is installed and enable it if it's not, let the update do its thing and then return the module back to its original state.
This *should* mean that noone should get stuck during builds. Let's see if it works!
Comment #17
marblegravy CreditAttribution: marblegravy commentedThis time without the facepalm-worthy errors.
Comment #18
marblegravy CreditAttribution: marblegravy commented....aaand another one - I wish you could test patches in make files for build processes locally so I didn't have to post so many silly mistakes.
--------------------
So after testing this one out I can confirm that it's working.
https://www.drupal.org/files/issues/rules-fix-for-undefined-function-dur...
works to allow builds to go through.
Depending on your make files you'll probably want to use something like this:
So for anyone else later, this patch is for when:
What this patch does is:
And in all cases:
If you have to have the Rules module installed, but your site doesn't need it, uninstall it as well as just disabling it.
Comment #19
marblegravy CreditAttribution: marblegravy commentedComment #20
xurizaemon+1 does what it says on the tin.
Did not review code.Looked at code, seems sane, and fixed issues on upgrade from D6 for this instance.Enabling Rules would also have resolved the issue, but this patch is good as it enables it only during the update process.
Comment #21
leisurman CreditAttribution: leisurman commentedSame for me, I put rules in my module folder then ran update, and got the error.It couldn't find that function because the module was not enabled. enable it, then ran update, no more error.
Comment #22
amme CreditAttribution: amme commentedPatch works
Comment #23
amme CreditAttribution: amme commentedComment #24
stefan.r CreditAttribution: stefan.r commentedPatch looks great and solves the issue, confirming RTBC and attaching a re-roll
Comment #25
brad.bulger CreditAttribution: brad.bulger commentedAgreed. Adding definition of $disable_rules for the case when Rules is enabled to avoid "undefined variable" error.
Comment #27
fagook, not the nicest workaround but makes sense. committed.