Strict warning: Only variables should be passed by reference in reference_option_limit_get_referred_entity_bundle() (line 184 of /www/sites/all/modules/reference_option_limit/reference_option_limit.module).

Comments

joachim’s picture

Status: Active » Postponed (maintainer needs more info)

For line 184 I have:

        $bundle = array_pop(array_keys($entity_info['bundles']));

Could you check and see if your entity type has bundles defined? IIRC they always should!

Mołot’s picture

It's standard Basic Page, new node form. Drupal 7.23 (upgraded from 7.20 one minor version at a time). Some custom modules, but no other modules touching entities workflow in a way that should matter. Just admin menu, internationalization package and my custom forms writing to my custom tables that aren't even in my main Drupal database.

Mołot’s picture

Status: Postponed (maintainer needs more info) » Active

If you need any more info, please tell what exactly. Anyway, if it's possible to have bundles not defined, I think modules should test for it and output something meaningful to the watchdog, not to allow PHP error to happen.

joachim’s picture

Can you debug the entity info at that point?

From https://api.drupal.org/api/drupal/includes!common.inc/function/entity_ge...

        // If no bundle key is provided, assume a single bundle, named after
        // the entity type.
        if (empty($entity_info[$name]['entity keys']['bundle']) && empty($entity_info[$name]['bundles'])) {
          $entity_info[$name]['bundles'] = array($name => array('label' => $entity_info[$name]['label']));
        }

Entity info should always have a bundles array.

Mołot’s picture

At what point? I mean, I don't have any custom code. It's built-in entity - good old basic page node. So if you want me to put dpr() somewhere, please tell me where. In your module just before line 184?

joachim’s picture

I've had a thought -- could it be the combination of array_pop(array_keys())?

What version of PHP are you running?

Mołot’s picture

5.4.14

joachim’s picture

Version: 7.x-1.4 » 7.x-1.x-dev

Yup it'll be that then.

The result of array_keys() needs to be set in a variable to then be passed to array_pop().

Mołot’s picture

I guess it's a change simple enough you don't really need anyone to create a patch?

jgullstr’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new619 bytes

Still getting this warning in current dev.

joachim’s picture

Status: Needs review » Fixed

I'm always a bit wary of the PHP functions for returning an item from an array (end(), key(), etc), because they all speak of returning the item for 'the current array pointer location' and that's something that's sort of concealed, and therefore doesn't feel reliable...

But this seems to be ok, so let's go with it :)

  • Commit 6c3798c on 7.x-1.x authored by jgullstr, committed by joachim:
    Issue #2082217 by jgullstr: Fixed invalid pass by reference.
    

Status: Fixed » Closed (fixed)

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