From a8b34348e714395bf15c88299adae1779253bb67 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Fri, 15 Feb 2019 18:30:30 +0100 Subject: [PATCH 01/18] [Debug][ErrorHandler] Preserve next error handler Co-authored-by: Joe --- src/Symfony/Component/Debug/ErrorHandler.php | 7 +++- .../Debug/Tests/ErrorHandlerTest.php | 39 +++++++++++++------ .../ErrorHandlerThatUsesThePreviousOne.php | 22 +++++++++++ .../Fixtures/LoggerThatSetAnErrorHandler.php | 5 ++- 4 files changed, 58 insertions(+), 15 deletions(-) create mode 100644 src/Symfony/Component/Debug/Tests/Fixtures/ErrorHandlerThatUsesThePreviousOne.php diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index 22a6426dab..66966db62d 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -517,6 +517,11 @@ class ErrorHandler $errorAsException ? ['exception' => $errorAsException] : [], ]; } else { + if (!\defined('HHVM_VERSION')) { + $currentErrorHandler = set_error_handler('var_dump'); + restore_error_handler(); + } + try { $this->isRecursive = true; $level = ($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG; @@ -525,7 +530,7 @@ class ErrorHandler $this->isRecursive = false; if (!\defined('HHVM_VERSION')) { - set_error_handler([$this, __FUNCTION__]); + set_error_handler($currentErrorHandler); } } } diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 6e0afd55ca..c1dea75bbd 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -12,12 +12,12 @@ namespace Symfony\Component\Debug\Tests; use PHPUnit\Framework\TestCase; -use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; use Psr\Log\NullLogger; use Symfony\Component\Debug\BufferingLogger; use Symfony\Component\Debug\ErrorHandler; use Symfony\Component\Debug\Exception\SilencedErrorContext; +use Symfony\Component\Debug\Tests\Fixtures\ErrorHandlerThatUsesThePreviousOne; use Symfony\Component\Debug\Tests\Fixtures\LoggerThatSetAnErrorHandler; /** @@ -590,26 +590,40 @@ class ErrorHandlerTest extends TestCase } /** - * @dataProvider errorHandlerIsNotLostWhenLoggingProvider + * @dataProvider errorHandlerWhenLoggingProvider */ - public function testErrorHandlerIsNotLostWhenLogging($customErrorHandlerHasBeenPreviouslyDefined, LoggerInterface $logger) + public function testErrorHandlerWhenLogging($previousHandlerWasDefined, $loggerSetsAnotherHandler, $nextHandlerIsDefined) { try { - if ($customErrorHandlerHasBeenPreviouslyDefined) { + if ($previousHandlerWasDefined) { set_error_handler('count'); } + $logger = $loggerSetsAnotherHandler ? new LoggerThatSetAnErrorHandler() : new NullLogger(); + $handler = ErrorHandler::register(); $handler->setDefaultLogger($logger); + if ($nextHandlerIsDefined) { + $handler = ErrorHandlerThatUsesThePreviousOne::register(); + } + @trigger_error('foo', E_USER_DEPRECATED); @trigger_error('bar', E_USER_DEPRECATED); $this->assertSame([$handler, 'handleError'], set_error_handler('var_dump')); + if ($logger instanceof LoggerThatSetAnErrorHandler) { + $this->assertCount(2, $logger->cleanLogs()); + } + restore_error_handler(); - if ($customErrorHandlerHasBeenPreviouslyDefined) { + if ($previousHandlerWasDefined) { + restore_error_handler(); + } + + if ($nextHandlerIsDefined) { restore_error_handler(); } } finally { @@ -618,13 +632,14 @@ class ErrorHandlerTest extends TestCase } } - public function errorHandlerIsNotLostWhenLoggingProvider() + public function errorHandlerWhenLoggingProvider() { - return [ - [false, new NullLogger()], - [true, new NullLogger()], - [false, new LoggerThatSetAnErrorHandler()], - [true, new LoggerThatSetAnErrorHandler()], - ]; + foreach ([false, true] as $previousHandlerWasDefined) { + foreach ([false, true] as $loggerSetsAnotherHandler) { + foreach ([false, true] as $nextHandlerIsDefined) { + yield [$previousHandlerWasDefined, $loggerSetsAnotherHandler, $nextHandlerIsDefined]; + } + } + } } } diff --git a/src/Symfony/Component/Debug/Tests/Fixtures/ErrorHandlerThatUsesThePreviousOne.php b/src/Symfony/Component/Debug/Tests/Fixtures/ErrorHandlerThatUsesThePreviousOne.php new file mode 100644 index 0000000000..d449c40cc7 --- /dev/null +++ b/src/Symfony/Component/Debug/Tests/Fixtures/ErrorHandlerThatUsesThePreviousOne.php @@ -0,0 +1,22 @@ + Date: Fri, 15 Feb 2019 10:01:57 +0200 Subject: [PATCH 02/18] =?UTF-8?q?#30172=20Add=20the=20missing=20validation?= =?UTF-8?q?=20translations=20for=20the=20Luxembourgish=20=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Resources/translations/validators.lb.xlf | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.lb.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.lb.xlf index bdbc9da09c..4c3579fb58 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.lb.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.lb.xlf @@ -322,6 +322,18 @@ This is not a valid UUID. Dëst ass keng gëlteg UUID. + + This value should be a multiple of {{ compared_value }}. + Dëse Wäert sollt e puer vun {{ compared_value }} sinn. + + + This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}. + Dëse "Business Identifier Code" (BIC) ass net mat IBAN verbonnen {{ iban }}. + + + This value should be valid JSON. + Dëse Wäert sollt gëlteg JSON. + From f9772359b3ed1d485ed44e746e2d493854a72541 Mon Sep 17 00:00:00 2001 From: JL Date: Thu, 14 Feb 2019 14:11:29 +0200 Subject: [PATCH 03/18] Update validators.lt.xlf --- .../Resources/translations/validators.lt.xlf | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf index 60641b5e68..9a20d9172e 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf @@ -302,10 +302,38 @@ An empty file is not allowed. Failas negali būti tuščias. + + The host could not be resolved. + Serveris nepasiekiamas. + + + This value does not match the expected {{ charset }} charset. + Ši reikšmė neatitinka {{ charset }} koduotės. + + + This is not a valid Business Identifier Code (BIC). + Bendrovės Identifikavimo Kodas (BIC) nėra tinkamas. + Error Klaida + + This is not a valid UUID. + Ši reikšmė nėra tinkamas UUID. + + + This value should be a multiple of {{ compared_value }}. + Ši reikšmė turi būti skaičiaus {{ compared_value }} kartotinis. + + + This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}. + Šis bendrovės identifikavimo kodas (BIC) nesusijęs su IBAN {{ iban }} + + + This value should be valid JSON. + Ši reikšmė turi būti tinkamo JSON formato. + From 85c448e915c5979949871127969809db0d213399 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 16 Feb 2019 12:46:43 +0100 Subject: [PATCH 04/18] added missing dot --- .../Validator/Resources/translations/validators.lt.xlf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf index 9a20d9172e..02eece5965 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf @@ -328,7 +328,7 @@ This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}. - Šis bendrovės identifikavimo kodas (BIC) nesusijęs su IBAN {{ iban }} + Šis bendrovės identifikavimo kodas (BIC) nesusijęs su IBAN {{ iban }}. This value should be valid JSON. From bd719cd7e1956404b41a90e0b76e9fb270a8cedd Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 13 Feb 2019 23:17:49 +0100 Subject: [PATCH 05/18] [Twig] removed usage of non-namespaced classes --- src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php b/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php index 04b8dda567..80e36e0491 100644 --- a/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php +++ b/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php @@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DataCollector\DataCollector; use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface; use Twig\Environment; +use Twig\Error\LoaderError; use Twig\Markup; use Twig\Profiler\Dumper\HtmlDumper; use Twig\Profiler\Profile; @@ -70,7 +71,7 @@ class TwigDataCollector extends DataCollector implements LateDataCollectorInterf if ($profile->isTemplate()) { try { $template = $this->twig->load($name = $profile->getName()); - } catch (\Twig_Error_Loader $e) { + } catch (LoaderError $e) { $template = null; } From 8743a1ada8963903bc25cf91258cc4733648e6e4 Mon Sep 17 00:00:00 2001 From: Ilya Bulakh Date: Thu, 14 Feb 2019 17:37:06 +0300 Subject: [PATCH 06/18] fix lost namespace in eval --- .../FrameworkBundle/Test/KernelShutdownOnTearDownTrait.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/KernelShutdownOnTearDownTrait.php b/src/Symfony/Bundle/FrameworkBundle/Test/KernelShutdownOnTearDownTrait.php index 7eb4d0726e..b01dbb0494 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/KernelShutdownOnTearDownTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/KernelShutdownOnTearDownTrait.php @@ -16,7 +16,9 @@ use PHPUnit\Framework\TestCase; // Auto-adapt to PHPUnit 8 that added a `void` return-type to the tearDown method if (method_exists(\ReflectionMethod::class, 'hasReturnType') && (new \ReflectionMethod(TestCase::class, 'tearDown'))->hasReturnType()) { -eval(' + eval(' + namespace Symfony\Bundle\FrameworkBundle\Test; + /** * @internal */ From da325fc0e2b8348f839ed497384cabce39aa6e01 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 16 Feb 2019 12:54:38 +0100 Subject: [PATCH 07/18] bug #30245 fix lost namespace in eval (fizzka) This PR was squashed before being merged into the 4.2 branch (closes #30245). Discussion ---------- fix lost namespace in eval Bugfix: phpunit8 tearDown() declaration Commits ------- 8743a1ada8 fix lost namespace in eval --- .../FrameworkBundle/Test/KernelShutdownOnTearDownTrait.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/KernelShutdownOnTearDownTrait.php b/src/Symfony/Bundle/FrameworkBundle/Test/KernelShutdownOnTearDownTrait.php index 7eb4d0726e..b01dbb0494 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/KernelShutdownOnTearDownTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/KernelShutdownOnTearDownTrait.php @@ -16,7 +16,9 @@ use PHPUnit\Framework\TestCase; // Auto-adapt to PHPUnit 8 that added a `void` return-type to the tearDown method if (method_exists(\ReflectionMethod::class, 'hasReturnType') && (new \ReflectionMethod(TestCase::class, 'tearDown'))->hasReturnType()) { -eval(' + eval(' + namespace Symfony\Bundle\FrameworkBundle\Test; + /** * @internal */ From 1090b8cb6e7abb946a0c64d021de85ebdee25a7b Mon Sep 17 00:00:00 2001 From: Gocha Ossinkine Date: Thu, 14 Feb 2019 21:08:19 +0500 Subject: [PATCH 08/18] Don't resolve the Deprecation error handler mode until a deprecation is triggered --- src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index b81eff528a..fc60cbd436 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -105,8 +105,7 @@ class DeprecationErrorHandler 'remaining vendor' => array(), ); $deprecationHandler = function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, $getMode, $UtilPrefix, $inVendors) { - $mode = $getMode(); - if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || DeprecationErrorHandler::MODE_DISABLED === $mode) { + if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || DeprecationErrorHandler::MODE_DISABLED === $mode = $getMode()) { $ErrorHandler = $UtilPrefix.'ErrorHandler'; return $ErrorHandler::handleError($type, $msg, $file, $line, $context); From d10347fb15849f7aa51c897079d4d23253fcb2ce Mon Sep 17 00:00:00 2001 From: devrck Date: Sat, 16 Feb 2019 21:49:57 +0100 Subject: [PATCH 09/18] [Validator] Added missing use statement for UnexpectedTypeException --- src/Symfony/Component/Validator/Constraints/CountValidator.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/Validator/Constraints/CountValidator.php b/src/Symfony/Component/Validator/Constraints/CountValidator.php index adedacdc62..301358bcf7 100644 --- a/src/Symfony/Component/Validator/Constraints/CountValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CountValidator.php @@ -13,6 +13,7 @@ namespace Symfony\Component\Validator\Constraints; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Exception\UnexpectedValueException; /** From 46d6a4d9ec54a57e271accf955c4a7bd9945ae3e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 16 Feb 2019 23:37:38 +0100 Subject: [PATCH 10/18] [VarDumper] fix serializing Stub instances --- .../Component/VarDumper/Cloner/Stub.php | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Component/VarDumper/Cloner/Stub.php b/src/Symfony/Component/VarDumper/Cloner/Stub.php index 08fba75930..27dd3ef32c 100644 --- a/src/Symfony/Component/VarDumper/Cloner/Stub.php +++ b/src/Symfony/Component/VarDumper/Cloner/Stub.php @@ -39,22 +39,29 @@ class Stub public $position = 0; public $attr = []; + private static $defaultProperties = []; + /** * @internal */ public function __sleep() { - $this->serialized = [$this->class, $this->position, $this->cut, $this->type, $this->value, $this->handle, $this->refCount, $this->attr]; + $properties = []; - return ['serialized']; - } + if (!isset(self::$defaultProperties[$c = \get_class($this)])) { + self::$defaultProperties[$c] = get_class_vars($c); - /** - * @internal - */ - public function __wakeup() - { - list($this->class, $this->position, $this->cut, $this->type, $this->value, $this->handle, $this->refCount, $this->attr) = $this->serialized; - unset($this->serialized); + foreach ((new \ReflectionClass($c))->getStaticProperties() as $k => $v) { + unset(self::$defaultProperties[$c][$k]); + } + } + + foreach (self::$defaultProperties[$c] as $k => $v) { + if ($this->$k !== $v) { + $properties[] = $k; + } + } + + return $properties; } } From 5cac9ad97d3d736f30ba948a4f2d2e8b3d0c3278 Mon Sep 17 00:00:00 2001 From: Eno Mullaraj Date: Sun, 17 Feb 2019 13:24:11 +0100 Subject: [PATCH 11/18] [Validator] improve translations for albanian ("sq") locale * improve overall translation message consistency * fix singular expression messages * fix grammatical errors * use albanian form of expression * restore as lexical gap the "locale" translation --- .../Resources/translations/validators.sq.xlf | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.sq.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.sq.xlf index 4ee22e31f2..569ebca47f 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.sq.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.sq.xlf @@ -24,15 +24,15 @@ You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices. - Duhet të zgjedhni së paku {{ limit }} alternativa.|Duhet të zgjedhni së paku {{ limit }} alternativa. + Duhet të zgjedhni së paku {{ limit }} alternativë.|Duhet të zgjedhni së paku {{ limit }} alternativa. You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices. - Duhet të zgjedhni më së shumti {{ limit }} alternativa.|Duhet të zgjedhni më së shumti {{ limit }} alternativa. + Duhet të zgjedhni më së shumti {{ limit }} alternativë.|Duhet të zgjedhni më së shumti {{ limit }} alternativa. One or more of the given values is invalid. - Një apo më shumë nga vlerat e dhëna nuk janë të sakta. + Një apo më shumë nga vlerat e dhëna janë të pavlefshme. This field was not expected. @@ -40,7 +40,7 @@ This field is missing. - Kjo fushë është zhdukur. + Kjo fushë mungon. This value is not a valid date. @@ -52,7 +52,7 @@ This value is not a valid email address. - Kjo vlerë nuk është e-mail adresë e vlefshme. + Kjo vlerë nuk është adresë email-i e vlefshme. The file could not be found. @@ -64,11 +64,11 @@ The file is too large ({{ size }} {{ suffix }}). Allowed maximum size is {{ limit }} {{ suffix }}. - File është shumë i madh ({{ size }} {{ suffix }}). Madhësia më e madhe e lejuar është {{ limit }} {{ suffix }}. + File është shumë i madh ({{ size }} {{ suffix }}). Madhësia maksimale e lejuar është {{ limit }} {{ suffix }}. The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}. - Lloji mime i files nuk është i vlefshëm ({{ type }}). Llojet mime të lejuara janë {{ types }}. + Lloji mime i file-it është i pavlefshëm ({{ type }}). Llojet mime të lejuara janë {{ types }}. This value should be {{ limit }} or less. @@ -76,7 +76,7 @@ This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less. - Kjo vlerë është shumë e gjatë. Duhet t'i ketë {{ limit }} ose më pak karaktere.|Kjo vlerë është shumë e gjatë. Duhet t'i ketë {{ limit }} ose më pak karaktere. + Kjo vlerë është shumë e gjatë. Duhet të përmbaj {{ limit }} karakter ose më pak.|Kjo vlerë është shumë e gjatë. Duhet të përmbaj {{ limit }} karaktere ose më pak. This value should be {{ limit }} or more. @@ -84,7 +84,7 @@ This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more. - Kjo vlerë është shumë e shkurtër. Duhet t'i ketë {{ limit }} ose më shumë karaktere.|Kjo vlerë është shumë e shkurtër. Duhet t'i ketë {{ limit }} ose më shumë karaktere. + Kjo vlerë është shumë e shkurtër. Duhet të përmbaj {{ limit }} karakter ose më shumë.|Kjo vlerë është shumë e shkurtër. Duhet të përmbaj {{ limit }} karaktere ose më shumë. This value should not be blank. @@ -136,7 +136,7 @@ This is not a valid IP address. - Kjo vlerë nuk është IP adresë e vlefshme. + Kjo adresë IP nuk është e vlefshme. This value is not a valid language. @@ -144,7 +144,7 @@ This value is not a valid locale. - Kjo vlerë nuk është përcaktim rajonal i vlefshëm. + Kjo vlerë nuk është nje locale i vlefshëm. This value is not a valid country. @@ -156,7 +156,7 @@ The size of the image could not be detected. - Madhësia e këtij imazhi nuk mund të zbulohet. + Madhësia e imazhit nuk mund të zbulohet. The image width is too big ({{ width }}px). Allowed maximum width is {{ max_width }}px. @@ -180,7 +180,7 @@ This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters. - Kjo vlerë duhet të ketë saktësisht {{ limit }} karaktere.|Kjo vlerë duhet të ketë saktësisht {{ limit }} karaktere. + Kjo vlerë duhet të ketë saktësisht {{ limit }} karakter.|Kjo vlerë duhet të ketë saktësisht {{ limit }} karaktere. The file was only partially uploaded. @@ -200,27 +200,27 @@ A PHP extension caused the upload to fail. - Një ekstenzion i PHP-së bëri të dështojë ngarkimi i files. + Një ekstension i PHP-së shkaktoi dështimin e ngarkimit. This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more. - Ky kolekcion duhet të përmbajë {{ limit }} ose më shumë elemente.|Ky kolekcion duhet të përmbajë {{ limit }} ose më shumë elemente. + Ky koleksion duhet të përmbajë {{ limit }} element ose më shumë.|Ky koleksion duhet të përmbajë {{ limit }} elemente ose më shumë. This collection should contain {{ limit }} element or less.|This collection should contain {{ limit }} elements or less. - Ky kolekcion duhet të përmbajë {{ limit }} ose më pak elemente.|Ky kolekcion duhet të përmbajë {{ limit }} ose më pak elemente. + Ky koleksion duhet të përmbajë {{ limit }} element ose më pak.|Ky koleksion duhet të përmbajë {{ limit }} elemente ose më pak. This collection should contain exactly {{ limit }} element.|This collection should contain exactly {{ limit }} elements. - Ky kolekcion duhet të përmbajë saktësisht {{ limit }} elemente.|Ky kolekcion duhet të përmbajë saktësisht {{ limit }} elemente. + Ky koleksion duhet të përmbajë saktësisht {{ limit }} element.|Ky koleksion duhet të përmbajë saktësisht {{ limit }} elemente. Invalid card number. - Numër kartele i pavlefshëm. + Numër karte i pavlefshëm. Unsupported card type or invalid card number. - Lloj kartele i pambështetur ose numër kartele i pavlefshëm. + Lloj karte i papranuar ose numër karte i pavlefshëm. This is not a valid International Bank Account Number (IBAN). @@ -292,11 +292,11 @@ The image is landscape oriented ({{ width }}x{{ height }}px). Landscape oriented images are not allowed. - Imazhi është i orientuar nga landscape ({{ width }}x{{ height }}px). Imazhet e orientuara nga landscape nuk lejohen. + Imazhi është i orientuar horizontalisht ({{ width }}x{{ height }}px). Imazhet e orientuara horizontalisht nuk lejohen. The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed. - Imazhi është portret i orientuar ({{ width }}x{{ height }}px). Imazhet orientuese të portretit nuk lejohen. + Imazhi është i orientuar vertikalisht ({{ width }}x{{ height }}px). Imazhet orientuara vertikalisht nuk lejohen. An empty file is not allowed. @@ -304,15 +304,15 @@ The host could not be resolved. - Probleme me Host + Host-i nuk mund te zbulohej. This value does not match the expected {{ charset }} charset. - Kjo vlerë nuk përputhet me karakteret {{ charset }} e pritura. + Kjo vlerë nuk përputhet me kodifikimin e karaktereve {{ charset }} që pritej. This is not a valid Business Identifier Code (BIC). - Ky nuk është një Kod i Identifikueshëm i Biznesit (BIC). + Ky nuk është një Kod Identifikues i Biznesit (BIC) i vleflshem. Error @@ -320,7 +320,7 @@ This is not a valid UUID. - Kjo nuk është një UUID e vlefshme. + Ky nuk është një UUID i vlefshëm. This value should be a multiple of {{ compared_value }}. From 3fbcb965d0e7d2b9ea50075a47e623e647e5771e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Ostroluck=C3=BD?= Date: Sun, 17 Feb 2019 18:39:16 +0100 Subject: [PATCH 12/18] Remove unnecessary ProgressBar stdout writes (fixes flickering) --- .../Component/Console/Helper/ProgressBar.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/Console/Helper/ProgressBar.php b/src/Symfony/Component/Console/Helper/ProgressBar.php index a1c3cc5d21..1725655141 100644 --- a/src/Symfony/Component/Console/Helper/ProgressBar.php +++ b/src/Symfony/Component/Console/Helper/ProgressBar.php @@ -466,19 +466,16 @@ final class ProgressBar { if ($this->overwrite) { if (!$this->firstRun) { - // Move the cursor to the beginning of the line - $this->output->write("\x0D"); - - // Erase the line - $this->output->write("\x1B[2K"); - // Erase previous lines if ($this->formatLineCount > 0) { - $this->output->write(str_repeat("\x1B[1A\x1B[2K", $this->formatLineCount)); + $message = str_repeat("\x1B[1A\x1B[2K", $this->formatLineCount).$message; } + + // Move the cursor to the beginning of the line and erase the line + $message = "\x0D\x1B[2K$message"; } } elseif ($this->step > 0) { - $this->output->writeln(''); + $message = PHP_EOL.$message; } $this->firstRun = false; From ad752b1a484f47628a9f5f0d1716505465a32be6 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Sun, 17 Feb 2019 19:45:33 +0100 Subject: [PATCH 13/18] [TwigBridge] Fix test --- src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php index e0e08232f5..3008f43f6f 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php @@ -54,7 +54,7 @@ class TransNodeTest extends TestCase protected function getVariableGetterWithStrictCheck($name) { if (Environment::MAJOR_VERSION >= 2) { - return sprintf('(isset($context["%1$s"]) || array_key_exists("%1$s", $context) ? $context["%1$s"] : (function () { throw new %2$s(\'Variable "%1$s" does not exist.\', 0, $this->source); })())', $name, Environment::VERSION_ID >= 20700 ? '\Twig\Error\RuntimeError' : 'Twig_Error_Runtime'); + return sprintf('(isset($context["%1$s"]) || array_key_exists("%1$s", $context) ? $context["%1$s"] : (function () { throw new %2$s(\'Variable "%1$s" does not exist.\', 0, $this->source); })())', $name, Environment::VERSION_ID >= 20700 ? 'RuntimeError' : 'Twig_Error_Runtime'); } if (\PHP_VERSION_ID >= 70000) { From 93cfd5b2a037195d292c15e0bc236e92e6c81f07 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 17 Feb 2019 23:00:14 +0100 Subject: [PATCH 14/18] [Security\Guard] bump lowest version of security-core --- src/Symfony/Component/Security/Guard/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Guard/composer.json b/src/Symfony/Component/Security/Guard/composer.json index de14c9b5e9..5d38065ff6 100644 --- a/src/Symfony/Component/Security/Guard/composer.json +++ b/src/Symfony/Component/Security/Guard/composer.json @@ -17,7 +17,7 @@ ], "require": { "php": "^5.5.9|>=7.0.8", - "symfony/security-core": "~2.8|~3.0|~4.0", + "symfony/security-core": "~3.4.22|^4.2.3", "symfony/security-http": "^3.3.13|~4.0" }, "require-dev": { From c8dcc5b8e64564d2fb81920a0a1fbc21cdba63e3 Mon Sep 17 00:00:00 2001 From: caalholm Date: Mon, 18 Feb 2019 10:23:26 +0100 Subject: [PATCH 15/18] [Validator] Added missing translations for Norwegian (\"no\") locale #30179 --- .../Resources/translations/validators.no.xlf | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf index 250576531c..db534528d1 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf @@ -314,6 +314,26 @@ This is not a valid Business Identifier Code (BIC). Dette er ikke en gyldig BIC. + + Error + Feil + + + This is not a valid UUID. + Dette er ikke en gyldig UUID. + + + This value should be a multiple of {{ compared_value }}. + Verdien skal være flertall av {{ compared_value }}. + + + This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}. + Business Identifier Code (BIC) er ikke tilknyttet en IBAN {{ iban }}. + + + This value should be valid JSON. + Verdien er ikke gyldig JSON. + From 5ca7dedaaa3c8b9ec29fd4a134f2df15f4d46500 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 14 Feb 2019 10:26:11 +0100 Subject: [PATCH 16/18] [Translation] Added a script to display the status of translations --- .../Resources/bin/translation-status.php | 195 ++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 src/Symfony/Component/Translation/Resources/bin/translation-status.php diff --git a/src/Symfony/Component/Translation/Resources/bin/translation-status.php b/src/Symfony/Component/Translation/Resources/bin/translation-status.php new file mode 100644 index 0000000000..acc8b4e227 --- /dev/null +++ b/src/Symfony/Component/Translation/Resources/bin/translation-status.php @@ -0,0 +1,195 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +$usageInstructions = << false, + // NULL = analyze all locales + 'locale_to_analyze' => null, + // the reference files all the other translations are compared to + 'original_files' => [ + 'src/Symfony/Component/Form/Resources/translations/validators.en.xlf', + 'src/Symfony/Component/Security/Core/Resources/translations/security.en.xlf', + 'src/Symfony/Component/Validator/Resources/translations/validators.en.xlf', + ], +]; + +$argc = $_SERVER['argc']; +$argv = $_SERVER['argv']; + +if ($argc > 3) { + echo str_replace('translation-status.php', $argv[0], $usageInstructions); + exit(1); +} + +foreach (array_slice($argv, 1) as $argumentOrOption) { + if (0 === strpos($argumentOrOption, '-')) { + $config['verbose_output'] = true; + } else { + $config['locale_to_analyze'] = $argumentOrOption; + } +} + +foreach ($config['original_files'] as $originalFilePath) { + if (!file_exists($originalFilePath)) { + echo sprintf('The following file does not exist. Make sure that you execute this command at the root dir of the Symfony code repository.%s %s', PHP_EOL, $originalFilePath); + exit(1); + } +} + +$totalMissingTranslations = 0; + +foreach ($config['original_files'] as $originalFilePath) { + $translationFilePaths = findTranslationFiles($originalFilePath, $config['locale_to_analyze']); + $translationStatus = calculateTranslationStatus($originalFilePath, $translationFilePaths); + + $totalMissingTranslations += array_sum(array_map(function ($translation) { + return \count($translation['missingKeys']); + }, array_values($translationStatus))); + + printTranslationStatus($originalFilePath, $translationStatus, $config['verbose_output']); +} + +exit($totalMissingTranslations > 0 ? 1 : 0); + +function findTranslationFiles($originalFilePath, $localeToAnalyze) +{ + $translations = []; + + $translationsDir = dirname($originalFilePath); + $originalFileName = basename($originalFilePath); + $translationFileNamePattern = str_replace('.en.', '.*.', $originalFileName); + + $translationFiles = glob($translationsDir.'/'.$translationFileNamePattern); + foreach ($translationFiles as $filePath) { + $locale = extractLocaleFromFilePath($filePath); + + if (null !== $localeToAnalyze && $locale !== $localeToAnalyze) { + continue; + } + + $translations[$locale] = $filePath; + } + + return $translations; +} + +function calculateTranslationStatus($originalFilePath, $translationFilePaths) +{ + $translationStatus = []; + $allTranslationKeys = extractTranslationKeys($originalFilePath); + + foreach ($translationFilePaths as $locale => $translationPath) { + $translatedKeys = extractTranslationKeys($translationPath); + $missingKeys = array_diff_key($allTranslationKeys, $translatedKeys); + + $translationStatus[$locale] = [ + 'total' => \count($allTranslationKeys), + 'translated' => \count($translatedKeys), + 'missingKeys' => $missingKeys, + ]; + } + + return $translationStatus; +} + +function printTranslationStatus($originalFilePath, $translationStatus, $verboseOutput) +{ + printTitle($originalFilePath); + printTable($translationStatus, $verboseOutput); + echo PHP_EOL.PHP_EOL; +} + +function extractLocaleFromFilePath($filePath) +{ + $parts = explode('.', $filePath); + + return $parts[count($parts) - 2]; +} + +function extractTranslationKeys($filePath) +{ + $translationKeys = []; + $contents = new \SimpleXMLElement(file_get_contents($filePath)); + + foreach ($contents->file->body->{'trans-unit'} as $translationKey) { + $translationId = (string) $translationKey['id']; + $translationKey = (string) $translationKey->source; + + $translationKeys[$translationId] = $translationKey; + } + + return $translationKeys; +} + +function printTitle($title) +{ + echo $title.PHP_EOL; + echo str_repeat('=', strlen($title)).PHP_EOL.PHP_EOL; +} + +function printTable($translations, $verboseOutput) +{ + $longestLocaleNameLength = max(array_map('strlen', array_keys($translations))); + + foreach ($translations as $locale => $translation) { + $isTranslationCompleted = $translation['translated'] === $translation['total']; + if ($isTranslationCompleted) { + textColorGreen(); + } + + echo sprintf('| Locale: %-'.$longestLocaleNameLength.'s | Translated: %d/%d', $locale, $translation['translated'], $translation['total']).PHP_EOL; + + textColorNormal(); + + if (true === $verboseOutput && \count($translation['missingKeys']) > 0) { + echo str_repeat('-', 80).PHP_EOL; + echo '| Missing Translations:'.PHP_EOL; + + foreach ($translation['missingKeys'] as $id => $content) { + echo sprintf('| (id=%s) %s', $id, $content).PHP_EOL; + } + + echo str_repeat('-', 80).PHP_EOL; + } + } +} + +function textColorGreen() +{ + echo "\033[32m"; +} + +function textColorNormal() +{ + echo "\033[0m"; +} From f2af0801c4c3212cf02c1231e6f1d2c03f0c5875 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Mon, 18 Feb 2019 15:33:02 +0100 Subject: [PATCH 17/18] [Validator] Sync no/nb translation files --- .../Resources/translations/validators.nb.xlf | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf index 250576531c..db534528d1 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf @@ -314,6 +314,26 @@ This is not a valid Business Identifier Code (BIC). Dette er ikke en gyldig BIC. + + Error + Feil + + + This is not a valid UUID. + Dette er ikke en gyldig UUID. + + + This value should be a multiple of {{ compared_value }}. + Verdien skal være flertall av {{ compared_value }}. + + + This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}. + Business Identifier Code (BIC) er ikke tilknyttet en IBAN {{ iban }}. + + + This value should be valid JSON. + Verdien er ikke gyldig JSON. + From ac4e9b0b265add48604c58a17d3c7593c0587614 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Sat, 16 Feb 2019 17:06:31 +0100 Subject: [PATCH 18/18] [Console] Fix command testing with missing inputs --- .../Console/Helper/QuestionHelper.php | 10 +++--- .../Console/Tester/CommandTester.php | 5 ++- .../Tests/Helper/QuestionHelperTest.php | 14 ++++++-- .../Helper/SymfonyQuestionHelperTest.php | 2 +- .../Tests/Tester/CommandTesterTest.php | 32 +++++++++++++++++-- 5 files changed, 51 insertions(+), 12 deletions(-) diff --git a/src/Symfony/Component/Console/Helper/QuestionHelper.php b/src/Symfony/Component/Console/Helper/QuestionHelper.php index d3188897f3..17295adb3a 100644 --- a/src/Symfony/Component/Console/Helper/QuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/QuestionHelper.php @@ -166,7 +166,7 @@ class QuestionHelper extends Helper if (false === $ret) { $ret = fgets($inputStream, 4096); if (false === $ret) { - throw new RuntimeException('Aborted'); + throw new RuntimeException('Aborted.'); } $ret = trim($ret); } @@ -252,8 +252,10 @@ class QuestionHelper extends Helper while (!feof($inputStream)) { $c = fread($inputStream, 1); - // Backspace Character - if ("\177" === $c) { + // as opposed to fgets(), fread() returns an empty string when the stream content is empty, not false. + if (false === $c || ('' === $ret && '' === $c && null === $question->getDefault())) { + throw new RuntimeException('Aborted.'); + } elseif ("\177" === $c) { // Backspace Character if (0 === $numMatches && 0 !== $i) { --$i; // Move cursor backwards @@ -380,7 +382,7 @@ class QuestionHelper extends Helper shell_exec(sprintf('stty %s', $sttyMode)); if (false === $value) { - throw new RuntimeException('Aborted'); + throw new RuntimeException('Aborted.'); } $value = trim($value); diff --git a/src/Symfony/Component/Console/Tester/CommandTester.php b/src/Symfony/Component/Console/Tester/CommandTester.php index 229471e13a..f869995eb9 100644 --- a/src/Symfony/Component/Console/Tester/CommandTester.php +++ b/src/Symfony/Component/Console/Tester/CommandTester.php @@ -62,9 +62,8 @@ class CommandTester } $this->input = new ArrayInput($input); - if ($this->inputs) { - $this->input->setStream(self::createStream($this->inputs)); - } + // Use an in-memory input stream even if no inputs are set so that QuestionHelper::ask() does not rely on the blocking STDIN. + $this->input->setStream(self::createStream($this->inputs)); if (isset($options['interactive'])) { $this->input->setInteractive($options['interactive']); diff --git a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php index 531474eddf..805b1311f5 100644 --- a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php @@ -900,7 +900,7 @@ class QuestionHelperTest extends AbstractQuestionHelperTest /** * @expectedException \Symfony\Component\Console\Exception\RuntimeException - * @expectedExceptionMessage Aborted + * @expectedExceptionMessage Aborted. */ public function testAskThrowsExceptionOnMissingInput() { @@ -910,7 +910,17 @@ class QuestionHelperTest extends AbstractQuestionHelperTest /** * @expectedException \Symfony\Component\Console\Exception\RuntimeException - * @expectedExceptionMessage Aborted + * @expectedExceptionMessage Aborted. + */ + public function testAskThrowsExceptionOnMissingInputForChoiceQuestion() + { + $dialog = new QuestionHelper(); + $dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream('')), $this->createOutputInterface(), new ChoiceQuestion('Choice', ['a', 'b'])); + } + + /** + * @expectedException \Symfony\Component\Console\Exception\RuntimeException + * @expectedExceptionMessage Aborted. */ public function testAskThrowsExceptionOnMissingInputWithValidator() { diff --git a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php index e7fd806064..cf7a78c34e 100644 --- a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php @@ -124,7 +124,7 @@ class SymfonyQuestionHelperTest extends AbstractQuestionHelperTest /** * @expectedException \Symfony\Component\Console\Exception\RuntimeException - * @expectedExceptionMessage Aborted + * @expectedExceptionMessage Aborted. */ public function testAskThrowsExceptionOnMissingInput() { diff --git a/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php b/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php index 8cad7f0385..f916b1821f 100644 --- a/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php +++ b/src/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php @@ -17,6 +17,7 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\HelperSet; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Output\Output; +use Symfony\Component\Console\Question\ChoiceQuestion; use Symfony\Component\Console\Question\Question; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Tester\CommandTester; @@ -139,7 +140,7 @@ class CommandTesterTest extends TestCase /** * @expectedException \RuntimeException - * @expectedMessage Aborted + * @expectedExceptionMessage Aborted. */ public function testCommandWithWrongInputsNumber() { @@ -153,13 +154,40 @@ class CommandTesterTest extends TestCase $command->setHelperSet(new HelperSet([new QuestionHelper()])); $command->setCode(function ($input, $output) use ($questions, $command) { $helper = $command->getHelper('question'); + $helper->ask($input, $output, new ChoiceQuestion('choice', ['a', 'b'])); + $helper->ask($input, $output, new Question($questions[0])); + $helper->ask($input, $output, new Question($questions[1])); + $helper->ask($input, $output, new Question($questions[2])); + }); + + $tester = new CommandTester($command); + $tester->setInputs(['a', 'Bobby', 'Fine']); + $tester->execute([]); + } + + /** + * @expectedException \RuntimeException + * @expectedExceptionMessage Aborted. + */ + public function testCommandWithQuestionsButNoInputs() + { + $questions = [ + 'What\'s your name?', + 'How are you?', + 'Where do you come from?', + ]; + + $command = new Command('foo'); + $command->setHelperSet(new HelperSet([new QuestionHelper()])); + $command->setCode(function ($input, $output) use ($questions, $command) { + $helper = $command->getHelper('question'); + $helper->ask($input, $output, new ChoiceQuestion('choice', ['a', 'b'])); $helper->ask($input, $output, new Question($questions[0])); $helper->ask($input, $output, new Question($questions[1])); $helper->ask($input, $output, new Question($questions[2])); }); $tester = new CommandTester($command); - $tester->setInputs(['Bobby', 'Fine']); $tester->execute([]); }