diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php
index ef77cb745e..b84becb750 100644
--- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php
+++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php
@@ -355,8 +355,22 @@ class AutowirePass extends AbstractRecursivePass
unset($this->ambiguousServiceTypes[$type]);
}
- if (!$reflectionClass = $this->container->getReflectionClass($definition->getClass(), true)) {
- return;
+ if ($deprecated = $definition->isDeprecated()) {
+ $prevErrorHandler = set_error_handler(function ($level, $message, $file, $line) use (&$prevErrorHandler) {
+ return (E_USER_DEPRECATED === $level || !$prevErrorHandler) ? false : $prevErrorHandler($level, $message, $file, $line);
+ });
+ }
+
+ $e = null;
+
+ try {
+ if (!$reflectionClass = $this->container->getReflectionClass($definition->getClass(), true)) {
+ return;
+ }
+ } finally {
+ if ($deprecated) {
+ restore_error_handler();
+ }
}
foreach ($reflectionClass->getInterfaces() as $reflectionInterface) {
diff --git a/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd b/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd
index 55530c4723..1a242d2134 100644
--- a/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd
+++ b/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd
@@ -197,8 +197,8 @@
-
-
+
+
@@ -210,8 +210,8 @@
-
-
+
+
@@ -223,10 +223,9 @@
-
-
-
-
+
+
+
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php
index d48b1d8409..687f56ff74 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php
@@ -595,6 +595,17 @@ class AutowirePassTest extends TestCase
$pass->process($container);
}
+ public function testProcessDoesNotTriggerDeprecations()
+ {
+ $container = new ContainerBuilder();
+ $container->register('deprecated', 'Symfony\Component\DependencyInjection\Tests\Fixtures\DeprecatedClass')->setDeprecated(true);
+ $container->register('foo', __NAMESPACE__.'\Foo');
+ $container->register('bar', __NAMESPACE__.'\Bar')->setAutowired(true);
+
+ $pass = new AutowirePass();
+ $pass->process($container);
+ }
+
public function testEmptyStringIsKept()
{
$container = new ContainerBuilder();
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/DeprecatedClass.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/DeprecatedClass.php
new file mode 100644
index 0000000000..33f37a0304
--- /dev/null
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/DeprecatedClass.php
@@ -0,0 +1,18 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\DependencyInjection\Tests\Fixtures;
+
+@trigger_error('deprecated', E_USER_DEPRECATED);
+
+class DeprecatedClass
+{
+}
diff --git a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php
index 5bd0d34e64..a60690f851 100644
--- a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php
+++ b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php
@@ -149,6 +149,17 @@ class TranslatorCacheTest extends TestCase
$this->assertEquals('OK', $translator->trans($msgid), '-> the cache was overwritten by another translator instance in '.($debug ? 'debug' : 'production'));
}
+ public function testGeneratedCacheFilesAreOnlyBelongRequestedLocales()
+ {
+ $translator = new Translator('a', null, $this->tmpDir);
+ $translator->setFallbackLocales(array('b'));
+ $translator->trans('bar');
+
+ $cachedFiles = glob($this->tmpDir.'/*.php');
+
+ $this->assertCount(1, $cachedFiles);
+ }
+
public function testDifferentCacheFilesAreUsedForDifferentSetsOfFallbackLocales()
{
/*
diff --git a/src/Symfony/Component/Translation/Translator.php b/src/Symfony/Component/Translation/Translator.php
index a2af7fb44e..5f8eb03304 100644
--- a/src/Symfony/Component/Translation/Translator.php
+++ b/src/Symfony/Component/Translation/Translator.php
@@ -386,7 +386,7 @@ EOF
foreach ($this->computeFallbackLocales($locale) as $fallback) {
if (!isset($this->catalogues[$fallback])) {
- $this->loadCatalogue($fallback);
+ $this->initializeCatalogue($fallback);
}
$fallbackCatalogue = new MessageCatalogue($fallback, $this->catalogues[$fallback]->all());
diff --git a/src/Symfony/Component/Validator/Constraints/EmailValidator.php b/src/Symfony/Component/Validator/Constraints/EmailValidator.php
index 2d779e6880..25df180de0 100644
--- a/src/Symfony/Component/Validator/Constraints/EmailValidator.php
+++ b/src/Symfony/Component/Validator/Constraints/EmailValidator.php
@@ -87,7 +87,7 @@ class EmailValidator extends ConstraintValidator
return;
}
- $host = substr($value, strrpos($value, '@') + 1);
+ $host = (string) substr($value, strrpos($value, '@') + 1);
// Check for host DNS resource records
if ($constraint->checkMX) {
@@ -118,7 +118,7 @@ class EmailValidator extends ConstraintValidator
*/
private function checkMX($host)
{
- return checkdnsrr($host, 'MX');
+ return '' !== $host && checkdnsrr($host, 'MX');
}
/**
@@ -130,6 +130,6 @@ class EmailValidator extends ConstraintValidator
*/
private function checkHost($host)
{
- return $this->checkMX($host) || (checkdnsrr($host, 'A') || checkdnsrr($host, 'AAAA'));
+ return '' !== $host && ($this->checkMX($host) || (checkdnsrr($host, 'A') || checkdnsrr($host, 'AAAA')));
}
}
diff --git a/src/Symfony/Component/Validator/Constraints/UrlValidator.php b/src/Symfony/Component/Validator/Constraints/UrlValidator.php
index e580e06b01..118a8defc1 100644
--- a/src/Symfony/Component/Validator/Constraints/UrlValidator.php
+++ b/src/Symfony/Component/Validator/Constraints/UrlValidator.php
@@ -74,7 +74,7 @@ class UrlValidator extends ConstraintValidator
if ($constraint->checkDNS) {
$host = parse_url($value, PHP_URL_HOST);
- if (!checkdnsrr($host, 'ANY')) {
+ if (!is_string($host) || !checkdnsrr($host, 'ANY')) {
$this->context->buildViolation($constraint->dnsMessage)
->setParameter('{{ value }}', $this->formatValue($host))
->setCode(Url::INVALID_URL_ERROR)
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php
index 30ec8f22a1..94857c1784 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php
@@ -229,4 +229,32 @@ class EmailValidatorTest extends ConstraintValidatorTestCase
$this->assertNoViolation();
}
+
+ /**
+ * @dataProvider provideCheckTypes
+ */
+ public function testEmptyHostIsNotValid($checkType, $violation)
+ {
+ $this->validator->validate(
+ 'foo@bar.fr@',
+ new Email(array(
+ 'message' => 'myMessage',
+ $checkType => true,
+ ))
+ );
+
+ $this
+ ->buildViolation('myMessage')
+ ->setParameter('{{ value }}', '"foo@bar.fr@"')
+ ->setCode($violation)
+ ->assertRaised();
+ }
+
+ public function provideCheckTypes()
+ {
+ return array(
+ array('checkMX', Email::MX_CHECK_FAILED_ERROR),
+ array('checkHost', Email::HOST_CHECK_FAILED_ERROR),
+ );
+ }
}
diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php
index c48d45a2e5..0459dd0220 100644
--- a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php
+++ b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php
@@ -167,6 +167,7 @@ class UrlValidatorTest extends ConstraintValidatorTestCase
array('http://example.com/exploit.html?'),
array('http://example.com/exploit.html?hel lo'),
array('http://example.com/exploit.html?not_a%hex'),
+ array('http://'),
);
}