Skip to content

Commit

Permalink
Merge branch '1.11.x'
Browse files Browse the repository at this point in the history
* 1.11.x:
  Skip generating link for backtrace record with missing file, fixes doctrine#967
  Wiring of the new PropertyAccessExtractor
  fix schema filtes on doctrine/dbal >= 2.9
  Fix service non existent error
  • Loading branch information
alcaeus committed May 14, 2019
2 parents 43e9087 + 09a3841 commit ae8f560
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
13 changes: 10 additions & 3 deletions DependencyInjection/DoctrineExtension.php
Expand Up @@ -25,6 +25,7 @@
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransportFactory;
use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface;
use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface;
use Symfony\Component\Validator\Mapping\Loader\LoaderInterface;
use function class_exists;
Expand Down Expand Up @@ -739,7 +740,7 @@ protected function loadCacheDriver($driverName, $entityManagerName, array $drive
break;

case 'pool':
$serviceId = $this->createPoolCacheDefinition($container, $aliasId, $driverMap['pool']);
$serviceId = $this->createPoolCacheDefinition($container, $driverMap['pool']);
break;

case 'provider':
Expand Down Expand Up @@ -794,6 +795,12 @@ private function loadPropertyInfoExtractor($entityManagerName, ContainerBuilder

$propertyExtractorDefinition->addTag('property_info.list_extractor', ['priority' => -1001]);
$propertyExtractorDefinition->addTag('property_info.type_extractor', ['priority' => -999]);

if (! is_a(DoctrineExtractor::class, PropertyAccessExtractorInterface::class, true)) {
return;
}

$propertyExtractorDefinition->addTag('property_info.access_extractor', ['priority' => -999]);
}

/**
Expand Down Expand Up @@ -862,15 +869,15 @@ private function loadMessengerServices(ContainerBuilder $container) : void
$transportFactoryDefinition->addTag('messenger.transport_factory');
}

private function createPoolCacheDefinition(ContainerBuilder $container, string $aliasId, string $poolName) : string
private function createPoolCacheDefinition(ContainerBuilder $container, string $poolName) : string
{
if (! class_exists(DoctrineProvider::class)) {
throw new LogicException('Using the "pool" cache type is only supported when symfony/cache is installed.');
}

$serviceId = sprintf('doctrine.orm.cache.pool.%s', $poolName);

$definition = $container->register($aliasId, DoctrineProvider::class);
$definition = $container->register($serviceId, DoctrineProvider::class);
$definition->addArgument(new Reference($poolName));
$definition->setPrivate(true);

Expand Down
2 changes: 2 additions & 0 deletions DoctrineBundle.php
Expand Up @@ -2,6 +2,7 @@

namespace Doctrine\Bundle\DoctrineBundle;

use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DbalSchemaFilterPass;
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\EntityListenerPass;
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\ServiceRepositoryCompilerPass;
use Doctrine\Common\Util\ClassUtils;
Expand Down Expand Up @@ -36,6 +37,7 @@ public function build(ContainerBuilder $container)
$container->addCompilerPass(new DoctrineValidationPass('orm'));
$container->addCompilerPass(new EntityListenerPass());
$container->addCompilerPass(new ServiceRepositoryCompilerPass());
$container->addCompilerPass(new DbalSchemaFilterPass());
}

/**
Expand Down
8 changes: 6 additions & 2 deletions Resources/views/Collector/db.html.twig
Expand Up @@ -289,10 +289,14 @@
<td>
<span class="text-small">
{% set line_number = trace.line|default(1) %}
<a href="{{ trace.file|file_link(line_number) }}">
{% if trace.file is defined %}
<a href="{{ trace.file|file_link(line_number) }}">
{% endif %}
{{- trace.class|default ~ (trace.class is defined ? trace.type|default('::')) -}}
<span class="status-warning">{{ trace.function }}</span>
</a>
{% if trace.file is defined %}
</a>
{% endif %}
(line {{ line_number }})
</span>
</td>
Expand Down
5 changes: 5 additions & 0 deletions Tests/BundleTest.php
Expand Up @@ -2,6 +2,7 @@

namespace Doctrine\Bundle\DoctrineBundle\Tests;

use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DbalSchemaFilterPass;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\DoctrineValidationPass;
Expand All @@ -21,16 +22,20 @@ public function testBuildCompilerPasses()

$foundEventListener = false;
$foundValidation = false;
$foundSchemaFilter = false;

foreach ($passes as $pass) {
if ($pass instanceof RegisterEventListenersAndSubscribersPass) {
$foundEventListener = true;
} elseif ($pass instanceof DoctrineValidationPass) {
$foundValidation = true;
} elseif ($pass instanceof DbalSchemaFilterPass) {
$foundSchemaFilter = true;
}
}

$this->assertTrue($foundEventListener, 'RegisterEventListenersAndSubscribersPass was not found');
$this->assertTrue($foundValidation, 'DoctrineValidationPass was not found');
$this->assertTrue($foundSchemaFilter, 'DbalSchemaFilterPass was not found');
}
}

0 comments on commit ae8f560

Please sign in to comment.