Taxonomy Wrapper 1.26.2.2: taxonomy_get_vocabulary as object instead of array?

falk_g - November 25, 2008 - 10:50
Project:Category
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:falk_g
Status:closed
Description

I just had a thorough look through the taxonomy wrapper because there are things that seem fishy. The first thing I wanted to get out of the way is why tokens [vocab] never returned anything. I think I found the problem pretty much right away.

the function taxonomy_get_vocabulary is converting the object returned from category_get_container into an array. Now I have no idea why that is because the original taxonomy_get_vocabulary from drupal also returns an object instead of an array. I switched it from producing an array to producing an object and voilá tokens [vocab] is working as expected. I expect this to remedy other problems where vocabs are not resolved (views maybe?). So again I only have a surface understanding of things and the array might have been in there for good - but at the moment I can only see things working better rather then worse.

so change line 792-805 from

<?php

  $vocabulary
['vid'] = $container->cid;
 
$vocabulary['name'] = $container->title;
 
$vocabulary['description'] = $container->cont_description;
 
$vocabulary['help'] = $container->help;
 
$vocabulary['relations'] = $container->has_relations;
 
$vocabulary['hierarchy'] = $container->hierarchy;
 
$vocabulary['multiple'] = $container->multiple;
 
$vocabulary['required'] = $container->required;
 
$vocabulary['tags'] = $container->tags;
 
$vocabulary['module'] = $container->module;
 
$vocabulary['weight'] = $container->cont_weight;
 
$vocabulary['nodes'] = $container->nodes;
?>

to

<?php

  $vocabulary
->vid = $container->cid;
 
$vocabulary->name = $container->title;
 
$vocabulary->description = $container->cont_description;
 
$vocabulary->help = $container->help;
 
$vocabulary->relations = $container->has_relations;
 
$vocabulary->hierarchy = $container->hierarchy;
 
$vocabulary->multiple = $container->multiple;
 
$vocabulary->required = $container->required;
 
$vocabulary->tags = $container->tags;
 
$vocabulary->module = $container->module;
 
$vocabulary->weight = $container->cont_weight;
 
$vocabulary->nodes = $container->nodes;
?>

A coding gods input would be welcomed.

#1

falk_g - November 25, 2008 - 10:51

ugh and delete

<?php
  $vocabulary
= array();
?>

in line 792 of course.

#2

falk_g - November 25, 2008 - 10:52
Status:needs work» needs review

#3

JirkaRybka - September 5, 2009 - 18:50
Status:needs review» fixed

Marked #176276: taxonomy_get_vocabulary function in taxonomy wrapper module returns array but it must return same information as object as duplicate.

As of 6.x, the function doesn't even exist. There's taxonomy_vocabulary_load(), which is more or less verbatim from core, having no such problem.

As of 5.x, the messages are seemingly mixed: In CVS there seems to be currently two 5.x branches, where 'DRUPAL-5' have this fixed in latest revision of the file, and 'DRUPAL-5--2' doesn't. The fix didn't make it to any stable release. But the available 5.x-1.x-dev tarball does have the fix - so that's at least one release fixed (although just a development snapshot), and a proof that the fix got committed.

So I believe this is Fixed one... Whether new releases are rolled after such fixes, that's a differernt question (and frankly, I had problems with that regarding several Drupal projects), but it doesn't stop issues here becoming 'fixed' after commit ;-)

#4

System Message - September 19, 2009 - 19:00
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.