From 92bc9c0d396958995bc3169244dca4d22252f515 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Fri, 25 Oct 2013 16:57:20 +0200 Subject: [PATCH 1/6] Ensure sorter index is removed --- lib/classes/patch/3820.php | 69 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 lib/classes/patch/3820.php diff --git a/lib/classes/patch/3820.php b/lib/classes/patch/3820.php new file mode 100644 index 0000000000..26d14f7a90 --- /dev/null +++ b/lib/classes/patch/3820.php @@ -0,0 +1,69 @@ +release; + } + + /** + * {@inheritdoc} + */ + public function require_all_upgrades() + { + return false; + } + + /** + * {@inheritdoc} + */ + public function concern() + { + return $this->concern; + } + + /** + * {@inheritdoc} + */ + public function apply(base $databox, Application $app) + { + $sql = "SHOW INDEX FROM metadatas_structure WHERE KEY_NAME = 'sorter'"; + $stmt = $databox->get_connection()->prepare($sql); + $stmt->execute(); + $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC); + $stmt->closeCursor(); + + if (count($rows) === 0) { + return true; + } + + $sql = "DROP INDEX sorter ON metadatas_structure"; + $stmt = $databox->get_connection()->prepare($sql); + $stmt->execute(); + $stmt->closeCursor(); + + return true; + } +} From 5e386a48d141a8748d8a499896d48af0c7115b38 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 25 Oct 2013 16:11:53 +0200 Subject: [PATCH 2/6] Fix #1538 : Email are not sent anymore --- templates/web/common/dialog_export.html.twig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/templates/web/common/dialog_export.html.twig b/templates/web/common/dialog_export.html.twig index 51acdc3ada..15a9223542 100644 --- a/templates/web/common/dialog_export.html.twig +++ b/templates/web/common/dialog_export.html.twig @@ -246,7 +246,6 @@ - {% endif %} @@ -798,8 +797,13 @@ if (!check_TOU($('#sendmail'))) { return false; } - dialog.Close(); + + if ($('iframe[name=""]').length === 0) { + $('body').append(''); + } + $('#sendmail form').submit(); + dialog.Close(); }); $('.datepicker', dialog.getDomElement()).datepicker({ From ffb9ac73d0dd5e3bd3bcd27b8d066e313066d15d Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 25 Oct 2013 15:05:03 +0200 Subject: [PATCH 3/6] Fix #1550 : Remove feed entry items that are not related to a record --- lib/classes/Feed/Entry/Item.php | 22 ++++++++++- .../Feed/Entry/Feed_Entry_ItemTest.php | 38 ++++++++++++++++++- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/lib/classes/Feed/Entry/Item.php b/lib/classes/Feed/Entry/Item.php index 3c20ae0514..0834ceb16f 100644 --- a/lib/classes/Feed/Entry/Item.php +++ b/lib/classes/Feed/Entry/Item.php @@ -10,6 +10,7 @@ */ use Alchemy\Phrasea\Application; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * @@ -273,9 +274,26 @@ class Feed_Entry_Item implements Feed_Entry_ItemInterface, cache_cacheableInterf } if (!isset($items[$row['item']])) { - $item = new self($app['phraseanet.appbox'], $entries[$row['entry']], $row['item']); + try { + $item = new self($app['phraseanet.appbox'], $entries[$row['entry']], $row['item']); + $record = $item->get_record(); + } catch (NotFoundHttpException $e) { + $sql = 'DELETE FROM feed_entry_elements WHERE id = :id'; + $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); + $stmt->execute(array(':id' => $row['item'])); + $stmt->closeCursor(); - if (null !== $preview = $item->get_record()->get_subdef('preview')) { + continue; + } catch (\Exception_Record_AdapterNotFound $e) { + $sql = 'DELETE FROM feed_entry_elements WHERE id = :id'; + $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); + $stmt->execute(array(':id' => $row['item'])); + $stmt->closeCursor(); + + continue; + } + + if (null !== $preview = $record->get_subdef('preview')) { if (null !== $permalink = $preview->get_permalink()) { $items[$row['item']] = $item; diff --git a/tests/classes/Feed/Entry/Feed_Entry_ItemTest.php b/tests/classes/Feed/Entry/Feed_Entry_ItemTest.php index e199120f98..d10bcaf537 100644 --- a/tests/classes/Feed/Entry/Feed_Entry_ItemTest.php +++ b/tests/classes/Feed/Entry/Feed_Entry_ItemTest.php @@ -1,5 +1,7 @@ assertCount(0, Feed_Entry_Item::loadLatest(self::$DI['app'], 20)); } + public function testLoadLatestWithDeletedDatabox() + { + $this->deleteEntries(); + self::$feed->set_public(true); + + $sql = 'INSERT INTO feed_entry_elements + (id, entry_id, sbas_id, record_id) + VALUES (null, :entry_id, :sbas_id, :record_id)'; + + $stmt = self::$DI['app']['phraseanet.appbox']->get_connection()->prepare($sql); + $stmt->execute(array(':entry_id' => self::$entry->get_id(), ':sbas_id' => self::$DI['record_1']->get_databox()->get_sbas_id(), ':record_id' => 0)); + $stmt->closeCursor(); + + $this->assertCount(0, Feed_Entry_Item::loadLatest(self::$DI['app'], 20)); + } + + public function testLoadLatestWithDeletedRecord() + { + $this->deleteEntries(); + self::$feed->set_public(true); + + $sql = 'INSERT INTO feed_entry_elements + (id, entry_id, sbas_id, record_id) + VALUES (null, :entry_id, :sbas_id, :record_id)'; + + $stmt = self::$DI['app']['phraseanet.appbox']->get_connection()->prepare($sql); + $stmt->execute(array(':entry_id' => self::$entry->get_id(), ':sbas_id' => -24, ':record_id' => 0)); + $stmt->closeCursor(); + + $this->assertCount(0, Feed_Entry_Item::loadLatest(self::$DI['app'], 20)); + } + public function testIs_record_in_public_feed() { $this->deleteEntries(); @@ -123,7 +157,7 @@ class Feed_Entry_ItemTest extends PhraseanetPHPUnitAuthenticatedAbstract private function deleteEntries() { - $sql = "TRUNCATE feed_entry_elements"; + $sql = "DELETE FROM feed_entry_elements"; $stmt = self::$DI['app']['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute(); $stmt->closeCursor(); From 18d16675984a036cf1d137d602260b5df1a05237 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 25 Oct 2013 18:39:16 +0200 Subject: [PATCH 4/6] Sanitize XML data --- lib/classes/caption/record.php | 40 +++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/lib/classes/caption/record.php b/lib/classes/caption/record.php index 12fb94eac7..2cd0253a34 100644 --- a/lib/classes/caption/record.php +++ b/lib/classes/caption/record.php @@ -104,12 +104,12 @@ class caption_record implements caption_interface, cache_cacheableInterface $buffer[$field->get_name()] = array(); foreach ($vi as $value) { $val = $value->getValue(); - $buffer[$field->get_name()][] = ctype_digit($val) ? (int) $val : $val; + $buffer[$field->get_name()][] = ctype_digit($val) ? (int) $val : $this->sanitizeSerializedValue($val); } } else { $value = array_pop($vi); $val = $value->getValue(); - $buffer[$field->get_name()] = ctype_digit($val) ? (int) $val : $val; + $buffer[$field->get_name()] = ctype_digit($val) ? (int) $val : $this->sanitizeSerializedValue($val); } } @@ -133,7 +133,7 @@ class caption_record implements caption_interface, cache_cacheableInterface foreach ($values as $value) { $elem = $dom_doc->createElement($field->get_name()); - $elem->appendChild($dom_doc->createTextNode($value->getValue())); + $elem->appendChild($dom_doc->createTextNode($this->sanitizeSerializedValue($value->getValue()))); $elem->setAttribute('meta_id', $value->getId()); $elem->setAttribute('meta_struct_id', $field->get_meta_struct_id()); $description->appendChild($elem); @@ -153,6 +153,40 @@ class caption_record implements caption_interface, cache_cacheableInterface return $dom_doc->saveXML(); } + private function sanitizeSerializedValue($value) + { + return str_replace(array( + "\x00", //null + "\x01", //start heading + "\x02", //start text + "\x03", //end of text + "\x04", //end of transmission + "\x05", //enquiry + "\x06", //acknowledge + "\x07", //bell + "\x08", //backspace + "\x0C", //new page + "\x0E", //shift out + "\x0F", //shift in + "\x10", //data link escape + "\x11", //dc 1 + "\x12", //dc 2 + "\x13", //dc 3 + "\x14", //dc 4 + "\x15", //negative ack + "\x16", //synchronous idle + "\x17", //end of trans block + "\x18", //cancel + "\x19", //end of medium + "\x1A", //substitute + "\x1B", //escape + "\x1C", //file separator + "\x1D", //group sep + "\x1E", //record sep + "\x1F", //unit sep + ), '', $value); + } + protected function retrieve_fields() { if (is_array($this->fields)) { From c5c75ceb2f451dfde049b9bf234ebddb495757d5 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Fri, 25 Oct 2013 15:23:32 +0200 Subject: [PATCH 5/6] Registe plugin_asset twig function --- lib/Alchemy/Phrasea/Application.php | 2 ++ .../CLIProvider/PluginServiceProvider.php | 8 ----- .../Core/Provider/PluginServiceProvider.php | 34 +++++++++++++++++++ 3 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 lib/Alchemy/Phrasea/Core/Provider/PluginServiceProvider.php diff --git a/lib/Alchemy/Phrasea/Application.php b/lib/Alchemy/Phrasea/Application.php index 4414d76f05..294c764fda 100644 --- a/lib/Alchemy/Phrasea/Application.php +++ b/lib/Alchemy/Phrasea/Application.php @@ -92,6 +92,7 @@ use Alchemy\Phrasea\Core\Provider\LocaleServiceProvider; use Alchemy\Phrasea\Core\Provider\NotificationDelivererServiceProvider; use Alchemy\Phrasea\Core\Provider\ORMServiceProvider; use Alchemy\Phrasea\Core\Provider\PhraseanetServiceProvider; +use Alchemy\Phrasea\Core\Provider\PluginServiceProvider; use Alchemy\Phrasea\Core\Provider\PhraseaVersionServiceProvider; use Alchemy\Phrasea\Core\Provider\RegistrationServiceProvider; use Alchemy\Phrasea\Core\Provider\SearchEngineServiceProvider; @@ -294,6 +295,7 @@ class Application extends SilexApplication $this->register(new ValidatorServiceProvider()); $this->register(new XPDFServiceProvider()); $this->register(new FileServeServiceProvider()); + $this->register(new PluginServiceProvider()); $this['phraseanet.exception_handler'] = $this->share(function ($app) { return PhraseaExceptionHandler::register($app['debug']); diff --git a/lib/Alchemy/Phrasea/Core/CLIProvider/PluginServiceProvider.php b/lib/Alchemy/Phrasea/Core/CLIProvider/PluginServiceProvider.php index 8819cbba2d..795c141609 100644 --- a/lib/Alchemy/Phrasea/Core/CLIProvider/PluginServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/CLIProvider/PluginServiceProvider.php @@ -83,13 +83,5 @@ class PluginServiceProvider implements ServiceProviderInterface public function boot(Application $app) { - $app['twig'] = $app->share( - $app->extend('twig', function($twig, Application $app){ - $function = new \Twig_SimpleFunction('plugin_asset', array('Alchemy\Phrasea\Plugin\Management\AssetsManager', 'twigPluginAsset')); - $twig->addFunction($function); - - return $twig; - }) - ); } } diff --git a/lib/Alchemy/Phrasea/Core/Provider/PluginServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/PluginServiceProvider.php new file mode 100644 index 0000000000..6eae3d1617 --- /dev/null +++ b/lib/Alchemy/Phrasea/Core/Provider/PluginServiceProvider.php @@ -0,0 +1,34 @@ +share( + $app->extend('twig', function($twig, Application $app){ + $function = new \Twig_SimpleFunction('plugin_asset', array('Alchemy\Phrasea\Plugin\Management\AssetsManager', 'twigPluginAsset')); + $twig->addFunction($function); + + return $twig; + }) + ); + } +} From 9d69c8dc3f4551013198585d95c13b8188d10f6d Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 28 Oct 2013 15:24:03 +0100 Subject: [PATCH 6/6] Use Twig 1.13, waiting for bug #1251 to be solved --- composer.json | 2 +- composer.lock | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index df82322d09..e69797d5a5 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "symfony/symfony" : "2.3.3", "alchemy-fr/tcpdf-clone" : "~6.0", "themattharris/tmhoauth" : "~0.7", - "twig/twig" : "~1.12", + "twig/twig" : "~1.13.0", "twig/extensions" : "~1.0", "zend/gdata" : "~1.12.1" }, diff --git a/composer.lock b/composer.lock index b4f874a133..8c8260111f 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": "dc36e39e9cc3094880026632dc315013", + "hash": "7c844fa6bef5e861c16a13b1dc9eca37", "packages": [ { "name": "alchemy-fr/tcpdf-clone", @@ -1160,12 +1160,12 @@ "source": { "type": "git", "url": "https://github.com/avalanche123/Imagine.git", - "reference": "bae39d07a8f56ff21ca773a6b4e1ed2ab13b1c03" + "reference": "237ccf205dd5ece7a00a574b4f18bd118aa08a5d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/avalanche123/Imagine/zipball/bae39d07a8f56ff21ca773a6b4e1ed2ab13b1c03", - "reference": "bae39d07a8f56ff21ca773a6b4e1ed2ab13b1c03", + "url": "https://api.github.com/repos/avalanche123/Imagine/zipball/237ccf205dd5ece7a00a574b4f18bd118aa08a5d", + "reference": "237ccf205dd5ece7a00a574b4f18bd118aa08a5d", "shasum": "" }, "require": { @@ -1209,7 +1209,7 @@ "image manipulation", "image processing" ], - "time": "2013-10-10 08:13:00" + "time": "2013-10-26 10:53:02" }, { "name": "jms/metadata", @@ -2868,16 +2868,16 @@ }, { "name": "twig/twig", - "version": "v1.14.1", + "version": "v1.13.2", "source": { "type": "git", "url": "https://github.com/fabpot/Twig.git", - "reference": "8873d7593ad7c120004f177c0fd01459b383c9cb" + "reference": "6d6a1009427d1f398c9d40904147bf9f723d5755" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fabpot/Twig/zipball/8873d7593ad7c120004f177c0fd01459b383c9cb", - "reference": "8873d7593ad7c120004f177c0fd01459b383c9cb", + "url": "https://api.github.com/repos/fabpot/Twig/zipball/6d6a1009427d1f398c9d40904147bf9f723d5755", + "reference": "6d6a1009427d1f398c9d40904147bf9f723d5755", "shasum": "" }, "require": { @@ -2886,7 +2886,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.14-dev" + "dev-master": "1.13-dev" } }, "autoload": { @@ -2913,7 +2913,7 @@ "keywords": [ "templating" ], - "time": "2013-10-15 19:17:38" + "time": "2013-08-03 15:35:31" }, { "name": "zend/gdata",