[aur-dev] [PATCH] Fix DB.class.php to match config

Lukas Fleischer lfleischer at archlinux.org
Wed Nov 9 18:56:23 UTC 2016


On Wed, 09 Nov 2016 at 04:23:22, Mark Weiman wrote:
> In commit baf8a220, conf/config.proto was changed so that dsn_prefix
> was changed to backend and this fixes this in web/lib/DB.class.php.
> 
> Signed-off-by: Mark Weiman <mark.weiman at markzz.com>
> ---
>  web/lib/DB.class.php | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 

Good catch. The dsn_prefix parameter was indeed replaced by the backend
parameter in commit baf8a22 (git-interface: Support SQLite as database
backend, 2016-08-03). However, it is more than a simple rename. The new
parameter allows for using SQLite instead of MySQL and I doubt that this
actually works after your patch; especially since host, socket, user and
password can be unset if SQLite is used.

So instead of pretending that the variable was renamed, we should either
add SQLite support to DB.class.php or simply check whether backend is
something other than "mysql" and bail out. Since the main reason for
adding SQLite was making the test suite simpler and faster, I am fine
with the second option. Opinions?

> diff --git a/web/lib/DB.class.php b/web/lib/DB.class.php
> index b538e0d..f6fd7ad 100644
> --- a/web/lib/DB.class.php
> +++ b/web/lib/DB.class.php
> @@ -17,14 +17,14 @@ class DB {
>         public static function connect() {
>                 if (self::$dbh === null) {
>                         try {
> -                               $dsn_prefix = config_get('database', 'dsn_prefix');
> +                               $backend = config_get('database', 'backend');
>                                 $host = config_get('database', 'host');
>                                 $socket = config_get('database', 'socket');
>                                 $name = config_get('database', 'name');
>                                 $user = config_get('database', 'user');
>                                 $password = config_get('database', 'password');
>  
> -                               $dsn = $dsn_prefix .
> +                               $dsn = $backend .
>                                        ':host=' . $host .
>                                        ';unix_socket=' . $socket .
>                                        ';dbname=' . $name;
> -- 
> 2.10.2


More information about the aur-dev mailing list