Skip to content

Commit

Permalink
Merge pull request #1644 from dmaicher/revert_xsd_validation
Browse files Browse the repository at this point in the history
revert enabling XSD validation by default
  • Loading branch information
greg0ire authored Apr 14, 2023
2 parents efe215c + d4c7141 commit 7539b3c
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 44 deletions.
31 changes: 0 additions & 31 deletions DependencyInjection/DoctrineExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Id\AbstractIdGenerator;
use Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver;
use Doctrine\ORM\Proxy\Autoloader;
use Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand;
use Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand;
Expand Down Expand Up @@ -64,7 +63,6 @@
use function array_intersect_key;
use function array_keys;
use function class_exists;
use function count;
use function interface_exists;
use function is_dir;
use function method_exists;
Expand Down Expand Up @@ -785,7 +783,6 @@ protected function loadOrmEntityManagerMappingInformation(array $entityManager,

$this->loadMappingInformation($entityManager, $container);
$this->registerMappingDrivers($entityManager, $container);
$this->enableXmlMappingDriverXsdValidation($entityManager['name'], $container);

$ormConfigDef->addMethodCall('setEntityNamespaces', [$this->aliasMap]);
}
Expand Down Expand Up @@ -1132,32 +1129,4 @@ private function useMiddlewaresIfAvailable(
->addTag('doctrine.middleware', ['connection' => $connName]);
}
}

/**
* TODO: remove this once we dropped support for ORM < 3.0
*/
private function enableXmlMappingDriverXsdValidation(string $managerName, ContainerBuilder $container): void
{
$xmlDriverId = sprintf('doctrine.orm.%s_xml_metadata_driver', $managerName);

if (! $container->hasDefinition($xmlDriverId)) {
return;
}

$xmlDriverDef = $container->getDefinition($xmlDriverId);
$args = $xmlDriverDef->getArguments();
$numberOfArgs = count($args);
if ($numberOfArgs === 0 || $numberOfArgs === 3) {
return;
}

if ($numberOfArgs < 2) {
$args[] = SimplifiedXmlDriver::DEFAULT_FILE_EXTENSION;
}

// enable validation
$args[] = true;

$xmlDriverDef->setArguments($args);
}
}
4 changes: 0 additions & 4 deletions Tests/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ public function testContainer(): void
$this->assertInstanceOf(InfoCommand::class, $container->get('doctrine.mapping_info_command'));
$this->assertInstanceOf(UpdateCommand::class, $container->get('doctrine.schema_update_command'));

$xmlDriverDef = $container->getDefinition('doctrine.orm.default_xml_metadata_driver');
$this->assertCount(3, $xmlDriverDef->getArguments());
$this->assertTrue($xmlDriverDef->getArguments()[2]);

$this->assertTrue(Type::hasType('test'));

$this->assertFalse($container->has('doctrine.dbal.default_connection.events.mysqlsessioninit'));
Expand Down
5 changes: 0 additions & 5 deletions Tests/DependencyInjection/AbstractDoctrineExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Doctrine\DBAL\Schema\LegacySchemaManagerFactory;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver;
use Generator;
use InvalidArgumentException;
use PDO;
Expand Down Expand Up @@ -510,8 +509,6 @@ public function testSingleEntityManagerMultipleMappingBundleDefinitions(): void
$xmlDef = $container->getDefinition('doctrine.orm.default_xml_metadata_driver');
$this->assertDICConstructorArguments($xmlDef, [
[__DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'Bundles' . DIRECTORY_SEPARATOR . 'XmlBundle' . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'doctrine' => 'Fixtures\Bundles\XmlBundle'],
SimplifiedXmlDriver::DEFAULT_FILE_EXTENSION,
true,
]);
}

Expand Down Expand Up @@ -567,8 +564,6 @@ public function testMultipleEntityManagersMappingBundleDefinitions(): void
$xmlDef = $container->getDefinition('doctrine.orm.em2_xml_metadata_driver');
$this->assertDICConstructorArguments($xmlDef, [
[__DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'Bundles' . DIRECTORY_SEPARATOR . 'XmlBundle' . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'doctrine' => 'Fixtures\Bundles\XmlBundle'],
SimplifiedXmlDriver::DEFAULT_FILE_EXTENSION,
true,
]);
}

Expand Down
4 changes: 0 additions & 4 deletions UPGRADE-2.9.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ doctrine:
schema_manager_factory: doctrine.dbal.default_schema_manager_factory
```
### XSD Schema validation
Starting with `doctrine/orm` 2.14.2 the XML mapping driver will have XSD validation enabled.

### Deprecations
- the DBAL `platform_service` connection option is deprecated now. Use a driver middleware that would instantiate the platform instead.

0 comments on commit 7539b3c

Please sign in to comment.