The following warning is logged in dblog:

Warning: count(): Parameter must be an array or an object that implements Countable in reference_option_limit_get_referred_entity_bundle() (line 175 of /var/www/html/sites/default/modules/reference_option_limit/reference_option_limit.module).

The function count() is called on a variable when it is unknown whether or not that variable is an array.

To reproduce

Edit an entityform field's entity reference element.

/admin/structure/entityform_types/manage/ENTITYFORM_ID/fields/FIELD_ID

Comments

jennine created an issue. See original summary.

solideogloria’s picture

Version: 7.x-1.6 » 7.x-1.x-dev
Category: Support request » Bug report

I have this problem, too.

nikunj.shah’s picture

Assigned: Unassigned » nikunj.shah
nikunj.shah’s picture

Assigned: nikunj.shah » Unassigned
Status: Active » Needs review
StatusFileSize
new759 bytes

Hi jennine,

This patch will solve it. Please find the attachment.

Thank you.

solideogloria’s picture

Will $bundles ever be equal to empty string? At the very least, I don't think that it should be if ($bundles && $bundles != ''), because the second half of that if statement will never be checked.

Maybe this?

      if (is_array($bundles) && count($bundles)) {
        return $bundles;
      }
nikunj.shah’s picture

StatusFileSize
new761 bytes
solideogloria’s picture

Same as before, you don't need to check it twice. If it's empty $bundles is FALSE, if not, then TRUE. So the code will never check if !empty($bundles). You can just do one or the other.

https://www.php.net/manual/en/function.empty.php

snehalgaikwad’s picture

StatusFileSize
new749 bytes

Kept only one condition to check if $bundles has value.

snehalgaikwad’s picture

StatusFileSize
new705 bytes

Removed count() and used empty() only for checking if variable is empty.

xoruna’s picture

I applied the patch in #9 and it works for me, thanks.

solideogloria’s picture

StatusFileSize
new603 bytes

I noticed the return statement is indented with 4 spaces in patch #9. I fixed it to be 2.

I also fixed the patch naming. Underscores are only for the module name, I think, otherwise it's unclear what the module name is at a glance.

xoruna’s picture

Status: Needs review » Reviewed & tested by the community

I applied your patch #11 on the last version of the module 1.7 and it works, thanks.
Maybe it could be checked and committed in a next release?

solideogloria’s picture

Issue summary: View changes

Yep. Still applies and works. Hope this will get fixed in a release soon.