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

amar.deokar created an issue. See original summary.

amar.deokar’s picture

Issue summary: View changes
amar.deokar’s picture

Status: Active » Needs review
StatusFileSize
new1.11 KB

Though we are fine with php7.1, we need to fix above error for php7.2 in future. I have added patch for it.

Status: Needs review » Needs work

The last submitted patch, 3: php7_2_compatibility-2923477-3.patch, failed testing. View results

amar.deokar’s picture

Status: Needs work » Needs review
StatusFileSize
new1.12 KB

Update path in patch file due which patch was failed.

tr’s picture

Status: Needs review » Reviewed & tested by the community

Yes, 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.

ram4nd’s picture

#5 works for me as well

jamesoakley’s picture

+1 RTBC from me, too.

fago’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed!

  • fago committed 0bdbc64 on 7.x-2.x authored by amar.deokar
    Issue #2923477 by amar.deokar: PHP 7.x compatibility issue
    

Status: Fixed » Closed (fixed)

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

oriol_e9g’s picture

Same 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.

camerongreen’s picture

+1 to #12, breaking some things

dxvargas’s picture

+1 to #12

axle_foley00’s picture

The patch in #5 works for me. +1 for #12 that there should be a minor version update released that includes this patch.

pimok3000’s picture

i can confirm that the patch in #5 is working.

jlancaster’s picture

Confirming as well patch from #5 fixes issues with PHP 7.2

pguerrier’s picture

How 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

pguerrier’s picture

Forgive 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;

tr’s picture

Almost...

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.

drupgirl’s picture

Confirming patch from #5 fixes issues with PHP 7.1.

msypes’s picture

Confirming that patch works with 7.2.4

xtaz’s picture

#5 works for me too.

tantana5’s picture

Confirm #5 that work for me PHP 7.2.2
Thank you very much!

tr’s picture

So, 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.

g089h515r806’s picture

people does not use the dev version.

jamesoakley’s picture

So, 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.

I was wondering the same thing, until g089h515r806 said what is now glaringly obvious to me (but wasn't until he said it):

people does not use the dev version.

Thanks, @TR, for your suggestion:

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.

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.

g089h515r806’s picture

Fago, the author of this modules not active like before. It seems that he focus on Node JS now.
Maybe this module need another maintainer.

jamesoakley’s picture

Are you sure? He posted #2968031: [PP-1] Race condition with locale javascript translation generation just today.

And klausi is also very much still active.

ferriol’s picture

Confirm #5 works with php 7.2.5

kennybell’s picture

#5 worked for me. Thanks.

x7ian’s picture

Thank you very much!
#5 did it!

camerongreen’s picture

Looks like this has been fixed in the module as an update to the latest worked for me.

shaktik’s picture

its working fine for me.

davidjguru’s picture

Hi, 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 :-)

jamesoakley’s picture

@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.

jamesoakley’s picture

More 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.

davidjguru’s picture

Thanks for the info. If I could update the platform, I sure would. :-/

aswathyajish’s picture

#5 worked for me. Thanks a lot.

vincent wasswa’s picture

#5 worked for me also. Thanks a lot

hiramanpatil’s picture

#5 php7_2_compatibility-2923477-5.patch worked for me. Thanks

spamator12’s picture

#5 works for me too.

tr’s picture

...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?

franckylfs’s picture

#5 works for me also after updating the PHP version to 7.1. Thanks!

jamesoakley’s picture

@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.

jamesoakley’s picture

Just 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?

gwheelerky’s picture

@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.

jamesoakley’s picture

That'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!

tr’s picture

A 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.

gwheelerky’s picture

You'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!

thirstysix’s picture

As per the Patch #5 & #35 comment is working fine with PHP 7.3

Thank you Guys !

jamesoakley’s picture

@ThirstySix - what version of Rules are you using such that the patch applies correctly?

thirstysix’s picture

@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.

coozila’s picture

The same error with php 7.4

jamesoakley’s picture

@coozila - with which version of the Rules module?

steva1982’s picture

hi @jamesoakley,

I have: php7.4, rules 2.13, drupal 7.88 and the error is

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 /MY-SERVER/docs/sites/all/modules/rules/ui/ui.plugins.inc on line 20
jamesoakley’s picture

Hi, @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 being form(&$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.

steva1982’s picture

hi @jamesoakley,

thank you for your suggestion. It works.