There was an error in 1.1 version for D7 (maybe it is already fixed in repository). I am not comfortable with D7 API (only D6), so may be I am wrong somewhere, please check me.

First issue:

function _taxonomy_menu_get_terms($vid) {
  $result = db_select('taxonomy_term_data', 'td')
    ->condition('vid', $vid)
    ->addField('td', 'tid')
    ->execute();
  return $result->fetchAll();
}

addField returns new field alias, not SelectQuery object, so we get an error here (PHP says that could not do ->execute() on non-object). Also this function is recommended to use just when we need to know assigned alias, otherwise we could use ->fields() (http://api.drupal.org/api/drupal/includes--database--select.inc/function...).

My variant:

function _taxonomy_menu_get_terms($vid) {
  $result = db_select('taxonomy_term_data', 'td')
    ->condition('vid', $vid)
    ->fields('td', array('tid'))
    ->execute();
   
  return $result->fetchAll();
}

2) Issue like previous one in the same file:

function _taxonomy_menu_get_vid_by_tid($tids) {
  if ($tids) {
    $result = db_select('term_data')
      ->condition('tid', $tids, 'IN')
      ->addField('vid')
      ->distinct()
      ->execute();
    $vids = array();
    return $result->fetchAllAssoc('vid');
  }
}

There is ->addField()->something. And maybe one more error: addField requires 2 arguments (table_alias, field), so may be right code looks like:

function _taxonomy_menu_get_vid_by_tid($tids) {
  if ($tids) {
    $result = db_select('term_data')
      ->condition('tid', $tids, 'IN')
      ->fields('term_data', array('vid'))
      ->distinct()
      ->execute();
    $vids = array();
    return $result->fetchAllAssoc('vid');
  }
}

But in that case I am not so sure.

Comments

dstol’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Status: Active » Needs work

@Aracon, mind submitting a patch for this? It's kinda hard to follow.

Aracon’s picture

I'm not very experienced in creating pathes for Drupal and working with git, so I hope I made all properly.

Aracon’s picture

Status: Needs work » Needs review
frank ralf’s picture

I got the same (or similar) error with a Drupal 7.4 install. The patch seems to have fixed the problem.

Frank

frank ralf’s picture

I applied the patch successfully to the 7.x-1.2 version (which seems to be identical to the dev version, unfortunately both don't seem to be available via CVS which makes creating patches a bit cumbersome).

However, I still get the error message described at #670346: Undefined index/property notices.

dstol’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

SlyK’s picture

Status: Closed (fixed) » Needs review

So this fix is still not released :(

Got another error: function _taxonomy_menu_get_terms() doesn't work as designed, because fetchAll() will return array of OBJECTS. And this leads to error in taxonomy_menu_path_default() on implode function. Example of bad return value:

Array
(
    [0] => stdClass Object
        (
            [tid] => 48
        )

    [1] => stdClass Object
        (
            [tid] => 9
        )
)

Easy fix for this will be replace

return $result->fetchAll();

with

return $result->fetchAllKeyed(0,0);
barrett’s picture

Status: Needs review » Closed (fixed)

SlyK, the issue reported by the poster is fixed in the current 7.x-1.x-dev version. If you're still experiencing the other problem, please open a new issue.