Warning: count(): Parameter must be an array or an object that implements Countable in adminimal_table() (line 330 of /var/www/html/skypyx/sites/all/themes/adminimal_theme/template.php).

Comments

drupalstrap created an issue. See original summary.

tessa bakker’s picture

Title: warning notice in php 7.2 » Warning notice in php 7.2
Project: Adminimal Administration Menu » Adminimal - Responsive Administration Theme
Version: 7.x-1.9 » 7.x-1.x-dev
heyyo’s picture

StatusFileSize
new2.57 KB

Proposed patch for it.

heyyo’s picture

Status: Active » Needs review
maximpodorov’s picture

One space is added, and the patch is renamed.

vandna b’s picture

I have tested it #5 working fine

rob c’s picture

Category: Bug report » Task
Status: Needs review » Reviewed & tested by the community

Yup, #5 seems to do the trick.

RTBC: we might find something else > followup. (we need to move on PHP7)
Task: PHP7 ain't a bug.

mookum’s picture

count((array)$array)..

hgoto’s picture

Status: Reviewed & tested by the community » Needs review
Related issues: +#2885610: [PHP 7.2] Avoid count() calls on uncountable variables
StatusFileSize
new2.7 KB
new1002 bytes

The patch in #5 works!

I found the same problem was fixed in the core with the patch #2885610-19: [PHP 7.2] Avoid count() calls on uncountable variables . Maybe it's better to have the same change with the core and I adjusted the patch #5 a little. (Sorry to move back to Needs review.)

herved’s picture

+1 It looks good to me. Thanks.

paulvandenburg’s picture

Regarding #9, on this part of the interdiff:

-      if (is_array($cols) && !empty($cols)) {
+      if (is_array($cols) && count($cols)) {

Why would you use count() instead of !empty() when the only thing we want to know is if it is not empty.
While the count works it seems like the wrong tool for the job.

The empty function could be more performant and/or better optimized. Although I don't know the current benchmarks regarding count() vs empty().

hgoto’s picture

@paulvandenburg:

Why would you use count() instead of !empty() when the only thing we want to know is if it is not empty.

Because the core uses count() in the same line in theme_table() and the performance is not the main interest here, I thought.

I understand your point. I also think empty() is better if this part is not related to the core code and this line is called many times in a request. In my opinion, using the same logic with the core as much as possible is more important here for future maintenance though I don't stick to count(). What do you think?

joseph.olstad’s picture

disclaimer: without looking at the code - patch #9 seems to work for me

joseph.olstad’s picture

Status: Needs review » Reviewed & tested by the community

had a closer look, RTBC

sjerdo’s picture

Patch #9 LGTM +1

martin_klima’s picture

Tested. +1 RTBC

klausi’s picture

Issue tags: +PHP 7.2
joseph.olstad’s picture

I've sent a message to the maintainer, if he doesn't respond in 2 weeks, make an official request to take ownership of this project.

andrey.troeglazov’s picture

Assigned: Unassigned » andrey.troeglazov
Issue tags: +Adminimal Release 7-1.25
joseph.olstad’s picture

Thanks Andrey!

wylbur’s picture

Just adding another confirmation that the patch in #9 resolved the PHP errors in php 7.2.

Looking forward to this patch making it to new release!

  • hgoto authored b09f2e1 on 7.x-1.x
    Issue #2951412 by hgoto, heyyo, maximpodorov, joseph.olstad, pyxio, Rob...
andrey.troeglazov’s picture

Status: Reviewed & tested by the community » Fixed
joseph.olstad’s picture

Thanks Andrey!

andrey.troeglazov’s picture

:)

Status: Fixed » Closed (fixed)

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