[dev] Datatree changes break giapeto

x3n` x3n at molinier.eu
Mon Mar 5 19:02:04 UTC 2007


I've also noted this problem. I propose the following patch which make
an recursive search of the full path (it replace the whole function
getId. It solved the problem from me


        $query = 'SELECT datatree_id FROM ' . $this->_params['table'] .
                 ' WHERE group_uid = ? AND datatree_name = ?' .
                 ' AND datatree_parents = ?';

        $rootLine=explode(':', $name);
        $id=array();

        foreach($rootLine as $node) {
          $result = $this->_db->getOne($query,
array($this->_params['group'],$node,count($id)?':'.implode(':',$id):''));
          if (is_a($result, 'PEAR_Error')) {
              return null;
          } else {
              array_push($id,$result);
          }
        }
        return $id[count($id)-1];



I don't know if there is another (more elegant ?) to do this... Perhaps
some core developer might answer this question :)


Best regards,
x3n

Roel Gloudemans a écrit :
> I think I found an inconsistency in the DataTree code.
> 
> In DataTree.php:
> 
> function getId($name)
> {
>      ....
>      /* Flip the name map to look up the id using the name as key. */
>      if (($id = array_search($name, $this->_nameMap)) !== false) {
>          return $id;
>      }
>      /* Not found in name map, consult the backend. */
>      $id = $this->_getId($name);
>      ....
> }
> 
> The namemap contains the full namepath (with : as separator). If the  
> name is not in the namemap, getId is called with the full namepath
> 
> in DataTree/sql.php
> function _getId($name)
> {
>      $query = 'SELECT datatree_id FROM ' . $this->_params['table'] . '  
> WHERE group_uid = ? AND datatree_name = ?';
>      $values = array($this->_params['group'], $name);
>      ....
> }
> 
> So the query is done using the full namepath, but that is not the way  
> it is stored in the database.
> 
> Cheers,
> Roel.
> 
> 
> Quoting Chuck Hagenbuch <chuck at horde.org>:
> 
>> Quoting Roel Gloudemans <roel at gloudemans.info>:
>>
>>> The update from 1.180 to 1.181 breaks giapeto.
>> Update again please.
>>
>> -chuck
>>
>> -- 
>> "we are plastered to the windshield of the bus that is time." - Chris
>>
>> -- 
>> Horde developers mailing list - Join the hunt: http://horde.org/bounties/
>> Frequently Asked Questions: http://horde.org/faq/
>> To unsubscribe, mail: dev-unsubscribe at lists.horde.org
> 
> 
> 


More information about the dev mailing list