Compare commits

..

7 Commits

Author SHA1 Message Date
Marco Pivetta c78afd5172 Preparing v2.5.10 release 2017-08-18 21:17:35 +02:00
Marco Pivetta fb7b78c004 Merge branch 'fix/#6633-#3788-avoid-xml-external-entity-loading-errors-in-xml-mapping-driver-2.5' into 2.5
Backport #6633
Backport #3788
2017-08-18 21:12:12 +02:00
Marco Pivetta 0de69e5a80 #6633 #3788 documenting why simplexml_load_file() was not used 2017-08-18 21:10:45 +02:00
Aljosha Papsch d7e1f883d8 XmlDriver: Avoid PHP bug #62577 by avoiding simplexml_load_file.
Doctrine is affected by PHP bug #62577. simplexml_load_file is not
able to load files if libxml_disable_entity_loader(true) has been
called. simplexml_load_file fails with the message:

I/O warning : failed to load external entity "/my/mappings/my_entity.dcm.xml"
in /path-to/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php on line 711

This error occurs even if there are no external entities in the XML file.

Waiting for the PHP bug to be resolved is infeasible, because it is
unresolved since years. Therefore Doctrine needs to circumvent the bug
by replacing simplexml_load_file with simplexml_load_string while getting
the file contents itself. simplexml_load_string is not affected by the
PHP bug.
2017-08-18 21:10:11 +02:00
Marco Pivetta 82e0d7e21a Removing ::class meta-constant for tests that need to run against my grandparents' PHP 2017-08-16 20:06:14 +02:00
Marco Pivetta 26880983fc Removing ::class meta-constant for tests that need to run against my grandparents' PHP 2017-08-16 19:24:39 +02:00
Marco Pivetta d9899732ca Bumping development release to v2.5.10DEV 2017-08-16 15:30:59 +02:00
3 changed files with 9 additions and 13 deletions
@@ -811,7 +811,8 @@ class XmlDriver extends FileDriver
protected function loadMappingFile($file)
{
$result = array();
$xmlElement = simplexml_load_file($file);
// Note: we do not use `simplexml_load_file()` because of https://bugs.php.net/bug.php?id=62577
$xmlElement = simplexml_load_string(file_get_contents($file));
if (isset($xmlElement->entity)) {
foreach ($xmlElement->entity as $entityElement) {
+1 -1
View File
@@ -36,7 +36,7 @@ class Version
/**
* Current Doctrine Version
*/
const VERSION = '2.5.9';
const VERSION = '2.5.10';
/**
* Compares a Doctrine version with the current one.
@@ -2,12 +2,7 @@
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\DBAL\Connection;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\ORM\Events;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\ORM\Internal\Hydration\AbstractHydrator;
use Doctrine\Tests\OrmFunctionalTestCase;
@@ -25,11 +20,11 @@ class AbstractHydratorTest extends OrmFunctionalTestCase
*/
public function testOnClearEventListenerIsDetachedOnCleanup()
{
$mockConnection = $this->createMock(Connection::class);
$mockEntityManagerInterface = $this->createMock(EntityManagerInterface::class);
$mockEventManager = $this->createMock(EventManager::class);
$mockStatement = $this->createMock(Statement::class);
$mockResultMapping = $this->getMockBuilder(ResultSetMapping::class);
$mockConnection = $this->createMock('Doctrine\DBAL\Connection');
$mockEntityManagerInterface = $this->createMock('Doctrine\ORM\EntityManagerInterface');
$mockEventManager = $this->createMock('Doctrine\Common\EventManager');
$mockStatement = $this->createMock('Doctrine\DBAL\Driver\Statement');
$mockResultMapping = $this->getMockBuilder('Doctrine\ORM\Query\ResultSetMapping');
$mockEntityManagerInterface->expects(self::any())->method('getEventManager')->willReturn($mockEventManager);
$mockEntityManagerInterface->expects(self::any())->method('getConnection')->willReturn($mockConnection);
@@ -37,7 +32,7 @@ class AbstractHydratorTest extends OrmFunctionalTestCase
/* @var $mockAbstractHydrator AbstractHydrator */
$mockAbstractHydrator = $this
->getMockBuilder(AbstractHydrator::class)
->getMockBuilder('Doctrine\ORM\Internal\Hydration\AbstractHydrator')
->setConstructorArgs([$mockEntityManagerInterface])
->setMethods(['hydrateAllData'])
->getMock();