Generate Stats failing as it seems to use a wrongly composed password

Issue #999 closed
Former user created an issue

Body of error mail produced by crontab:

PHP Fatal error: Uncaught Error: Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' in /var/piler/www/system/database/mysql.php:13
Stack trace:
#0 /var/piler/www/system/db.php(12): MySQL->__construct('localhost', 'piler', '<password>...', 'piler', '')
#1 /usr/local/libexec/piler/generate_stats.php(65): DB->__construct('mysql', 'localhost', 'piler', '<password>...', 'piler', '')
#2 {main}
thrown in /var/piler/www/system/database/mysql.php on line 13

I suspect the three dots are suffixed to the password inadvertedly?

Comments (13)

  1. Janos SUTO repo owner

    I don’t think it’s the 3 dots. Rather the MYSQL_ATTR_INIT_COMMAND. What php version do you have?

  2. Janos SUTO repo owner

    Well, then try removing the array with the 2 PDO::MYSQL_ATTR_INIT_COMMAND entries from /var/piler/www/system/database/mysql.php

    Btw. if that’s your real password in the topic, I suggest you to edit and remove.

  3. Former user Account Deleted reporter
    • edited description

    I obfuscated the password in the first place, but the fact tha Bitbucket doesn’t handle special characters when edit/saving made me copying again unchanged without checking. Changed anyway now .. thanks

  4. Former user Account Deleted reporter

    No, not fixed. Not knowing PHP at all, I replaced the array with NULL? Possibly not what you were expecting. When executing as user piler the line from cron (without >/dev/null)

    /usr/bin/php /usr/local/libexec/piler/generate_stats.php --webui /var/piler/www
    

    I get the error

    Error: could not find driver on database: piler<br />
    
  5. Janos SUTO repo owner

    Yeah, I asked remove, not replace. Make sure the the __construct function looks as follows:

    public function __construct($hostname, $username, $password, $database, $prefix = NULL) {
          try {
             $this->link = new PDO("mysql:host=$hostname;dbname=$database", $username, $password);
          }
          catch(PDOException $exception) {
             exit('Error: ' . $exception->getMessage() . " on database: $database<br />");
          }
    
          $this->affected = 0;
       }
    
  6. Janos SUTO repo owner

    If this won’t fix it, then let me take a look at the host (Check out piler -V for my email). In this case reopen the issue.

  7. Log in to comment