From d9ea6175451f0beb8be15d5e771bb2d3b0e7f7c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Vandoorine?= Date: Thu, 28 Nov 2019 09:24:06 +0100 Subject: [PATCH 1/2] Fixes #1750 added proper block cloning to put the image size part after the #number and fixing Process call to array instead of string --- src/PhpWord/TemplateProcessor.php | 2 +- tests/PhpWord/_includes/AbstractWebServerEmbeddedTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index 7efc0f1ac8..96b379c158 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -1085,7 +1085,7 @@ protected function indexClonedVariables($count, $xmlBlock) { $results = array(); for ($i = 1; $i <= $count; $i++) { - $results[] = preg_replace('/\$\{(.*?)\}/', '\${\\1#' . $i . '}', $xmlBlock); + $results[] = preg_replace('/\$\{(.*?)(:.*)?\}/', '\${\1#' . $i . '\2}', $xmlBlock); } return $results; diff --git a/tests/PhpWord/_includes/AbstractWebServerEmbeddedTest.php b/tests/PhpWord/_includes/AbstractWebServerEmbeddedTest.php index 9316a9fe61..39714365cb 100644 --- a/tests/PhpWord/_includes/AbstractWebServerEmbeddedTest.php +++ b/tests/PhpWord/_includes/AbstractWebServerEmbeddedTest.php @@ -26,7 +26,7 @@ abstract class AbstractWebServerEmbeddedTest extends \PHPUnit\Framework\TestCase public static function setUpBeforeClass() { if (self::isBuiltinServerSupported()) { - self::$httpServer = new Process('php -S localhost:8080 -t tests/PhpWord/_files'); + self::$httpServer = new Process(array('php', '-S', 'localhost:8080', '-t', 'tests/PhpWord/_files')); self::$httpServer->start(); while (!self::$httpServer->isRunning()) { usleep(1000); From 0945a37c6198ff1b57fd7367227911828e60f52a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Vandoorine?= Date: Mon, 2 Dec 2019 08:54:45 +0100 Subject: [PATCH 2/2] Fixed block capture so that it would work properly with blocks to be cloned in rows --- src/PhpWord/TemplateProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index 96b379c158..75cc78395d 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -1085,7 +1085,7 @@ protected function indexClonedVariables($count, $xmlBlock) { $results = array(); for ($i = 1; $i <= $count; $i++) { - $results[] = preg_replace('/\$\{(.*?)(:.*)?\}/', '\${\1#' . $i . '\2}', $xmlBlock); + $results[] = preg_replace('/\$\{([^:]*?)(:.*?)?\}/', '\${\1#' . $i . '\2}', $xmlBlock); } return $results;