[sork] Forwards and customSQL

Jan Schneider jan at horde.org
Wed Oct 8 17:02:41 UTC 2008


Zitat von horde at corwyn.net:

>
>
>
> I'm having several problems with forwards running customsql. I'm  
> running the current version, 3.0.1, and trying to get it to work in  
> conjunction with postfixadmin, which I think is imminently doable
>
> The first problem is that when building the SQL query, customsql.php  
> is adding extra single quotes to the SQL. that happens because of  
> the code at ./forwards/Driver/customsql.php:
>
> # RGS changed to stop double quotes
> #$query = str_replace("\U", $this->_db->quote(Auth::getAuth()), $query);
> #$query = str_replace("\T", $this->_db->quote($target), $query);
> #$query = str_replace("\L", $this->_db->quote($keeplocal), $query);
> #$query = str_replace("\P", $this->_db->quote($password), $query);
> $query = str_replace("\U", Auth::getAuth(), $query);
> $query = str_replace("\T", $target, $query);
> $query = str_replace("\L", $keeplocal, $query);
> $query = str_replace("\P", $password, $query);
>
> Example result in /var/log/mysql:
> 60172 Query       INSERT INTO alias (address,goto) VALUES  
> (''test222 at example.com'','''')
>
> Note that there's an extra set of single quotes.

There are extra quotes because you specified them in the queries.  
Don't do that.

> I've already made that code change, to get to the next thing that's  
> causing me issues:
>
>
> forwards does not appear to honor customsql as an option. When I  
> configure forwards to use customSQL, the mysql queries that show up  
> in /var/log/mysql do not appear to use the values from  
> ./horde/forwards/config/conf.php.
>
> forwards/conf.php:
> <?php
> /* CONFIG START. DO NOT CHANGE ANYTHING IN OR AFTER THIS LINE. */
> // $Horde: forwards/config/conf.xml,v 1.7 2005/04/13 18:06:16 chuck Exp $
> $conf['server']['params']['username'] = 'removed';
> $conf['server']['params']['password'] = 'removed';
> $conf['server']['params']['protocol'] = 'unix';
> $conf['server']['params']['database'] = 'postfix';
> $conf['server']['params']['charset'] = 'utf-8';
> $conf['server']['params']['splitread'] = false;
> $conf['server']['params']['phptype'] = 'mysqli';
> $conf['server']['params']['driverconfig'] = 'custom';
> $conf['server']['params']['query_select'] = 'select * from alias  
> where address =
> $conf['server']['params']['query_set'] = 'UPDATE alias SET goto = \T  
> WHERE addre
> $conf['server']['params']['query_disable'] = 'UPDATE alias SET goto  
> = \U WHERE a
> $conf['server']['params']['column_target'] = 'goto';
> $conf['server']['params']['column_keeplocal'] = 'active';
> $conf['server']['driver'] = 'customsql';
> $conf['enabled']['keeplocal'] = false;
> $conf['enabled']['authenticate'] = false;
> $conf['user']['refused'] = array('root', 'bin', 'daemon', 'adm',  
> 'lp', 'shutdown
> $conf['menu']['apps'] = array();
> /* CONFIG END. DO NOT CHANGE ANYTHING IN OR BEFORE THIS LINE. */
>
>
> If I try to make a change to the user's forwards info, I get the  
> following data from /var/log/mysql (with the fix to prevent double,  
> single-quotes):
>  60471 Query       INSERT INTO alias (address,goto) VALUES  
> ('test222 at example.com','test222 at example.com,test222#example.com at autoreply.example.com')
>
> Note that this is an INSERT query, where in conf.php it's set up as  
> an update query.
>
> The same happens for the remove choice, you get a DELETE query:
>  60421 Query       DELETE FROM alias WHERE goto = '\T'
>
> Additionally, note that it's failing to parse out the '\T' to the  
> correct result. Don't care much about that, as I don't want to use  
> this part of the code, but it's still not correct.
>
> As you can see I've figured out how to resolve my problem with too  
> many single-quotes, but I don't quite grok how horde passes around  
> the conf.php values. I know that the problem is in  
> ./forwards/lib/Driver/customsql.php:
>         $query = $this->_params['query_set'];
> and
>         $query = $this->_params['query_disable'];
>
>
> but I don't understand why it's failing to pull the correct value  
> from the conf.php file.

You didn't logout after changing the configuration.

Jan.

-- 
Do you need professional PHP or Horde consulting?
http://horde.org/consulting/



More information about the sork mailing list