• Resolved juelybean

    (@juelybean)


    Hi.
    I noticed the following error message appeared on my site some time ago. At the time there was also a message to update my PHP version and I assumed the two errors were linked, however I have since updated the PHP but this message remains.
    As I am unfamiliar with the technical language, I’m not sure if how to solve the problem.

    Warning: count(): Parameter must be an array or an object that implements Countable in /home/ridingin/public_html/wp-content/themes/cindy-j/includes/lists.php on line 352
    For reference, line 352 in lists.php: if (count($custom_sidebars_number) > 0) {

    I see a few similar topics in the forum, so I apologize in advance if this is repetitive, but I still haven’t figured out how to fix it.

    Any help would be greatly appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author C. Johnson

    (@radgeek)

    Hi @juelybean , a couple of notes on your issue:

    (1) On the one hand, if you download and install the update to the most recent version of FeedWordPress (v. 2021.0713, released yesterday on the 13th), I can say that this update resolves some outstanding issues with notices resulting from the use of the count() function. So it might be useful for your purposes, if nothing else for the sake of eliminating possible causes. HOWEVER, see below.

    (2) ON THE OTHER HAND, from the contents of the PHP Warning that you quote above, it appears that the problem here is related to code within your WordPress Theme, (cindy-j), rather than being related to the FeedWordPress plugin. The line that you quote above is not from the FWP code and does not seem to be closely related to FeedWordPress functionality.

    As a general matter, if you are able to, and feel comfortable with, editing the code in your theme in order to address this issue, it might be relatively easy to address the immediate issue that is causing the warning.

    Usually warnings like these result from code that was written under earlier versions of PHP (in which coders were able to use the count() function not only on arrays and array-like structures, but also to detect NULL values, single-item scalar values, etc.) but are now being run under newer versions of PHP (in which count() is more narrowly limited to arrays and array-like lists, and where the older conventions have been eliminated in favor of other conventions like using is_null() and similar type-detection functions). Certainly, this is what caused issues in the case of code that I wrote for FeedWordPress (which was originally written a very long time ago, and has gone through several versions of PHP).

    Depending on the code that is above or below the if structure that you quote — in particular, depending on where the $custom_sidebars_number variable comes from and how it is used when it has a valid value — this issue should be fixable by putting one or two simple test functions in front of the call to count($custom_sidebars_number). You might be able to do this by hand, or, if the theme was developed by a third-party developer, you might be able to get the developer to do it for you. If you want, please feel free to drop me an e-mail at <[email protected]> with some more details about the theme you’re using and with, say, the 5 lines before line 352 and the 5 lines after it, and we can probably work it out from there. Just let me know!

    Since this issue seems very probable to be unrelated to FeedWordPress, I am for the time being marking the issue as “Resolved,” but if you have more information that indicates it is in fact directly related to the plugin, please let me know and I’d be happy to open it back up again here.

    Thread Starter juelybean

    (@juelybean)

    Thank you so much for your response. Email sent.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Warning: count():’ is closed to new replies.