diff --git a/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration31.php b/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration31.php index ee0fbaf845..0ef523e973 100644 --- a/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration31.php +++ b/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration31.php @@ -103,12 +103,12 @@ class Migration31 implements MigrationInterface $val = serialize($val); break; case \registry::TYPE_INTEGER: + $val = (int) $val; break; case \registry::TYPE_BOOLEAN: $val = $val ? '1' : '0'; break; case \registry::TYPE_STRING: - $val = (int) $val; default: $val = (string) $val; $type = \registry::TYPE_STRING; diff --git a/lib/classes/ACL.class.php b/lib/classes/ACL.class.php index c79f677c1d..723f82d2bd 100644 --- a/lib/classes/ACL.class.php +++ b/lib/classes/ACL.class.php @@ -665,8 +665,9 @@ class ACL implements cache_cacheableInterface foreach ($databox->get_collections() as $collection) { $continue = false; - if (!array_key_exists($collection->get_base_id(), $this->_rights_bas)) + if (!array_key_exists($collection->get_base_id(), $this->_rights_bas)) { continue; + } $base_id = $collection->get_base_id(); $datas = $this->_rights_bas[$base_id]; @@ -677,12 +678,13 @@ class ACL implements cache_cacheableInterface break; } } - if ($continue || $this->is_limited($base_id)) + if ($continue || $this->is_limited($base_id)) { continue; + } try { $ret[$base_id] = collection::get_from_base_id($this->app, $base_id); - } catch (Exception $e) { + } catch (\Exception $e) { } } @@ -823,7 +825,7 @@ class ACL implements cache_cacheableInterface FROM usr WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->user->get_id())); + $stmt->execute(array(':usr_id' => $this->user->get_id())); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); unset($stmt); diff --git a/lib/classes/User/Adapter.class.php b/lib/classes/User/Adapter.class.php index 25f3dd5e2f..3fe3f47b67 100644 --- a/lib/classes/User/Adapter.class.php +++ b/lib/classes/User/Adapter.class.php @@ -322,6 +322,21 @@ class User_Adapter implements User_Interface, cache_cacheableInterface return $this; } + public static function unsetInstances() + { + foreach (self::$_instance as $id => $user) { + self::unsetInstance($id); + } + } + + public static function unsetInstance($id) + { + if (isset(self::$_instance[$id])) { + self::$_instance[$id] = null; + unset(self::$_instance[$id]); + } + } + /** * * @param type $id diff --git a/lib/classes/User/Query.class.php b/lib/classes/User/Query.class.php index b42f35fa5a..2a8f102032 100644 --- a/lib/classes/User/Query.class.php +++ b/lib/classes/User/Query.class.php @@ -542,7 +542,7 @@ class User_Query implements User_QueryInterface $sql_count = 'SELECT COUNT(DISTINCT usr.usr_id) as total ' . $this->generate_sql_constraints(); - + $stmt = $conn->prepare($sql_count); $stmt->execute($this->sql_params); $row = $stmt->fetch(PDO::FETCH_ASSOC); diff --git a/lib/classes/record/adapter.class.php b/lib/classes/record/adapter.class.php index d6c9377c42..98a1c10969 100644 --- a/lib/classes/record/adapter.class.php +++ b/lib/classes/record/adapter.class.php @@ -1617,7 +1617,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface } $sphinx_rt->delete(array("documents" . $sbas_crc, "documents" . $sbas_crc . "_stemmed_fr", "documents" . $sbas_crc . "_stemmed_en"), "docs_realtime" . $sbas_crc, $this->get_record_id()); } - } catch (Exception $e) { + } catch (\Exception $e) { unset($e); } diff --git a/lib/classes/registry.class.php b/lib/classes/registry.class.php index ff26c49049..a745f892d5 100644 --- a/lib/classes/registry.class.php +++ b/lib/classes/registry.class.php @@ -25,11 +25,6 @@ class registry implements registryInterface */ protected $cache; - /** - * - * @var registry - */ - protected static $_instance; protected $app; const TYPE_BOOLEAN = 'boolean'; diff --git a/lib/classes/sphinxrt.class.php b/lib/classes/sphinxrt.class.php index 02be0072d0..f05d9e9b3f 100644 --- a/lib/classes/sphinxrt.class.php +++ b/lib/classes/sphinxrt.class.php @@ -24,12 +24,17 @@ class sphinxrt protected function __construct(registry $registry) { $this->registry = $registry; + + if(!$registry->get('GV_sphinx') || !$registry->get('GV_sphinx_rt_host') || !$registry->get('GV_sphinx_rt_port')) { + throw new \Exception('Sphinx not configured'); + } + try { $dsn = sprintf('mysql:host=%s;port=%s;', $registry->get('GV_sphinx_rt_host'), $registry->get('GV_sphinx_rt_port')); $this->connection = @new PDO($dsn); - } catch (Exception $e) { + } catch (\Exception $e) { self::$_failure = true; - throw new Exception('Unable to connect to sphinx rt'); + throw new \Exception('Unable to connect to sphinx rt'); } return $this; diff --git a/tests/Alchemy/Phrasea/Setup/InstallerTest.php b/tests/Alchemy/Phrasea/Setup/InstallerTest.php index d219020f24..0c02e390d4 100644 --- a/tests/Alchemy/Phrasea/Setup/InstallerTest.php +++ b/tests/Alchemy/Phrasea/Setup/InstallerTest.php @@ -27,7 +27,10 @@ class InstallerTest extends \PHPUnit_Framework_TestCase public static function tearDownAfterClass() { + $app = new Application('test'); \connection::close_connections(); + \phrasea::reset_sbasDatas($app['phraseanet.appbox']); + \phrasea::reset_baseDatas($app['phraseanet.appbox']); parent::tearDownAfterClass(); } @@ -54,6 +57,8 @@ class InstallerTest extends \PHPUnit_Framework_TestCase $installer = new Installer($app, 'admin@example.com', 'sdfsdsd', $abConn, 'http://local.phrasea.test.installer/', $dataPath, $dbConn, $template); $installer->install(); + \User_Adapter::unsetInstances(); + $this->assertTrue($specifications->isSetup()); $this->assertTrue($app['phraseanet.configuration-tester']->isUpToDate()); }