Skip to content

Commit

Permalink
Merge branch '1.11.x'
Browse files Browse the repository at this point in the history
* 1.11.x:
  Fix BC break with DoctrineType::reset()
  Fix usage of wrong option in previously delegated commands
  Skip generating link for backtrace record with missing file, fixes #967
  Wiring of the new PropertyAccessExtractor
  fix schema filtes on doctrine/dbal >= 2.9
  Fix service non existent error
  • Loading branch information
alcaeus committed Jun 4, 2019
2 parents eb068c2 + 28101e2 commit 958ec5b
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Command/Proxy/CollectionRegionDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output)
{
DoctrineCommandHelper::setApplicationConnection($this->getApplication(), $input->getOption('connection'));
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));

return parent::execute($input, $output);
}
Expand Down
2 changes: 1 addition & 1 deletion Command/Proxy/EntityRegionCacheDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output)
{
DoctrineCommandHelper::setApplicationConnection($this->getApplication(), $input->getOption('connection'));
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));

return parent::execute($input, $output);
}
Expand Down
2 changes: 1 addition & 1 deletion Command/Proxy/QueryRegionCacheDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output)
{
DoctrineCommandHelper::setApplicationConnection($this->getApplication(), $input->getOption('connection'));
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));

return parent::execute($input, $output);
}
Expand Down
18 changes: 15 additions & 3 deletions DependencyInjection/DoctrineExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Form\AbstractType;
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 @@ -342,6 +344,10 @@ protected function ormLoad(array $config, ContainerBuilder $container)
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('orm.xml');

if (class_exists(AbstractType::class)) {
$container->getDefinition('form.type.entity')->addTag('kernel.reset', ['method' => 'reset']);
}

$entityManagers = [];
foreach (array_keys($config['entity_managers']) as $name) {
$entityManagers[$name] = sprintf('doctrine.orm.%s_entity_manager', $name);
Expand Down Expand Up @@ -739,7 +745,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 +800,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 +874,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 958ec5b

Please sign in to comment.