diff --git a/composer.json b/composer.json index aafbe7fbfb..f51dc21abf 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "jms/serializer" : "~0.10", "justinrainbow/json-schema" : "~1.3", "mediavorus/mediavorus" : "~0.4.0", - "media-alchemyst/media-alchemyst" : "~0.3.1", + "media-alchemyst/media-alchemyst" : "~0.4, >=0.4.3", "monolog/monolog" : "~1.3", "mrclay/minify" : "~2.1.6", "neutron/process-manager" : "~1.0", @@ -31,6 +31,7 @@ "neutron/sphinxsearch-api" : "~2.0.6", "neutron/recaptcha" : "~0.1.0", "neutron/temporary-filesystem" : "~2.1", + "php-ffmpeg/php-ffmpeg" : "~0.4, >=0.4.3", "php-xpdf/php-xpdf" : "~0.2.1", "phpexiftool/phpexiftool" : "~0.3", "silex/silex" : "1.1.x-dev@dev", diff --git a/composer.lock b/composer.lock index 033f4cf230..e9acd51248 100644 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "daac732f5ff830bcaf81da6ecf16f9e2", + "hash": "c8348e356ce79bc133510a11279d48c9", "packages": [ { "name": "alchemy-fr/tcpdf-clone", @@ -1574,26 +1574,26 @@ }, { "name": "media-alchemyst/media-alchemyst", - "version": "0.3.6", + "version": "0.4.3", "source": { "type": "git", "url": "https://github.com/alchemy-fr/Media-Alchemyst.git", - "reference": "86a16aab82b6e31d2e70050f61fa815a98037253" + "reference": "319f55c2265a9056d68f1f0e6314dce977ef47ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/alchemy-fr/Media-Alchemyst/zipball/86a16aab82b6e31d2e70050f61fa815a98037253", - "reference": "86a16aab82b6e31d2e70050f61fa815a98037253", + "url": "https://api.github.com/repos/alchemy-fr/Media-Alchemyst/zipball/319f55c2265a9056d68f1f0e6314dce977ef47ef", + "reference": "319f55c2265a9056d68f1f0e6314dce977ef47ef", "shasum": "" }, "require": { "alchemy/ghostscript": "~0.4.0", "imagine/imagine": "0.6.x@dev", - "mediavorus/mediavorus": "~0.4.0", + "mediavorus/mediavorus": "~0.4.2", "monolog/monolog": "~1.0", "neutron/temporary-filesystem": "~2.1", "php": ">=5.3.3", - "php-ffmpeg/php-ffmpeg": "~0.3, >=0.3.4", + "php-ffmpeg/php-ffmpeg": "~0.4.2", "php-mp4box/php-mp4box": "~0.3.0", "php-unoconv/php-unoconv": "~0.3.0", "pimple/pimple": "~1.0", @@ -1643,7 +1643,7 @@ "video", "video processing" ], - "time": "2013-10-21 12:41:18" + "time": "2013-12-03 17:07:51" }, { "name": "mediavorus/mediavorus", diff --git a/lib/Alchemy/Phrasea/Core/Version.php b/lib/Alchemy/Phrasea/Core/Version.php index a22a92e121..28af745b0f 100644 --- a/lib/Alchemy/Phrasea/Core/Version.php +++ b/lib/Alchemy/Phrasea/Core/Version.php @@ -15,6 +15,8 @@ class Version { protected static $number = '3.9.0-alpha.9'; protected static $name = 'Epanterias'; + protected static $number = '3.8.3-alpha.1'; + protected static $name = 'Diplodocus'; public static function getNumber() { diff --git a/lib/Doctrine/Repositories/SessionRepository.php b/lib/Doctrine/Repositories/SessionRepository.php new file mode 100644 index 0000000000..8e334961f5 --- /dev/null +++ b/lib/Doctrine/Repositories/SessionRepository.php @@ -0,0 +1,26 @@ +_em->createQuery($dql); + $query->setParameters(array('usr_id' => $user->get_id())); + + return $query->getResult(); + } +} diff --git a/lib/classes/User/Adapter.php b/lib/classes/User/Adapter.php index 6581f0b729..8fbcebf4f6 100644 --- a/lib/classes/User/Adapter.php +++ b/lib/classes/User/Adapter.php @@ -751,6 +751,12 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $this->app['EM']->remove($order); } + $repo = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Session'); + + foreach ($repo->findByUser($this) as $session) { + $this->app['EM']->remove($session); + } + $this->app['EM']->flush(); $sql = 'UPDATE usr SET usr_login = :usr_login , usr_mail = null diff --git a/lib/classes/patch/383alpha1a.php b/lib/classes/patch/383alpha1a.php new file mode 100644 index 0000000000..269e00c837 --- /dev/null +++ b/lib/classes/patch/383alpha1a.php @@ -0,0 +1,84 @@ +release; + } + + /** + * {@inheritdoc} + */ + public function require_all_upgrades() + { + return false; + } + + /** + * {@inheritdoc} + */ + public function getDoctrineMigrations() + { + return []; + } + + /** + * {@inheritdoc} + */ + public function concern() + { + return $this->concern; + } + + /** + * {@inheritdoc} + */ + public function apply(base $appbox, Application $app) + { + // Remove deleted users sessions + $sql = 'SELECT s.id FROM `Sessions` s, usr u WHERE u.usr_login LIKE "(#deleted%" AND u.usr_id = s.usr_id'; + $stmt = $appbox->get_connection()->prepare($sql); + $stmt->execute(); + $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC); + $stmt->closeCursor(); + + foreach ($rows as $row) { + if (null !== $session = $app['EM']->find('Alchemy\Phrasea\Model\Entities\Session', $row['id'])) { + $app['EM']->remove($session); + } + } + + // Remove API sessions + $query = $app['EM']->createQuery('SELECT s FROM Alchemy\Phrasea\Model\Entities\Session s WHERE s.user_agent LIKE :guzzle'); + $query->setParameter(':guzzle', 'Guzzle%'); + + foreach ($query->getResult() as $session) { + $app['EM']->remove($session); + } + + $app['EM']->flush(); + + return true; + } +} diff --git a/tests/classes/userTest.php b/tests/classes/userTest.php index bb960af300..47cdd23336 100644 --- a/tests/classes/userTest.php +++ b/tests/classes/userTest.php @@ -49,6 +49,29 @@ class userTest extends PhraseanetPHPUnitAbstract $this->assertNull($repo->findWithProviderAndId('custom-one', 12345)); } + public function testDeleteSetMailToNullAndRemovesSessions() + { + try { + $usrId = \User_Adapter::get_usr_id_from_login(self::$DI['app'], 'test_phpunit_sessions'); + $user = \User_Adapter::getInstance($usrId, self::$DI['app']); + } catch (\Exception $e) { + $user = \User_Adapter::create(self::$DI['app'], 'test_phpunit_sessions', 'any', null, false); + } + + $session = new \Alchemy\Phrasea\Model\Entities\Session(); + $session + ->setUsrId($user->get_id()) + ->setUserAgent(''); + + self::$DI['app']['EM']->persist($session); + self::$DI['app']['EM']->flush(); + + $user->delete(); + + $repo = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Session'); + $this->assertCount(0, $repo->findByUser($user)); + } + public function testGetPref() { $user = $this->get_user();