Correction : php5-fpm & MySQL : is not a valid MySQL-Link resource.
[lhc/ateliers.git] / etc / php5 / fpm / auto_prepend_file.php
diff --git a/etc/php5/fpm/auto_prepend_file.php b/etc/php5/fpm/auto_prepend_file.php
new file mode 100644 (file)
index 0000000..d44bad0
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+function shutdown_mysql_close() {
+       // NOTE: fix things like this :
+       // Warning:  mysql_select_db(): 2 is not a valid MySQL-Link resource in test.php
+       // which is likely due to php5-fpm not correctly destroying all PHP variables ;
+       // uses auto_prepend_file in php.ini :
+       // - works when script ends or exit() is called;
+       // - works when mysql.so is loaded or not;
+       // - not sure if this works with multiple MySQL connexions.
+       if(function_exists('mysql_close'))
+               @mysql_close();
+ }
+register_shutdown_function('shutdown_mysql_close');
+?>