ClassMetadataInfo: use reflection for creating new instance (on PHP >=5.4) #588

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
5 participants
Contributor

Majkl578 commented Feb 23, 2013

On PHP >=5.4, use proper way for instantiating classes without invoking constructor.

I think no test is necessary, since travis runs them on different PHP versions.

Hello,

thank you for positing this Pull Request. I have automatically opened an issue on our Jira Bug Tracker for you with the details of this Pull-Request. See the Link:

http://doctrine-project.org/jira/browse/DDC-2316

@Ocramius Ocramius commented on the diff Feb 23, 2013

lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
@@ -862,7 +862,12 @@ public function __sleep()
public function newInstance()
{
if ($this->_prototype === null) {
- $this->_prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
+ if (PHP_VERSION_ID >= 50400) {
+ $refl = $this->reflClass ?: new ReflectionClass($this->name);
@Ocramius

Ocramius Feb 23, 2013

Owner

I don't think this is needed. This code should be invoked anyway after calling wakeupReflection.

Owner

beberlei commented May 4, 2013

Scheduled this for Doctrine 3.0, so we don't need the if condition when we raise requirrements to PHP 5.4 or higher.

Owner

guilhermeblanco commented Jul 6, 2014

We faced a weird issue lately and this support got somehow partially introduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment