From f32d561c981023a4d6d1e37a4fa58edf18feaa1a Mon Sep 17 00:00:00 2001 From: jygaulier Date: Mon, 14 Oct 2013 16:58:32 +0200 Subject: [PATCH 1/5] fix #1496 --- lib/classes/task/Scheduler.php | 75 ++++++++++++++++++++++------------ lib/classes/task/manager.php | 7 ++++ 2 files changed, 57 insertions(+), 25 deletions(-) diff --git a/lib/classes/task/Scheduler.php b/lib/classes/task/Scheduler.php index 32513b2fe9..d00a8ab1c1 100644 --- a/lib/classes/task/Scheduler.php +++ b/lib/classes/task/Scheduler.php @@ -34,11 +34,15 @@ class task_Scheduler private $method; private $dependencyContainer; + private $schedstatus; + public function __construct(Application $application, Logger $logger) { declare(ticks = 1); $this->dependencyContainer = $application; $this->logger = $logger; + + $this->schedstatus = ''; } protected function log($message) @@ -54,10 +58,21 @@ class task_Scheduler */ public function sigHandler($signal) { - $status = null; - $pid = pcntl_wait($status); - $exitstatus = pcntl_wexitstatus($status); - $this->log(sprintf("sigchild %s received from pid=%s, status=%s, exitstatus=%s\n", $signal, $pid, var_export($status, true), $exitstatus)); + switch ($signal) { + case SIGCHLD: + $status = null; + $pid = pcntl_wait($status); + $exitstatus = pcntl_wexitstatus($status); + $this->log(sprintf("SIGCHLD (%s) received from pid=%s, status=%s, exitstatus=%s", $signal, $pid, var_export($status, true), $exitstatus)); + break; + case SIGINT: // ctrl C + $this->log(sprintf("SIGINT (%s) Ctrl-C received, schedstatus='tostop'", $signal)); + $this->schedstatus = 'tostop'; + break; + case SIGTERM: + $this->log(sprintf("SIGTERM (%s) received but ignored, http timeout ?", $signal)); + break; + } } public function run() @@ -87,6 +102,8 @@ class task_Scheduler // pcntl_signal(SIGCHLD, SIG_IGN); // no zombies but no returnValue // pcntl_signal(SIGCHLD, SIG_DFL); // with "declare(ticks=1)" returnValue ok but zombies pcntl_signal(SIGCHLD, array($this, 'sigHandler')); // ok + pcntl_signal(SIGINT, array($this, 'sigHandler')); + pcntl_signal(SIGTERM, array($this, 'sigHandler')); $this->method = self::METHOD_FORK; } @@ -147,11 +164,11 @@ class task_Scheduler } } - $schedstatus = 'started'; + $this->schedstatus = 'started'; $runningtask = 0; $connwaslost = false; - while ($schedstatus == 'started' || $runningtask > 0) { + while ($this->schedstatus == 'started' || $runningtask > 0) { while (1) { try { assert(is_object($conn)); @@ -189,23 +206,25 @@ class task_Scheduler $connwaslost = false; } - $schedstatus = ''; - $row = NULL; - try { - $sql = "SELECT schedstatus FROM sitepreff"; - $stmt = $conn->prepare($sql); - $stmt->execute(); - $row = $stmt->fetch(PDO::FETCH_ASSOC); - $stmt->closeCursor(); - } catch (ErrorException $e) { - continue; + if ($this->schedstatus == "started") { + $this->schedstatus = ''; + $row = NULL; + try { + $sql = "SELECT schedstatus FROM sitepreff"; + $stmt = $conn->prepare($sql); + $stmt->execute(); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + $stmt->closeCursor(); + } catch (ErrorException $e) { + continue; + } + + if ($row) { + $this->schedstatus = $row["schedstatus"]; + } } - if ($row) { - $schedstatus = $row["schedstatus"]; - } - - if ($schedstatus == 'tostop') { + if ($this->schedstatus == 'tostop') { $sql = 'UPDATE sitepreff SET schedstatus = "stopping"'; $stmt = $conn->prepare($sql); $stmt->execute(); @@ -327,7 +346,7 @@ class task_Scheduler } } - if ($schedstatus == 'started') { + if ($this->schedstatus == 'started') { $taskPoll[$tkey]["task"]->setState(task_abstract::STATE_TOSTART); } // trick to start the task immediatly : DON'T break if ending with 'tostart' @@ -338,7 +357,7 @@ class task_Scheduler case task_abstract::STATE_TOSTART: // if scheduler is 'tostop', don't launch a new task ! - if ($schedstatus != 'started') { + if ($this->schedstatus != 'started') { break; } @@ -567,10 +586,16 @@ class task_Scheduler break; } } - - for ($i = 0; $i < $sleeptime; $i ++) { + if(function_exists('pcntl_sigprocmask')) { + @pcntl_sigprocmask(SIG_BLOCK, array(SIGCHLD)); + } + sleep(1); + for ($i = 0; $this->schedstatus=='started' && $i < $sleeptime; $i++) { sleep(1); } + if(function_exists('pcntl_sigprocmask')) { + @pcntl_sigprocmask(SIG_UNBLOCK, array(SIGCHLD)); + } } $sql = "UPDATE sitepreff SET schedstatus='stopped', schedpid='0'"; diff --git a/lib/classes/task/manager.php b/lib/classes/task/manager.php index 1c02eb1541..2c38f1d37d 100644 --- a/lib/classes/task/manager.php +++ b/lib/classes/task/manager.php @@ -161,6 +161,13 @@ class task_manager if (!in_array($status, $av_status)) throw new Exception(sprintf('unknown status `%s` ', $status)); + if ($status == self::STATE_TOSTOP && function_exists('posix_kill')) { + $gs = $this->getSchedulerState(); + if ($gs['pid'] !== NULL) { + @posix_kill($gs['pid'], 2); // 2 = SIGINT + } + } + $sql = "UPDATE sitepreff SET schedstatus = :schedstatus, schedqtime=NOW()"; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute(array(':schedstatus' => $status)); From 42cb682dd5e0396cac05b3fb52f9d2440c31f84f Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 18 Oct 2013 15:55:39 +0200 Subject: [PATCH 2/5] Use custom repo for tcpdf --- composer.json | 8 +++- composer.lock | 115 +++++++++++++++++++++++++------------------------- 2 files changed, 64 insertions(+), 59 deletions(-) diff --git a/composer.json b/composer.json index a30791a67f..df82322d09 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "silex/web-profiler" : "~1.0.0", "swiftmailer/swiftmailer" : "~4.3.0", "symfony/symfony" : "2.3.3", - "tecnick.com/tcpdf" : "~6.0", + "alchemy-fr/tcpdf-clone" : "~6.0", "themattharris/tmhoauth" : "~0.7", "twig/twig" : "~1.12", "twig/extensions" : "~1.0", @@ -51,6 +51,12 @@ "behat/mink-selenium2-driver" : "~1.0", "fabpot/goutte" : "~1.0" }, + "repositories": [ + { + "type": "git", + "url": "https://github.com/alchemy-fr/tcpdf-clone" + } + ], "autoload": { "psr-0": { "" : "lib/classes", diff --git a/composer.lock b/composer.lock index 708c2e39ba..55b2dbedd6 100644 --- a/composer.lock +++ b/composer.lock @@ -3,8 +3,64 @@ "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": "3d1785e1916b3d0cf47c0eb8ec7ac591", + "hash": "dc36e39e9cc3094880026632dc315013", "packages": [ + { + "name": "alchemy-fr/tcpdf-clone", + "version": "6.0.039", + "source": { + "type": "git", + "url": "https://github.com/alchemy-fr/tcpdf-clone", + "reference": "2ba0248a7187f1626df6c128750650416267f0e7" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "fonts", + "config", + "include", + "tcpdf.php", + "tcpdf_parser.php", + "tcpdf_import.php", + "tcpdf_barcodes_1d.php", + "tcpdf_barcodes_2d.php", + "include/tcpdf_colors.php", + "include/tcpdf_filters.php", + "include/tcpdf_font_data.php", + "include/tcpdf_fonts.php", + "include/tcpdf_images.php", + "include/tcpdf_static.php", + "include/barcodes/datamatrix.php", + "include/barcodes/pdf417.php", + "include/barcodes/qrcode.php" + ] + }, + "license": [ + "LGPLv3" + ], + "authors": [ + { + "name": "Nicola Asuni", + "email": "info@tecnick.com", + "homepage": "http://nicolaasuni.tecnick.com" + } + ], + "description": "TCPDF is a PHP class for generating PDF documents.", + "homepage": "http://www.tcpdf.org/", + "keywords": [ + "PDF", + "PDFD32000-2008", + "barcodes", + "datamatrix", + "pdf417", + "qrcode", + "tcpdf" + ], + "time": "2013-10-13 16:11:17" + }, { "name": "alchemy/binary-driver", "version": "1.5.0", @@ -2720,63 +2776,6 @@ ], "time": "2013-08-07 17:11:16" }, - { - "name": "tecnick.com/tcpdf", - "version": "6.0.039", - "source": { - "type": "git", - "url": "git://git.code.sf.net/p/tcpdf/code", - "reference": "2ba0248a7187f1626df6c128750650416267f0e7" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "fonts", - "config", - "include", - "tcpdf.php", - "tcpdf_parser.php", - "tcpdf_import.php", - "tcpdf_barcodes_1d.php", - "tcpdf_barcodes_2d.php", - "include/tcpdf_colors.php", - "include/tcpdf_filters.php", - "include/tcpdf_font_data.php", - "include/tcpdf_fonts.php", - "include/tcpdf_images.php", - "include/tcpdf_static.php", - "include/barcodes/datamatrix.php", - "include/barcodes/pdf417.php", - "include/barcodes/qrcode.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPLv3" - ], - "authors": [ - { - "name": "Nicola Asuni", - "email": "info@tecnick.com", - "homepage": "http://nicolaasuni.tecnick.com" - } - ], - "description": "TCPDF is a PHP class for generating PDF documents.", - "homepage": "http://www.tcpdf.org/", - "keywords": [ - "PDFD32000-2008", - "TCPDF", - "barcodes", - "datamatrix", - "pdf", - "pdf417", - "qrcode" - ], - "time": "2013-10-13 16:11:17" - }, { "name": "themattharris/tmhoauth", "version": "0.8.3", From f9cd105e51450619081b5f6dc499173616e42d10 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Fri, 18 Oct 2013 16:11:54 +0200 Subject: [PATCH 3/5] Fix #1497 Resizing images is not working on tablet in paysage mode --- templates/mobile/common/index.html.twig | 17 ------------- templates/mobile/common/thumbnail.html.twig | 6 ++--- .../mobile/lightbox/basket_element.html.twig | 25 +++++++++++++------ .../mobile/lightbox/feed_element.html.twig | 23 +++++++++++------ templates/web/common/macros.html.twig | 2 +- 5 files changed, 35 insertions(+), 38 deletions(-) diff --git a/templates/mobile/common/index.html.twig b/templates/mobile/common/index.html.twig index cadf1051c3..c62d468f09 100644 --- a/templates/mobile/common/index.html.twig +++ b/templates/mobile/common/index.html.twig @@ -15,23 +15,6 @@ margin: 0px; padding: 0px; } - - .ui-content{ - height: 85%; - width: 100%; - margin: 0px; - padding: 0px; - display:table; - } - - #map { - height: 100%; - width: 100%; - padding: 0px; - display:table-cell; - vertical-align: middle; - text-align: center - } {% block stylesheet %}{% endblock %} {% block icon %}{% endblock %} diff --git a/templates/mobile/common/thumbnail.html.twig b/templates/mobile/common/thumbnail.html.twig index b8d676b229..537e608cef 100644 --- a/templates/mobile/common/thumbnail.html.twig +++ b/templates/mobile/common/thumbnail.html.twig @@ -72,7 +72,6 @@ {% macro format100percent(thumbnail, extraclass)%} {% set record_type = thumbnail.get_type() %} -
{% if record_type == 'VIDEO_MP4' or record_type == 'VIDEO_FLV' %} {% set random = thumbnail.get_random() %}
@@ -102,8 +101,7 @@ "{{thumbnail.get_width()}}", "{{thumbnail.get_height()}}", "9.0.0", false, false, {menu: "false",flashvars: "playerID=2&autostart=yes&noinfo=yes&animation=no&remaining=yes&soundFile={{thumbnail.get_url()}}", movie: "/include/jslibs/audio-player/player.swf", allowFullScreen :"true",wmode: "transparent"}, false); {% else %} - + {% endif %} -
{% endmacro %} diff --git a/templates/mobile/lightbox/basket_element.html.twig b/templates/mobile/lightbox/basket_element.html.twig index ddfb3aac0d..683d9177c8 100644 --- a/templates/mobile/lightbox/basket_element.html.twig +++ b/templates/mobile/lightbox/basket_element.html.twig @@ -8,17 +8,32 @@ {% block stylesheet %} + + {% endblock %} {% block content %} {% set record = basket_element.getRecord(app) %} -
+
Back

{{basket_element.getOrd()}} - {{record.get_title()}}

Home
-
+
{{ thumbnail.format100percent(record.get_preview()) }} {% if basket_element.getBasket().getValidation() %} {% if basket_element.getBasket().getValidation().getParticipant(app['authentication'].getUser(), app).getCanAgree() %} @@ -44,11 +59,5 @@
-
{% endblock %} diff --git a/templates/mobile/lightbox/feed_element.html.twig b/templates/mobile/lightbox/feed_element.html.twig index 3ae130a7c4..0700f147ea 100644 --- a/templates/mobile/lightbox/feed_element.html.twig +++ b/templates/mobile/lightbox/feed_element.html.twig @@ -8,6 +8,21 @@ {% block stylesheet %} + + {% endblock %} {% block content %} @@ -22,13 +37,5 @@ {{ thumbnail.format100percent(record.get_preview()) }}
- -
-
{% endblock %} diff --git a/templates/web/common/macros.html.twig b/templates/web/common/macros.html.twig index 8fc16710ef..aa1a244d83 100644 --- a/templates/web/common/macros.html.twig +++ b/templates/web/common/macros.html.twig @@ -78,4 +78,4 @@
{% endfor %} {% endfor %} -{% endmacro %} \ No newline at end of file +{% endmacro %} From 1a6e1075cd5c2c56f4b0cca41bc5bf2f073c9032 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 21 Oct 2013 14:45:37 +0200 Subject: [PATCH 4/5] Fix #1529 : Update to PHP-FFMpeg 0.4 --- composer.lock | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/composer.lock b/composer.lock index 55b2dbedd6..b4f874a133 100644 --- a/composer.lock +++ b/composer.lock @@ -1434,16 +1434,16 @@ }, { "name": "media-alchemyst/media-alchemyst", - "version": "0.3.5", + "version": "0.3.6", "source": { "type": "git", "url": "https://github.com/alchemy-fr/Media-Alchemyst.git", - "reference": "da4dc484cff946a5a2bb1966c538e7132b542b8c" + "reference": "86a16aab82b6e31d2e70050f61fa815a98037253" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/alchemy-fr/Media-Alchemyst/zipball/da4dc484cff946a5a2bb1966c538e7132b542b8c", - "reference": "da4dc484cff946a5a2bb1966c538e7132b542b8c", + "url": "https://api.github.com/repos/alchemy-fr/Media-Alchemyst/zipball/86a16aab82b6e31d2e70050f61fa815a98037253", + "reference": "86a16aab82b6e31d2e70050f61fa815a98037253", "shasum": "" }, "require": { @@ -1453,7 +1453,7 @@ "monolog/monolog": "~1.0", "neutron/temporary-filesystem": "~2.1", "php": ">=5.3.3", - "php-ffmpeg/php-ffmpeg": "~0.3.4", + "php-ffmpeg/php-ffmpeg": "~0.3, >=0.3.4", "php-mp4box/php-mp4box": "~0.3.0", "php-unoconv/php-unoconv": "~0.3.0", "pimple/pimple": "~1.0", @@ -1470,7 +1470,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "0.3-dev" + "dev-master": "0.4-dev" } }, "autoload": { @@ -1503,27 +1503,27 @@ "video", "video processing" ], - "time": "2013-09-05 10:26:38" + "time": "2013-10-21 12:41:18" }, { "name": "mediavorus/mediavorus", - "version": "0.4.0", + "version": "0.4.1", "source": { "type": "git", "url": "https://github.com/romainneutron/MediaVorus.git", - "reference": "0102f4e73f9184ff7861f89b6c1189a83fb19bac" + "reference": "5d5c416353f48192f2202dd4be5c21d95f46b08d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/romainneutron/MediaVorus/zipball/0102f4e73f9184ff7861f89b6c1189a83fb19bac", - "reference": "0102f4e73f9184ff7861f89b6c1189a83fb19bac", + "url": "https://api.github.com/repos/romainneutron/MediaVorus/zipball/5d5c416353f48192f2202dd4be5c21d95f46b08d", + "reference": "5d5c416353f48192f2202dd4be5c21d95f46b08d", "shasum": "" }, "require": { "doctrine/collections": "~1.0", "monolog/monolog": "~1.0", "php": ">=5.3.0", - "php-ffmpeg/php-ffmpeg": "~0.3.0", + "php-ffmpeg/php-ffmpeg": "~0.3", "phpexiftool/phpexiftool": "~0.1", "symfony/console": "~2.0", "symfony/http-foundation": "~2.0" @@ -1541,7 +1541,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "0.4.x-dev" + "dev-master": "0.5.x-dev" } }, "autoload": { @@ -1564,7 +1564,7 @@ "keywords": [ "metadata" ], - "time": "2013-07-04 10:19:13" + "time": "2013-10-21 12:36:49" }, { "name": "monolog/monolog", @@ -1887,22 +1887,23 @@ }, { "name": "php-ffmpeg/php-ffmpeg", - "version": "0.3.4", + "version": "0.4.0", "source": { "type": "git", "url": "https://github.com/alchemy-fr/PHP-FFmpeg.git", - "reference": "c7226654828600e0c44ac6689a07e741b32147dd" + "reference": "0d82e5ad3cb50fd78882b5e15aaf57b39a274103" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/alchemy-fr/PHP-FFmpeg/zipball/c7226654828600e0c44ac6689a07e741b32147dd", - "reference": "c7226654828600e0c44ac6689a07e741b32147dd", + "url": "https://api.github.com/repos/alchemy-fr/PHP-FFmpeg/zipball/0d82e5ad3cb50fd78882b5e15aaf57b39a274103", + "reference": "0d82e5ad3cb50fd78882b5e15aaf57b39a274103", "shasum": "" }, "require": { "alchemy/binary-driver": "~1.5", "doctrine/cache": "~1.0", "evenement/evenement": "~1.0", + "neutron/temporary-filesystem": "~2.1, >=2.1.1", "php": ">=5.3.3" }, "require-dev": { @@ -1951,7 +1952,7 @@ "video", "video processing" ], - "time": "2013-09-05 10:09:39" + "time": "2013-10-21 12:16:28" }, { "name": "php-mp4box/php-mp4box", From 6e59e7aae6bb89d0465007deab568b0cdf5b55af Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Thu, 10 Oct 2013 16:43:41 +0200 Subject: [PATCH 5/5] Fix #1518 Can not edit tags in metadatas settings --- www/scripts/apps/admin/fields/views/edit.js | 2 +- www/scripts/tests/specs/admin/fields.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/www/scripts/apps/admin/fields/views/edit.js b/www/scripts/apps/admin/fields/views/edit.js index 2353fd9a4c..8fc9ed9d4e 100644 --- a/www/scripts/apps/admin/fields/views/edit.js +++ b/www/scripts/apps/admin/fields/views/edit.js @@ -125,8 +125,8 @@ define([ var fieldTag = $(e.target); var fieldTagId = fieldTag.attr("id"); var fieldTagValue = fieldTag.val(); + var notValid = "" === fieldTagValue; - var notValid = "" !== fieldTagValue; // check for format tag if (notValid) { fieldTag diff --git a/www/scripts/tests/specs/admin/fields.js b/www/scripts/tests/specs/admin/fields.js index 6d76b9c568..24224975d4 100644 --- a/www/scripts/tests/specs/admin/fields.js +++ b/www/scripts/tests/specs/admin/fields.js @@ -217,6 +217,14 @@ define([ it("should render as a DIV element", function() { this.view.render().el.nodeName.should.equal("DIV"); }); + + it("should render an error message if provided tag is empty", function() { + var view = this.view.render(); + + view.$('input#tag').val("").blur(); + + assert.isTrue(view.$('input#tag').closest(".control-group").hasClass("error")); + }); }); describe("FieldError Views", function() {