When activating taxonomy context module and trying to browse into a vocabulary page the page gets empty
Looking at my PHP logs I found the following errors:

PHP Fatal error: Only variables can be passed by reference in ..\modules\\taxonomy_context\taxonomy_context.module on line 269
PHP Fatal error: Only variables can be passed by reference in ..\modules\\taxonomy_context\taxonomy_context.module on line 284

       case 'term':
          $tidcurrs = preg_split('/[+ ,]/', arg(2));
          $context['tid'] = $tidcurrs[0];
 X -->    $top_parent = array_pop(taxonomy_get_parents_all($context['tid']));
          $context['root_tid'] = $top_parent->tid;
          $term = taxonomy_get_term($context['tid']);
          $context['vid'] = $term->vid;
          break;
      }
      break;
    case 'node':
      if (arg(2) == null) {
        $context['nid'] = arg(1);
        $tidscurr = taxonomy_node_get_terms(arg(1));
        foreach ($tidscurr as $tidcurr) {
          $context['tid'] = $tidcurr->tid;
          break;
        }
 X -->  $top_parent = array_pop(taxonomy_get_parents_all($context['tid']));
        $context['root_tid'] = $top_parent->tid;
        $term = taxonomy_get_term($context['tid']);
        $context['vid'] = $term->vid;
      }

Replacing the problematic lines with the following code solved the problem..

  //$top_parent = array_pop(taxonomy_get_parents_all($context['tid']));  
  $temp = array();
  $temp = taxonomy_get_parents_all($context['tid']);
  $top_parent = array_pop($temp);

Hope this helps someone...

Comments

deekayen’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new1.61 KB

I wasn't able to reproduce this, but it seems like a harmless patch. If nothing else, it increases code readability. Proper patch attached.

lee20’s picture

@Optaglin

I'd be interested to know what PHP Version you were running to see this error and what your error level was set to. It seems odd that this wasn't seen before.

@deekayen

Thanks for the patch!

An alternative syntax would have been to use list(). This eliminates the need for allocating a temp variable, but the difference is trivial.

list($top_parent) = taxonomy_get_parents_all($context['tid']);
lee20’s picture

Status: Reviewed & tested by the community » Fixed
Leeteq’s picture

Status: Fixed » Reviewed & tested by the community

Where is this patch implemented?
(The dev. version is from Jan. 15th, is that the one? The last patch in this thread is at a later date.)

lee20’s picture

Status: Reviewed & tested by the community » Fixed

@DanielTheViking

Thanks for pointing that out. I had committed the patch to HEAD but not to the 5 branch. Therefore the change did not appear in the dev release as it is a nightly snapshot. This should be resolved once the next snapshot is taken.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

optalgin’s picture

Sorry, I upgraded PHP few times since my post :-)
If I remember right, it was PHP5 but I'm not sure the exact version...

Anyway if I ever post again I'll try to add all the information
Thanks for your comments