I get the following notice:

Notice: Trying to get property of non-object in taxonomy_entity_query_alter() (line 2053 of /[..]/modules/taxonomy/taxonomy.module).

Digging deeper, I found this in taxonomy_feeds_set_target():

  if (!isset($cache['allowed_vocabularies'][$target])) {
    foreach ($info['settings']['allowed_values'] as $tree) {
      if ($vocabulary = taxonomy_vocabulary_machine_name_load($tree['vocabulary'])) {
        $cache['allowed_vocabularies'][$target][$vocabulary->vid] = $vocabulary->machine_name;
      }
    }
  }

  $query = new EntityFieldQuery();
  $query->entityCondition('entity_type', 'taxonomy_term')
    ->entityCondition('bundle', $cache['allowed_vocabularies'][$target])
    ->range(0, 1);

Problem: The above code intends to guarantee that $cache['allowed_vocabularies'][$target] will not be empty.
But this will fail if $info['settings']['allowed_values'] is empty, or if a vocabulary with the machine name from $tree['vocabulary'] does not exist.

This probably means that field settings point to a deleted or non-existing vocabulary. Typical deployment fails.
Either way, taxonomy_feeds_set_target() should properly initialize $cache['allowed_vocabularies'][$target], before going into the foreach() loop.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

donquixote’s picture

Hm, I notice that empty arrays in conditions are no good either.
The function should have a special behavior for this case..

donquixote’s picture

The following seems to work. Not sure if that is a good solution.

  $query = new EntityFieldQuery();
  $query->entityCondition('entity_type', 'taxonomy_term');
  if (!empty($cache['allowed_vocabularies'][$target])) {
    $query->entityCondition('bundle', $cache['allowed_vocabularies'][$target]);
    $query->range(0, 1);
  }
  else {
    return;
  }
MegaChriz’s picture

donquixote’s picture

Status: Active » Needs review
FileSize
735 bytes

Probably related or the same symptom, yes.
I am going to post my patch here, just because this issue describes the underlying problem that this particular patch is going to fix, instead of focusing on the symptom.

I can re-post the patch in the other issue if that is desired.

twistor’s picture

Status: Needs review » Fixed

Opps. Forgot the test.

Status: Fixed » Closed (fixed)

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