This error was came only for php 7.2.
PHP Fatal error: Declaration of RulesRuleUI::form(&$form, &$form_state, $options = Array) must be compatible with RulesActionContainerUI::form(&$form, &$form_state, $options = Array, $iterator = NULL) in /sites/all/modules/rules/ui/ui.plugins.inc on line 80
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Declaration of RulesRuleUI::form(&$form, &$form_state, $options = Array) must be compatible with RulesActionContainerUI::form(&$form, &$form_state, $options =
Array, $iterator = NULL) in /sites/all/modules/rules/ui/ui.plugins.inc, line 80
Fatal error: Declaration of RulesRuleUI::form(&$form, &$form_state, $options = Array) must be compatible with RulesActionContainerUI::form(&$form, &$form_state, $options = Array, $iterator = NULL) in /sites/all/modules/rules/ui/ui.plugins.inc on line 80
Comments
Comment #2
amar.deokar commentedComment #3
amar.deokar commentedThough we are fine with php7.1, we need to fix above error for php7.2 in future. I have added patch for it.
Comment #5
amar.deokar commentedUpdate path in patch file due which patch was failed.
Comment #6
tr commentedYes, this should be done.
RulesContainerPluginUI extends RulesPluginUI
The only thing RulesContainerPluginUI does is override the form() method to add the additional $iterator argument.
By definition then, all subclasses of RulesContainerPluginUI inherit this redefinition of form().
RulesActionContainerUI extends RulesContainerPluginUI, so this applies to subclasses of RulesActionContainerUI as well.
In particular:
RulesRuleUI extends RulesActionContainerUI
RulesReactionRuleUI extends RulesRuleUI
RulesLoopUI extends RulesActionContainerUI
The patch fixes these three subclasses of RulesContainerPluginUI which currently fail to accept an $iterator argument to form(). That's wrong from an OO perspective, and at long last PHP is starting to enforce some of this problems which it previously let slide.
Comment #7
ram4nd commented#5 works for me as well
Comment #8
jamesoakley+1 RTBC from me, too.
Comment #9
fagoThanks, committed!
Comment #12
oriol_e9gSame problem and dev fixes it.
I think it would be a good idea to release a new minor version to ensure that the last stable version is PHP 7.2 compatible.
Comment #13
camerongreen commented+1 to #12, breaking some things
Comment #14
dxvargas commented+1 to #12
Comment #15
axle_foley00 commentedThe patch in #5 works for me. +1 for #12 that there should be a minor version update released that includes this patch.
Comment #16
pimok3000 commentedi can confirm that the patch in #5 is working.
Comment #17
jlancaster commentedConfirming as well patch from #5 fixes issues with PHP 7.2
Comment #18
pguerrier commentedHow do I apply this patch ? Can someone please assist? I am running Drupal 7 on Ubuntu 16 and have PHP 7.2. and getting this error when I try to update security patches (want to go from drupal 7.50 to 7.5.8)
PHP Fatal error: Declaration of RulesRuleUI::form(&$form, &$form_state, $options = Array) must be compatible with RulesActionContainerUI::form(&$form, &$form_state, $options = Array, $iterator = NULL) in /var/www/html/sites/all/modules/contrib/rules/ui/ui.plugins.inc on line 80
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Declaration of RulesRuleUI::form(&$form, &$form_state, $options = Array)
must be compatible with RulesActionContainerUI::form(&$form, &$form_state, $options
= Array, $iterator = NULL) in
Comment #19
pguerrier commentedForgive me for being a newbie, but I'm trying to apply this php patch from #5 and having problems
I copied the patch content to a file called php7.patch and placed in /var/www/html/sites/all/modules/contrib/rules/ui directory
Ran the command "git apply -v patch"
root@ace-linux13 # cd /var/www/html/sites/all/modules/contrib/rules/ui
root@ace-linux13 # git apply -v patch
fatal: corrupt patch at line 29
root@ace-linux13 # more patch
--- a/ui.plugins.inc 2017-11-15 15:23:38.474142310 +0530
+++ b/ui.plugins.inc 2017-11-14 23:52:46.273778697 +0530
@@ -17,7 +17,7 @@
$this->conditions = $this->rule->conditionContainer();
}
- public function form(&$form, &$form_state, $options = array()) {
+ public function form(&$form, &$form_state, $options = array(), $iterator = NULL) {
$form_state['rules_element'] = $this->rule;
$label = $this->element->label();
// Automatically add a counter to unlabelled rules.
@@ -84,7 +84,7 @@
*/
class RulesReactionRuleUI extends RulesRuleUI {
- public function form(&$form, &$form_state, $options = array()) {
+ public function form(&$form, &$form_state, $options = array(), $iterator = NULL) {
$form['events'] = array(
'#type' => 'container',
'#weight' => -10,
@@ -193,7 +193,7 @@
*/
class RulesLoopUI extends RulesActionContainerUI {
- public function form(&$form, &$form_state, $options = array()) {
+ public function form(&$form, &$form_state, $options = array(), $iterator = NULL) {
parent::form($form, $form_state, $options);
$settings = $this->element->settings;
Comment #20
tr commentedAlmost...
Copy the patch content to a file called php7.patch and place it in the /var/www/html/sites/all/modules/contrib/rules directory.
cd /var/www/html/sites/all/modules/contrib/rules/
patch -p1 < php7.patch
Or, just update to the 7.x-2.x-dev version of Rules.
Comment #21
drupgirl commentedConfirming patch from #5 fixes issues with PHP 7.1.
Comment #22
msypes commentedConfirming that patch works with 7.2.4
Comment #23
xtaz#5 works for me too.
Comment #24
tantana5 commentedConfirm #5 that work for me PHP 7.2.2
Thank you very much!
Comment #25
tr commentedSo, I have no idea why so many people keep posting in this CLOSED issue - this bug has been fixed for four months now. The patch was reviewed and we know it works, and it was committed to Rules 7.x-2.x-dev back in December.
If you're concerned about Rules working with PHP 7.2, please review the OPEN issues that are trying to address the remaining PHP 7.2 problems. It doesn't make sense to make a new minor point release for PHP 7.2 support unless ALL the known PHP 7.2 problems are fixed.
See for example #2952654: Support PHP 7.2 - you could comment on that if you want, and push to get that committed.
Comment #26
g089h515r806 commentedpeople does not use the dev version.
Comment #27
jamesoakleyI was wondering the same thing, until g089h515r806 said what is now glaringly obvious to me (but wasn't until he said it):
Thanks, @TR, for your suggestion:
I've done a search. There's only one open issue tagged PHP 7.2 in the Rules issue queue and it's the one you linked to: #2952654: Support PHP 7.2, which has been RTBC for 6 weeks.
We don't know what the maintainers' plan is, and if they're waiting for other issues to be fixed before making a new point release. But it would help the endless string of people who return to this issue to say that the patch works if #2952654: Support PHP 7.2 could be committed and a new point release made. Then the latest release on the 7.x branch of Rules would be PHP 7.2 compliant, and attention can be given to other issues once the noise from PHP 7.2 warnings has been muted.
Comment #28
g089h515r806 commentedFago, the author of this modules not active like before. It seems that he focus on Node JS now.
Maybe this module need another maintainer.
Comment #29
jamesoakleyAre you sure? He posted #2968031: [PP-1] Race condition with locale javascript translation generation just today.
And klausi is also very much still active.
Comment #30
ferriol commentedConfirm #5 works with php 7.2.5
Comment #31
kennybell commented#5 worked for me. Thanks.
Comment #32
x7ian commentedThank you very much!
#5 did it!
Comment #33
camerongreen commentedLooks like this has been fixed in the module as an update to the latest worked for me.
Comment #34
shaktikits working fine for me.
Comment #35
davidjguruHi, I Just want to say that the solution #5 Works fine for me. Thanks.
PHP: 7.2.10
Ubuntu: 18.04.1
Drupal Core: 7.59
Profile: Drupal Origins (drupal_origins-7.x-1.18)
Rules: 7.x-2.10
Simply doing:
cd /path_to_project/modules/contrib/rules/
(Well in my case is /path_to_project/profiles/drupal_origins/modules/contrib/rules/ )
And Then,
curl -0 https://www.drupal.org/files/issues/php7_2_compatibility-2923477-5.patch | git apply
And everything is fine :-)
Comment #36
jamesoakley@davidjguru: Rules 7.x-2.11 has been out since May this year, and includes this fix. It also includes other fixes. So I'd suggest updating from 7.x-2.10 to this latest tagged release, then you won't need to patch this manually.
Comment #37
jamesoakleyMore concerning is that you're using Drupal 7.59. This is off-topic from this issue, but 7.60 was a security release, so you should definitely upgrade core to at least 7.60, but you may as well get bang up to date and go for 7.61 while you're about it.
Comment #38
davidjguruThanks for the info. If I could update the platform, I sure would. :-/
Comment #39
aswathyajish commented#5 worked for me. Thanks a lot.
Comment #40
vincent wasswa commented#5 worked for me also. Thanks a lot
Comment #41
hiramanpatil#5 php7_2_compatibility-2923477-5.patch worked for me. Thanks
Comment #42
spamator12 commented#5 works for me too.
Comment #43
tr commented...or maybe you could stop using an outdated version of Rules? Rules has worked with PHP 7.2 since Drupal core started to support it, and has been working with PHP 7.2 since 7.2 was officially released... So if you're still seeing this problem that means you've updated both Drupal core and PHP but are still using a two year old version of Rules?
Comment #44
franckylfs commented#5 works for me also after updating the PHP version to 7.1. Thanks!
Comment #45
jamesoakley@FranckyLFS - please upgrade your copy of Rules to the latest version, and your other modules and themes while you're there. The current version downloaded from the Drupal website has had this fix built into it since May 2018. I can't see any security-level fixes in Rules since then, but it's always very risky running such out of date versions of modules. Indeed, PHP 7.1 itself ends security support on 1 December, so in 6 weeks time you could have vulnerabilities in your PHP as well.
Comment #46
jamesoakleyJust a thought.
I must be email subscribed to loads of issues that are now "Closed (Fixed)". What is it about this one that gets so many people confirming the patch works long after the tagged release has come out? I don't get this with any other issues. Why this one?
Comment #47
gwheelerky commented@JamesOakley: This issue just now took a client site completely down on Acquia cloud, with PHP 7.2 and Rules 7.x-2.12 and latest D7 core. I looked at the ui.plugins.inc file on my dev workstation and the 2.12 release code did NOT contain all of the fixes reflected in the patch referred to in #5.
I manually altered the code and pushed to production and the issue resolved. At this point I still don't know how the site didn't break earlier, since it's been running for a while on those versions. At any rate, the patch did not appear to actually make it into the release.
Comment #48
jamesoakleyThat's very strange.
The commit is this one: https://git.drupalcode.org/project/rules/commit/0bdbc64
That picks up all the changes in the patch in #5.
It's dated 14 Dec 2017
7.x-2.12 is Jan 2019.
You can see the exact code for ui/ui.plugins.inc in the 7.x-2.12 release here: https://git.drupalcode.org/project/rules/blob/7.x-2.12/ui/ui.plugins.inc
I've just manually checked the 3 changes in the patch, and they all seem to be there.
Odd!
Comment #49
tr commentedA clean git checkout of Rules 7.x-2.12 does contain this fix from two years ago - I just verified that. I also verified that the .tar.gz version of the module does contain that fix.
I suggest you check the code on your server and ensure you really have a complete up-to-date copy of Rules. Perhaps a file permission or something prevented some files from being updated, or perhaps the code was restored from an old backup.
Comment #50
gwheelerky commentedYou're absolutely right, I was certain I was dealing with pristine release code but looking through the history of the file I found an accidental reversion bundled into a completely unrelated commit. Case closed!
Comment #51
thirstysix commentedAs per the Patch #5 & #35 comment is working fine with PHP 7.3
Thank you Guys !
Comment #52
jamesoakley@ThirstySix - what version of Rules are you using such that the patch applies correctly?
Comment #53
thirstysix commented@JamesOakley
When i setup the existing Drupal 7 site with Rules version = "7.x-2.9" & PHP version 7.3. it's shows the error. So I tried with Patch #5 & #35 comment. It's work.
In my use case I am to upgrade the core & contirb versions to latest.
Comment #54
coozila commentedThe same error with php 7.4
Comment #55
jamesoakley@coozila - with which version of the Rules module?
Comment #56
steva1982 commentedhi @jamesoakley,
I have: php7.4, rules 2.13, drupal 7.88 and the error is
Comment #57
jamesoakleyHi, @steva1982
If you look at the code for ui.plugins.inc in Rules 7.x-2.13 (https://git.drupalcode.org/project/rules/-/blob/7.x-2.13/ui/ui.plugins.inc), the declaration for form is (a) not on line 20, and (b) reads
public function form(&$form, &$form_state, $options = array(), $iterator = NULL). The error you're getting refers to that declaration being on line 20, and to the method signature beingform(&$form, &$form_state, $options = Array)If you look at the commit that fixed this issue, the method declaration was what was changed to fix things.
So, although your rules.info file suggests yo'ure on 7.x-2.13, that file doesn't appear to be from that version.
I suggest deleting all the files for the rules module on your site, and extracting a fresh copy of 7.x-2.13.
Comment #58
steva1982 commentedhi @jamesoakley,
thank you for your suggestion. It works.