0

I recently made a local copy of an existing site to make development changes. Most everything is working fine in the local version, except that at the top of any Page I see this error (sometimes more than once) –

Warning: count(): Parameter must be an array or an object that implements Countable in /[website directory]/wp-includes/post-template.php on line 284

It looks like <?php wp_head(); ?> is throwing the error when php checks to see if the selected post has more than one page, and that it's the $pages variable that's failing. I've tried manually setting $pages to an empty array before that, but that didn't make any difference.

The only other thing I can think of is that my dev environment is running php 7.2 but the production server (which is working fine) is running 5.6. Might that have anything to do with this issue?

  • PHP docs on count do mention count new warnings if invalid countable type variables are passed. Are you able to share the code you believe to be throwing the error. – Andrew Jan 6 '18 at 16:40
  • in addition to what andrew said, it realy means that you always had a bug, or at least bug code, but there were just nonnoticeable manifistation of it – Mark Kaplun Jan 6 '18 at 16:45
  • Looks like the problem was my Jetpack plugin, which isn't completely compatible with PHP 7.2 yet. A little more info is below. Thanks guys! – jtenclay Jan 6 '18 at 21:53
0

Turns out the problem was Jetpack. I looked through the <head> to see where in the stack it was breaking and it was right in the middle of the Jetpack plugin code.

Looks like it's being worked on here: https://github.com/Automattic/jetpack/issues/8156 under "PHP warnings." Since Jetpack isn't necessary for my dev server on this project, I deactivated it and haven't had any errors since.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.