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

PHP Notice: Only variables should be passed by reference #143

Closed
joyously opened this issue Jun 27, 2019 · 3 comments · Fixed by ClassicPress/ClassicPress#429
Closed

PHP Notice: Only variables should be passed by reference #143

joyously opened this issue Jun 27, 2019 · 3 comments · Fixed by ClassicPress/ClassicPress#429

Comments

@joyously
Copy link
Contributor

Trying ClassicPress 1.0.1 conversion from WP 5.2.2, my debug_log file has

PHP Notice: Only variables should be passed by reference in /wp-admin/includes/dashboard.php on line 1463

That line of code is
$active = array_shift( array_keys( $feeds ) );
The dashboard is showing two widgets with feeds (petitions and blog).

Possible solution

This could be because of using the same database as WordPress was using? It went through a page that updated the database, though.

Steps to reproduce

  1. I extracted the CP zip to a folder
  2. I copied the wp-config.php and the uploads folder from my wordpress folder to CP folder
  3. I renamed the wordpress folder to x, and the CP folder to wordpress
  4. I logged in to the site
@pattonwebz
Copy link
Contributor

pattonwebz commented Jun 28, 2019

I will take care of this one today. I have encountered this problem before and I know the solution.

The output of array_keys() is not intuitive. It returns an array but it does not output one. It's a bit nuanced.

@pattonwebz
Copy link
Contributor

I have created a PR to correct this notice. It introduces no breaking changes and is functionally exactly the same - it just rearranges things to satisfy strict php notice about this.

@nylen
Copy link
Contributor

nylen commented Jun 28, 2019

Thanks @pattonwebz!

I was able to confirm that this PR (#429) fixes the issue. Also quoting from my comment there:

This is a good example of why it's a good idea to add an automated test for any new code. This would have caught this error by executing the code in question against all of our supported PHP versions automatically, and failing if any notices or any other errors occur.

nylen referenced this issue in ClassicPress/ClassicPress Jun 28, 2019
Also adds an automated test to cover the related code.

Fixes #427.
@viktorix viktorix transferred this issue from ClassicPress/ClassicPress Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants