SQL syntax error with

Ask community to help.

Moderators: Amaradana, TurboPT, TL Developers

Post Reply
gcomeau
TestLink user
Posts: 8
Joined: Wed Feb 06, 2019 6:06 pm

SQL syntax error with

Post by gcomeau »

There is an issue with the newest version of mysql and the syntax of the softwares queries.

To get around this I modified the php code in installUtils.php

Code: Select all

// 20070310 - $the_host -> $db_host        
if (strlen(trim($db_host)) != 0)
{
  $stmt .= "@" . "'" . $dbhandler->prepare_string($db_host) . "'";
}         
$stmt .= " IDENTIFIED BY '" .  $passwd . "'"; // this is bad
Should be:

Code: Select all

   // 20070310 - $the_host -> $db_host        
if (strlen(trim($db_host)) != 0)
{
  $stmt .= "@" . "'" . $dbhandler->prepare_string($db_host) . "'";
}         
// $stmt .= " IDENTIFIED BY '" .  $passwd . "'"; // this is good
And:

i

Code: Select all

f( strcasecmp('localhost',$db_host) != 0)
  {
    // 20060514 - franciscom - missing 
    $stmt = "GRANT SELECT, UPDATE, DELETE, INSERT ON " . 
             "`" . $dbhandler->prepare_string($db_name) . "`" . ".* TO " . 
             "'" . $dbhandler->prepare_string($login) . "'@'localhost'" .
            " IDENTIFIED BY '" .  $passwd . "'"; // this is bad
    if ( !@$dbhandler->exec_query($stmt) ) 
    {
      $op->msg = "ko - " . $dbhandler->error_msg();
      $op->status_ok=false;
    }
  }
}
Should be:

Code: Select all

if( strcasecmp('localhost',$db_host) != 0)
  {
    // 20060514 - franciscom - missing 
    $stmt = "GRANT SELECT, UPDATE, DELETE, INSERT ON " . 
             "`" . $dbhandler->prepare_string($db_name) . "`" . ".* TO " . 
             "'" . $dbhandler->prepare_string($login) . "'@'localhost'"; // this is good
    if ( !@$dbhandler->exec_query($stmt) ) 
    {
      $op->msg = "ko - " . $dbhandler->error_msg();
      $op->status_ok=false;
    }
  }
}
fman
Member of TestLink Community
Posts: 3123
Joined: Tue Nov 15, 2005 7:19 am

Re: SQL syntax error with

Post by fman »

Hi
thanks.
It would be better for issues to open it on mantis.testlink.org, and if possible provide a Pull Request .
Would you mind to provide MySQL version you are using ?

Important thing is that syntax need to be backward compatible and MariaDB compatible
gcomeau
TestLink user
Posts: 8
Joined: Wed Feb 06, 2019 6:06 pm

Re: SQL syntax error with

Post by gcomeau »

fman wrote:Hi
thanks.
It would be better for issues to open it on mantis.testlink.org, and if possible provide a Pull Request .
Would you mind to provide MySQL version you are using ?

Important thing is that syntax need to be backward compatible and MariaDB compatible
Np, homie. I tried to sign up for an account there but was unable to do so. I would be happy to put a bug report there if I can get an account.

On a side note, we could check for DB version and adjust the syntax accordingly. Personally, I think testlink has a lot of potentials, but it should work with the latest version of mysql. How do I get an account with mantis.
fman
Member of TestLink Community
Posts: 3123
Joined: Tue Nov 15, 2005 7:19 am

Re: SQL syntax error with

Post by fman »

latest MySQL version means 8?

only issue with mantis user creation can be that you do not receive the confirmation email, is that what has happened to you ?
what user name have you used ?
gcomeau
TestLink user
Posts: 8
Joined: Wed Feb 06, 2019 6:06 pm

Re: SQL syntax error with

Post by gcomeau »

Ok, so I was able to sign-up with the same credentials, I will post my findings as a bug report on mantis.
Post Reply