[horde] sql share driver: groups uid and integer cast

Dominique LALOT dom.lalot at gmail.com
Thu Dec 4 09:04:34 UTC 2008


Hello,

I spent a long time to understand a problem with a group driver I wanted 
to develop. A previous mail concerning documentation about developing 
such a driver had never been delivered to list.
My aim was to develop an ldap driver based on attributes values rather 
than on ldap groups.

I quickly get it working. I was able to select my groups under kronolith 
or in admin mode and save kronolith shares in SQL database
kronolith_shares_groups.

But then displaying the form (horde/kronolith/perms.php?share=xxx), my 
groups get lost.. And then spent days adding traces everywhere till I 
found the problem:

My groups uid are alpha-numeric groups like APA01 and so on.

in ./lib/Horde/Share/sql.php

    function _getShareGroups(&$share)
    {
        if ($this->_hasGroups($share)) {
            // Get groups permissions
            $stmt = $this->_db->prepare('SELECT group_uid, perm FROM ' . 
$this->_table . '_groups WHERE share_id = ?');
            if (is_a($stmt, 'PEAR_Error')) {
                Horde::logMessage($stmt, __FILE__, __LINE__, PEAR_LOG_ERR);
                return $stmt;
            }
            $result = $stmt->execute(array($share['share_id']));
            if (is_a($result, 'PEAR_Error')) {
                Horde::logMessage($result, __FILE__, __LINE__, 
PEAR_LOG_ERR);
                return $result;
            } elseif (!empty($result)) {
                while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC)) {
#                    $share['perm']['groups'][*(int)*$row['group_uid']] 
= (int)$row['perm'];

That instruction was the problem converting my groups uid to 0 (no 
warning on cast..) which does not exists

                     $share['perm']['groups'][$row['group_uid']] = 
$row['perm'];
                }
            }
            $stmt->free();
            $result->free();
        }
    }

I know that's not an Horde bug properly speaking. But in sql database, 
the group_uid is varchar(255). So why should we cast?
I also suppose there's another cast somewhere else as one of my 
group_uid saved is 0.
Is it reasonable to change that line?

Dom




-- 
Dominique LALOT
Ingenieur Systeme et Reseaux
Universite de la Mediterrane (Aix-Marseille 2)
http://annuaire.univmed.fr/showuser.php?uid=lalot



More information about the horde mailing list