concretecms / concrete5-legacy

Legacy repository for concrete5
http://www.concrete5.org
559 stars 323 forks source link

PHP 7.2 warning on page_owner.php #1970

Closed ConcreteOwl closed 6 years ago

ConcreteOwl commented 6 years ago

The following warning is displayed when a user attempts to edit a block. Warning: count(): Parameter must be an array or an object that implements Countable in /xxxx/xxxx/concrete/core/models/permission/access/entity/types/page_owner.php on line 24

Line 24 if (count($users) == 0) {

I have 'fixed' this with this code

Line 24 if (count((array)$users) == 0) {

Although this has stopped the PHP warnings, I am not sure if this is the correct way?

ConcreteOwl commented 6 years ago

This code also 'fixes' this issue if (!is_array($users) || count($users) == 0) {

mlocati commented 6 years ago

See #1971

ConcreteOwl commented 6 years ago

Thanks Michele, I knew there must be a better way of fixing this..

mlocati commented 6 years ago

David: your solution fixed this specific problem, and it's correct. BTW with my approach we are sure to not break code in other points where PHP tries to count the result of the getAccessEntityUsers method.

ConcreteOwl commented 6 years ago

Ah Yes, I understand.. Thank You