Doctrine ORM: Exception “Duplicate entry ‘2147483647’”

I was storing Facebook and Twitter profile IDs and I got this error:

  [Doctrine\DBAL\Driver\PDOException]
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2147
  483647' for key 'PRIMARY'

  [PDOException]
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2147
  483647' for key 'PRIMARY'

When I went back to my data there was no ID with 2147483647 value. Then I realized that 2147483647 is the maximun value you can store in MySQL with a Doctrine integer type. So I just changed integer to bigint in my entities and the problem was solved.

class TwitterProfile
{
    /**
     * @ORM\Id
     * @ORM\Column(type="bigint")
     */
    protected $id;
    ...
}

doctrine-mysql-duplicate-entry-2147483647

Clear internal DNS cache in Google Chrome

I was moving a client’s web from one hosting to another and after checking that the DNS registers have already been updated I could load the page on the new server in Chrome. It was like still trying to reach the old IP. Then I assumed Chrome has some kind of DNS cache, and sure it does. If you want to clear it open chrome://net-internals/#dns and press “Clear host cache”.

google-chrome-dns-cache

Ref: http://superuser.com/questions/203674/how-to-clear-flush-the-dns-cache-in-google-chrome

Change between multiple versions of PHP with Apache in Mac Ports

If you have for example 2 different versions of PHP in the same machine you can switch between them by just using APache eXtenSion tool:

For example to enable PHP 5.4:

cd /opt/local/apache2/modules
sudo /opt/local/apache2/bin/apxs -a -e -n php5 mod_php54.so

To enable PHP 5.6:

cd /opt/local/apache2/modules
sudo /opt/local/apache2/bin/apxs -a -e -n php5 mod_php56.so

apache_logo

Fix “Class ‘PMA_Message’ not found” in phpMyAdmin with nginx + PHP_FPM

After updating phpMyAdmin I got this error:

PHP message: PHP Fatal error:  Class 'PMA_Message' not found in /usr/share/phpMyAdmin/libraries/Message.class.php on line 649" while reading upstream, client: xxx.xxx.xxx.xxx, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "myweb.com"
2014/12/20 18:05:28 [error] 27827#0: *30369 FastCGI sent in stderr: "PHP message: PHP Notice:  Undefined property: PMA_Error::$hash in /usr/share/phpMyAdmin/libraries/Error.class.php on line 169
PHP message: PHP Notice:  Undefined property: PMA_Error::$isDisplayed in /usr/share/phpMyAdmin/libraries/Message.class.php on line 724
PHP message: PHP Notice:  Undefined property: PMA_Error::$params in /usr/share/phpMyAdmin/libraries/Message.class.php on line 538

The problem was that the /var/lib/php/session owner group had changed and was no more owned by nginx. This solved the issue:

# chown root:nginx /var/lib/php/session

PhpMyAdmin-Logo

Ref: http://incredimike.com/2011/04/phpmyadmin-installation-errors/

MySQL can’t start after updating from 5.1 to 5.5

After updating a MySQL server from 5.1.73 to 5.5.4 it won’t start. To see what was going on I checked the logs:

# tail /var/log/mysql.log
141221 13:23:41  InnoDB: Waiting for the background threads to start
141221 13:23:42 InnoDB: 5.5.41 started; log sequence number 1589339
141221 13:23:42 [ERROR] /usr/libexec/mysqld: unknown variable 'record_buffer=1M'
141221 13:23:42 [ERROR] Aborting

It was obvious that many things had changed form 5.1 to 5.5 and in this case the reason to the problem was that record_buffer has been deprecated and now it’s called read_buffer_size. Changing the name of it in /etc/my.cnf fixed the problem.

mysql