Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix php 7.2+ deprecation error #15178

Merged
merged 1 commit into from
Sep 7, 2019
Merged

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

FIxes
The each() function is deprecated. This message will be suppressed on further calls in /var/www/sln/wordpress/wp-content/plugins/civicrm/civicrm/bin/cli.class.php on line 298"
from wp cli

Before

Error on php 7.2+

After

No error

Technical Details

@kcristiano @seamuslee001 I haven't tested this - it's just off chat but I think this is the syntax for getting rid of each

Comments

@civibot
Copy link

civibot bot commented Aug 31, 2019

(Standard links)

@civibot civibot bot added the master label Aug 31, 2019
@seamuslee001
Copy link
Contributor

I think that looks right to me

@kcristiano
Copy link
Member

The patch looks sensible, but in r-run I had an issue.

php 7.3, WP 5.2.2, CiviviCRM master without the patch:

calling cli.php works fine. I did not get any errors in my php logs and as I had call -e Job -a execute I was able to confirm that the the cron jobs ran.

Command used /usr/bin/php ./bin/cli.php -e Job -a execute -s wpcv.test -u admin -p admin

After the patch was applied, I ran the same command and received a cryptic message:

The --c argument is required

Reverting the patch and cli.php runs properly.

Perhaps there is a flaw in how i am testing. Any ideas?

@demeritcowboy
Copy link
Contributor

By default the error_reporting() value doesn't often include E_DEPRECATED so you won't see the message. I can reproduce it if I add E_DEPRECATED to error_reporting(). For the patch, the letter 'c' is appearing because $var[1] is the second letter in 'action':

Suggest to change foreach ($required as $vars) to foreach ($required as $var) and remove the $var = $vars[1]; line.

@seamuslee001
Copy link
Contributor

@demeritcowboy i believe wordpress by default turns on E_ALL for error_reporting

@demeritcowboy
Copy link
Contributor

demeritcowboy commented Sep 2, 2019

@seamuslee001 Ok I admit I was using drupal but when I echo'd error_reporting() at the line just before the each() it said 1 (E_ERROR) only, which now that I think more about it must be set somewhere in civi because that's not my setting or drupal's. But then how did the original person see it. Hmmm.

@eileenmcnaughton
Copy link
Contributor Author

OK doing a code step through

this the vars....
Screen Shot 2019-09-07 at 1 39 27 PM

@eileenmcnaughton
Copy link
Contributor Author

& with @demeritcowboy code
Screen Shot 2019-09-07 at 1 41 51 PM

So yes Dave nailed figuring out what the crufty old code was trying to say - I will update & merge (treating myself as the review of @demeritcowboy's suggested code change)

@demeritcowboy
Copy link
Contributor

@eileenmcnaughton Some extra contribution-related code seems to have snuck into the patch?

@kcristiano
Copy link
Member

@demeritcowboy Good pickup. I'll test again and not include that

@kcristiano
Copy link
Member

did an r-run works with and without the change to CRM/Contribute/BAO/Contribution.php likely a false commit sneaked in.

@eileenmcnaughton
Copy link
Contributor Author

OK - removed the extra - I had created a local 'origin/master' branch & rebased over that not the remove tracking branch - merging now

@eileenmcnaughton eileenmcnaughton merged commit aad2f96 into civicrm:master Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants