From d28afc8d67d73f6c378867984a691263be2cb723 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Thu, 31 Oct 2013 16:46:12 +0100 Subject: [PATCH 01/10] Fix #1556 Ajax issue when loading bridge playlists --- .../actions/Bridge/Dailymotion/actioncontainers.html.twig | 4 ++-- .../web/prod/actions/Bridge/Flickr/actioncontainers.html.twig | 4 ++-- .../prod/actions/Bridge/Youtube/actioncontainers.html.twig | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/templates/web/prod/actions/Bridge/Dailymotion/actioncontainers.html.twig b/templates/web/prod/actions/Bridge/Dailymotion/actioncontainers.html.twig index 0fc7e8dd8d..4abf04be54 100644 --- a/templates/web/prod/actions/Bridge/Dailymotion/actioncontainers.html.twig +++ b/templates/web/prod/actions/Bridge/Dailymotion/actioncontainers.html.twig @@ -1,8 +1,8 @@
- +
diff --git a/templates/web/prod/actions/Bridge/Flickr/actioncontainers.html.twig b/templates/web/prod/actions/Bridge/Flickr/actioncontainers.html.twig index f597e039c3..4abf04be54 100644 --- a/templates/web/prod/actions/Bridge/Flickr/actioncontainers.html.twig +++ b/templates/web/prod/actions/Bridge/Flickr/actioncontainers.html.twig @@ -1,8 +1,8 @@
- +
diff --git a/templates/web/prod/actions/Bridge/Youtube/actioncontainers.html.twig b/templates/web/prod/actions/Bridge/Youtube/actioncontainers.html.twig index 0fc7e8dd8d..4abf04be54 100644 --- a/templates/web/prod/actions/Bridge/Youtube/actioncontainers.html.twig +++ b/templates/web/prod/actions/Bridge/Youtube/actioncontainers.html.twig @@ -1,8 +1,8 @@
- +
From 409a43db0cd60b9eacb6fad6628902d5312dded8 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Thu, 31 Oct 2013 14:38:35 +0100 Subject: [PATCH 02/10] Fix field edition for vocabulary --- lib/classes/databox/field.php | 2 ++ www/scripts/apps/admin/fields/views/edit.js | 11 +++++++++++ www/scripts/tests/specs/admin/fields.js | 9 +++++++++ 3 files changed, 22 insertions(+) diff --git a/lib/classes/databox/field.php b/lib/classes/databox/field.php index 705c01084a..e2d1e425b7 100644 --- a/lib/classes/databox/field.php +++ b/lib/classes/databox/field.php @@ -235,6 +235,8 @@ class databox_field implements cache_cacheableInterface $this->thumbtitle = $row['thumbtitle']; + $this->loadVocabulary(); + return $this; } diff --git a/www/scripts/apps/admin/fields/views/edit.js b/www/scripts/apps/admin/fields/views/edit.js index 2864f6e4e3..4ae44163d7 100644 --- a/www/scripts/apps/admin/fields/views/edit.js +++ b/www/scripts/apps/admin/fields/views/edit.js @@ -89,11 +89,22 @@ define([ "blur input#tbranch": "fieldChangedAction", "blur input#separator": "fieldChangedAction", "blur input#tag": "tagFieldChangedAction", + "change select#vocabulary-type": "triggerControlledVocabulary", "keyup input.input-label": "labelChangedAction", "change input[type=checkbox]": "fieldChangedAction", "change select": "selectionChangedAction", "click .lng-label a": "_toggleLabels" }, + triggerControlledVocabulary: function(e) { + if ($(e.target, this.$el).find("option:selected").val() === "") { + this.model.set("vocabulary-type", false); + this.render(); + } else if ($("input#vocabulary-restricted", this.$el).length === 0) { + this.model.set("vocabulary-restricted", false); + this.model.set("vocabulary-type", $(e.target, this.$el).find("option:selected").val()); + this.render(); + } + }, selectionChangedAction: function(e) { var field = $(e.target); var data = {}; diff --git a/www/scripts/tests/specs/admin/fields.js b/www/scripts/tests/specs/admin/fields.js index 24224975d4..23a7024abd 100644 --- a/www/scripts/tests/specs/admin/fields.js +++ b/www/scripts/tests/specs/admin/fields.js @@ -225,6 +225,15 @@ define([ assert.isTrue(view.$('input#tag').closest(".control-group").hasClass("error")); }); + + it("should uncheck vocabulary restricted if provided vocabulary is empty", function() { + var view = this.view.render(); + + view.$('input#vocabulary-restricted').attr("checked", true); + view.$('input#vocabulary-type option').first().attr("selected", true); + + assert.isTrue(false === view.$('input#vocabulary-restricted').is(":checked")); + }); }); describe("FieldError Views", function() { From beb409e932152dc4fe08fc1035ce2e1f68e39f54 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 4 Nov 2013 13:02:54 +0100 Subject: [PATCH 03/10] Use symfony/debug error handler instead of the deprecated one --- www/api.php | 2 +- www/index.php | 2 +- www/index_dev.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/www/api.php b/www/api.php index ece1f8f827..7033a9e1d7 100644 --- a/www/api.php +++ b/www/api.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -use Symfony\Component\HttpKernel\Debug\ErrorHandler; +use Symfony\Component\Debug\ErrorHandler; require_once __DIR__ . '/../lib/autoload.php'; diff --git a/www/index.php b/www/index.php index 22f1a537a2..924a601ef3 100644 --- a/www/index.php +++ b/www/index.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -use Symfony\Component\HttpKernel\Debug\ErrorHandler; +use Symfony\Component\Debug\ErrorHandler; require_once __DIR__ . "/../lib/autoload.php"; diff --git a/www/index_dev.php b/www/index_dev.php index a3119aeb90..27ee07a78a 100644 --- a/www/index_dev.php +++ b/www/index_dev.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -use Symfony\Component\HttpKernel\Debug\ErrorHandler; +use Symfony\Component\Debug\ErrorHandler; require_once __DIR__ . "/../lib/autoload.php"; From d7e108d37565a6efde91e964b417f0f7a40c4d8e Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Mon, 4 Nov 2013 17:54:33 +0100 Subject: [PATCH 04/10] Fix #1152 On IE7 editing on dialog box is broken --- www/skins/prod/jquery.edit.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/www/skins/prod/jquery.edit.js b/www/skins/prod/jquery.edit.js index 2713ad757e..9eadd155d8 100644 --- a/www/skins/prod/jquery.edit.js +++ b/www/skins/prod/jquery.edit.js @@ -1035,7 +1035,7 @@ function cleanTags(string) }, { 'f':">", 't':">" - }, ]; + } ]; for(c in chars2replace) string = string.replace(RegExp(chars2replace[c].f,"g") ,chars2replace[c].t); return string; @@ -1929,6 +1929,10 @@ function startThisEditing(sbas_id,what,regbasprid,ssel) }); } + hsplit1(); + vsplit2() + vsplit1(); + $('#EDIT_TOP', p4.edit.editBox).resizable({ handles : 's', minHeight:100, @@ -1958,7 +1962,7 @@ function startThisEditing(sbas_id,what,regbasprid,ssel) }); $('#EDIT_MID_R') - .css('left', $('#EDIT_MID_R').position().left) + .css('left', $('#EDIT_MID_L').position().left + $('#EDIT_MID_L').width() + 15) .resizable({ handles : 'w', minWidth:200, @@ -2114,10 +2118,6 @@ $('#EDIT_MID_R') ETHSeeker = new EditThesaurusSeeker(p4.edit.sbas_id); - hsplit1(); - vsplit2(); - vsplit1(); - setSizeLimits(); var p = { From 50913c00abc30118f0edd2c0adf37df63a631bd8 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 4 Nov 2013 19:10:45 +0100 Subject: [PATCH 05/10] Fix disconnection on session delete --- .../Phrasea/Authentication/Authenticator.php | 15 ++++++++- lib/Alchemy/Phrasea/Setup/Installer.php | 3 +- .../Authentication/AuthenticatorTest.php | 33 ++++++++++++------- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/lib/Alchemy/Phrasea/Authentication/Authenticator.php b/lib/Alchemy/Phrasea/Authentication/Authenticator.php index 8766d46096..d43660bd80 100644 --- a/lib/Alchemy/Phrasea/Authentication/Authenticator.php +++ b/lib/Alchemy/Phrasea/Authentication/Authenticator.php @@ -149,6 +149,19 @@ class Authenticator */ public function isAuthenticated() { - return $this->session->has('usr_id'); + if (!$this->session->has('usr_id')) { + return false; + } + + if ($this->session->has('session_id')) { + if (null !== $this->em->find('Entities\Session', $this->session->get('session_id'))) { + return true; + } + } + + $this->session->invalidate(); + $this->reinitUser(); + + return false; } } diff --git a/lib/Alchemy/Phrasea/Setup/Installer.php b/lib/Alchemy/Phrasea/Setup/Installer.php index 24759b4811..b6aea89c47 100644 --- a/lib/Alchemy/Phrasea/Setup/Installer.php +++ b/lib/Alchemy/Phrasea/Setup/Installer.php @@ -113,8 +113,7 @@ class Installer private function createUser($email, $password) { $user = \User_Adapter::create($this->app, $email, $password, $email, true); - - $this->app['session']->set('usr_id', $user->get_id()); + $this->app['authentication']->openAccount($user); return $user; } diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/AuthenticatorTest.php b/tests/Alchemy/Tests/Phrasea/Authentication/AuthenticatorTest.php index 682192ecf1..2383e0f735 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/AuthenticatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/AuthenticatorTest.php @@ -5,6 +5,7 @@ namespace Alchemy\Tests\Phrasea\Authentication; use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Authentication\Authenticator; use Alchemy\Phrasea\Exception\RuntimeException; +use Entities\Session; class AuthenticatorTest extends \PhraseanetPHPUnitAbstract { @@ -33,11 +34,17 @@ class AuthenticatorTest extends \PhraseanetPHPUnitAbstract $app['browser'] = $browser = $this->getBrowserMock(); $app['session'] = $session = $this->getSessionMock(); - $app['EM'] = $em = $this->getEntityManagerMock(); + + $sessionEntity = new Session(); + $sessionEntity->setUsrId($user->get_id()); + $sessionEntity->setUserAgent(''); + $app['EM']->persist($sessionEntity); + $app['EM']->flush(); $session->set('usr_id', $user->get_id()); + $session->set('session_id', $sessionEntity->getId()); - $authenticator = new Authenticator($app, $browser, $session, $em); + $authenticator = new Authenticator($app, $browser, $session, $app['EM']); $this->assertEquals($user, $authenticator->getUser()); } @@ -69,8 +76,7 @@ class AuthenticatorTest extends \PhraseanetPHPUnitAbstract public function testOpenAccount() { $app = new Application(); - - $sessionId = 2442; + $capturedSession = null; $app['browser'] = $browser = $this->getBrowserMock(); $app['session'] = $session = $this->getSessionMock(); @@ -97,11 +103,8 @@ class AuthenticatorTest extends \PhraseanetPHPUnitAbstract $em->expects($this->at(0)) ->method('persist') ->with($this->isInstanceOf('Entities\Session')) - ->will($this->returnCallback(function ($session) use ($sessionId) { - $ref = new \ReflectionObject($session); - $prop = $ref->getProperty('id'); - $prop->setAccessible(true); - $prop->setValue($session, $sessionId); + ->will($this->returnCallback(function ($session) use (&$capturedSession) { + $capturedSession = $session; })); $em->expects($this->at(1)) ->method('flush'); @@ -110,7 +113,7 @@ class AuthenticatorTest extends \PhraseanetPHPUnitAbstract $phsession = $authenticator->openAccount($user); $this->assertInstanceOf('Entities\Session', $phsession); - $this->assertEquals($sessionId, $session->get('session_id')); + $this->assertEquals($capturedSession, $phsession); } /** @@ -237,11 +240,17 @@ class AuthenticatorTest extends \PhraseanetPHPUnitAbstract $app['browser'] = $browser = $this->getBrowserMock(); $app['session'] = $session = $this->getSessionMock(); - $app['EM'] = $em = $this->getEntityManagerMock(); + + $sessionEntity = new Session(); + $sessionEntity->setUsrId($user->get_id()); + $sessionEntity->setUserAgent(''); + $app['EM']->persist($sessionEntity); + $app['EM']->flush(); $session->set('usr_id', $user->get_id()); + $session->set('session_id', $sessionEntity->getId()); - $authenticator = new Authenticator($app, $browser, $session, $em); + $authenticator = new Authenticator($app, $browser, $session, $app['EM']); $this->assertTrue($authenticator->isAuthenticated()); } From ab512540caa334058f6c4c7fe5b4f25e21832de4 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 4 Nov 2013 19:11:36 +0100 Subject: [PATCH 06/10] Add cache provider for memcached extension --- lib/Alchemy/Phrasea/Cache/Factory.php | 27 +++++++++++++++++++ .../Tests/Phrasea/Cache/FactoryTest.php | 2 ++ 2 files changed, 29 insertions(+) diff --git a/lib/Alchemy/Phrasea/Cache/Factory.php b/lib/Alchemy/Phrasea/Cache/Factory.php index bbebbd04ea..8e1437880e 100644 --- a/lib/Alchemy/Phrasea/Cache/Factory.php +++ b/lib/Alchemy/Phrasea/Cache/Factory.php @@ -45,6 +45,10 @@ class Factory case 'memcachecache': $cache = $this->createMemcache($options); break; + case 'memcached': + case 'memcachecached': + $cache = $this->createMemcached($options); + break; case 'redis': case 'rediscache': $cache = $this->createRedis($options); @@ -131,6 +135,29 @@ class Factory return $cache; } + private function createMemcached($options) + { + if (!extension_loaded('memcached')) { + throw new RuntimeException('The Memcached cache requires the Memcached extension.'); + } + + $host = isset($options['host']) ? $options['host'] : 'localhost'; + $port = isset($options['port']) ? $options['port'] : 11211; + + $memcached = new \Memcached(); + $memcached->addServer($host, $port); + $memcached->getStats(); + + if (\Memcached::RES_SUCCESS !== $memcached->getResultCode()) { + throw new RuntimeException(sprintf("Memcached instance with host '%s' and port '%s' is not reachable", $host, $port)); + } + + $cache = new MemcachedCache(); + $cache->setMemcached($memcached); + + return $cache; + } + private function createApc($options) { if (!extension_loaded('apc')) { diff --git a/tests/Alchemy/Tests/Phrasea/Cache/FactoryTest.php b/tests/Alchemy/Tests/Phrasea/Cache/FactoryTest.php index 93fd5bb108..cabe7fae2f 100644 --- a/tests/Alchemy/Tests/Phrasea/Cache/FactoryTest.php +++ b/tests/Alchemy/Tests/Phrasea/Cache/FactoryTest.php @@ -28,6 +28,8 @@ class FactoryTest extends \PHPUnit_Framework_TestCase array('arraycache', null, 'Alchemy\Phrasea\Cache\ArrayCache'), array('memcache', 'memcache', 'Alchemy\Phrasea\Cache\MemcacheCache'), array('memcachecache', 'memcache', 'Alchemy\Phrasea\Cache\MemcacheCache'), + array('memcached', 'memcached', 'Alchemy\Phrasea\Cache\MemcachedCache'), + array('memcachecached', 'memcached', 'Alchemy\Phrasea\Cache\MemcachedCache'), array('redis', 'redis', 'Alchemy\Phrasea\Cache\RedisCache'), array('rediscache', 'redis', 'Alchemy\Phrasea\Cache\RedisCache'), array('wincache', 'wincache', 'Alchemy\Phrasea\Cache\WincacheCache'), From 0eb0b56407274b034235b89b3c45d48cf864436c Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 4 Nov 2013 19:12:10 +0100 Subject: [PATCH 07/10] Re-enable animated gif tests without Gmagick --- tests/classes/record/adapterTest.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/classes/record/adapterTest.php b/tests/classes/record/adapterTest.php index deed1a274f..67ab898120 100644 --- a/tests/classes/record/adapterTest.php +++ b/tests/classes/record/adapterTest.php @@ -197,10 +197,6 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract public function testGet_rollover_thumbnail() { - if (!extension_loaded('\Gmagick')) { - $this->markTestSkipped('\Gmagick required to build animated gifs'); - } - $this->assertNull(self::$DI['record_1']->get_rollover_thumbnail()); } From 6de169658f1fcad3c022ea547ff6315935b58ed0 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 4 Nov 2013 19:22:43 +0100 Subject: [PATCH 08/10] Switch back to bower as it is now stable --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index df68fef0da..6cb7c70ca2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ services: before_script: - node --version - npm --version - - npm install bower-canary mocha-phantomjs@">=2.0 <3.0" recess@">=1.1.0 <1.1.7" uglify-js -g + - npm install bower mocha-phantomjs@">=2.0 <3.0" recess@">=1.1.0 <1.1.7" uglify-js -g - echo '' > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini - sh -c 'if [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - sh -c 'if [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then pecl install redis; fi;' From ed3f31b01d95bc649b0b2c6166809698fc53717f Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 4 Nov 2013 12:54:30 +0100 Subject: [PATCH 09/10] Fix #1563 : Explicitely declare the default environment to be Application::ENV_PROD --- lib/Alchemy/Phrasea/Application/Api.php | 2 +- lib/Alchemy/Phrasea/Application/Root.php | 2 +- www/api.php | 2 ++ www/index.php | 3 ++- www/index_dev.php | 3 ++- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/Alchemy/Phrasea/Application/Api.php b/lib/Alchemy/Phrasea/Application/Api.php index 06160932b9..55c33d3cd3 100644 --- a/lib/Alchemy/Phrasea/Application/Api.php +++ b/lib/Alchemy/Phrasea/Application/Api.php @@ -66,4 +66,4 @@ return call_user_func(function ($environment = PhraseaApplication::ENV_PROD) { $app['dispatcher']->dispatch(PhraseaEvents::API_LOAD_END, new ApiLoadEndEvent()); return $app; -}, isset($environment) ? $environment : null); +}, isset($environment) ? $environment : PhraseaApplication::ENV_PROD); diff --git a/lib/Alchemy/Phrasea/Application/Root.php b/lib/Alchemy/Phrasea/Application/Root.php index 2a973fc148..e6470185d9 100644 --- a/lib/Alchemy/Phrasea/Application/Root.php +++ b/lib/Alchemy/Phrasea/Application/Root.php @@ -68,4 +68,4 @@ return call_user_func(function ($environment = PhraseaApplication::ENV_PROD) { ); return $app; -}, isset($environment) ? $environment : null); +}, isset($environment) ? $environment : PhraseaApplication::ENV_PROD); diff --git a/www/api.php b/www/api.php index 7033a9e1d7..7e76061a4d 100644 --- a/www/api.php +++ b/www/api.php @@ -9,12 +9,14 @@ * file that was distributed with this source code. */ +use Alchemy\Phrasea\Application; use Symfony\Component\Debug\ErrorHandler; require_once __DIR__ . '/../lib/autoload.php'; ErrorHandler::register(); +$environment = Application::ENV_PROD; $app = require __DIR__ . '/../lib/Alchemy/Phrasea/Application/Api.php'; $app->run(); diff --git a/www/index.php b/www/index.php index 924a601ef3..f7c746c5c8 100644 --- a/www/index.php +++ b/www/index.php @@ -9,13 +9,14 @@ * file that was distributed with this source code. */ +use Alchemy\Phrasea\Application; use Symfony\Component\Debug\ErrorHandler; require_once __DIR__ . "/../lib/autoload.php"; ErrorHandler::register(); -$environment = 'prod'; +$environment = Application::ENV_PROD; $app = require __DIR__ . '/../lib/Alchemy/Phrasea/Application/Root.php'; $app->run(); diff --git a/www/index_dev.php b/www/index_dev.php index 27ee07a78a..dc1472cf9a 100644 --- a/www/index_dev.php +++ b/www/index_dev.php @@ -9,13 +9,14 @@ * file that was distributed with this source code. */ +use Alchemy\Phrasea\Application; use Symfony\Component\Debug\ErrorHandler; require_once __DIR__ . "/../lib/autoload.php"; ErrorHandler::register(); -$environment = 'dev'; +$environment = Application::ENV_DEV; $app = require __DIR__ . '/../lib/Alchemy/Phrasea/Application/Root.php'; $app->run(); From 36a36aa7b4491cc43e9336be2184571d20c429a1 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 5 Nov 2013 14:09:49 +0100 Subject: [PATCH 10/10] Fix jquery.cookie.js path in setup templates --- templates/web/setup/wrapper.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/web/setup/wrapper.html.twig b/templates/web/setup/wrapper.html.twig index 90374f9414..544c6ae174 100644 --- a/templates/web/setup/wrapper.html.twig +++ b/templates/web/setup/wrapper.html.twig @@ -2,7 +2,7 @@ "http://www.w3.org/TR/html4/strict.dtd"> - +