Skip to content

Commit

Permalink
Fixes after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermeblanco committed Dec 4, 2017
1 parent d2ac5cc commit e7d61c2
Show file tree
Hide file tree
Showing 49 changed files with 369 additions and 478 deletions.
2 changes: 1 addition & 1 deletion docs/en/cookbook/dql-custom-walkers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ implementation is:
{
$parent = null;
$parentName = null;
foreach ($this->_getQueryComponents() as $dqlAlias => $qComp) {
foreach ($this->getQueryComponents() as $dqlAlias => $qComp) {
if ($qComp['parent'] === null && $qComp['nestingLevel'] == 0) {
$parent = $qComp;
$parentName = $dqlAlias;
Expand Down
4 changes: 2 additions & 2 deletions docs/en/reference/batch-processing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@ problems using the following approach:
.. code-block:: php
<?php
$q = $this->_em->createQuery('select u from MyProject\Model\User u');
$q = $this->em->createQuery('select u from MyProject\Model\User u');
$iterableResult = $q->iterate();
foreach ($iterableResult as $row) {
// do stuff with the data in the row, $row[0] is always the object
// detach all entities from Doctrine, so that Garbage-Collection can kick in immediately
$this->_em->clear();
$this->em->clear();
}
.. note::
Expand Down
14 changes: 7 additions & 7 deletions docs/en/reference/change-tracking-policies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ follows:
{
// ...
private $_listeners = array();
private $listeners = array();
public function addPropertyChangedListener(PropertyChangedListener $listener)
{
$this->_listeners[] = $listener;
$this->listeners[] = $listener;
}
}
Expand All @@ -104,10 +104,10 @@ behaviour:
{
// ...
protected function _onPropertyChanged($propName, $oldValue, $newValue)
protected function onPropertyChanged($propName, $oldValue, $newValue)
{
if ($this->_listeners) {
foreach ($this->_listeners as $listener) {
if ($this->listeners) {
foreach ($this->listeners as $listener) {
$listener->propertyChanged($this, $propName, $oldValue, $newValue);
}
}
Expand All @@ -116,13 +116,13 @@ behaviour:
public function setData($data)
{
if ($data != $this->data) {
$this->_onPropertyChanged('data', $this->data, $data);
$this->onPropertyChanged('data', $this->data, $data);
$this->data = $data;
}
}
}
You have to invoke ``_onPropertyChanged`` inside every method that
You have to invoke ``onPropertyChanged`` inside every method that
changes the persistent state of ``MyEntity``.

The check whether the new value is different from the old one is
Expand Down
2 changes: 1 addition & 1 deletion docs/en/reference/dql-doctrine-query-language.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ creating a class which extends ``AbstractHydrator``:
{
protected function _hydrateAll()
{
return $this->_stmt->fetchAll(PDO::FETCH_ASSOC);
return $this->stmt->fetchAll(PDO::FETCH_ASSOC);
}
}
Expand Down
6 changes: 3 additions & 3 deletions docs/en/reference/metadata-drivers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,22 @@ the ``AbstractFileDriver`` implementation for you to extend from:
/**
* {@inheritdoc}
*/
protected $_fileExtension = '.dcm.ext';
protected $fileExtension = '.dcm.ext';
/**
* {@inheritdoc}
*/
public function loadMetadataForClass($className, ClassMetadata $metadata)
{
$data = $this->_loadMappingFile($file);
$data = $this->loadMappingFile($file);
// populate ClassMetadata instance from $data
}
/**
* {@inheritdoc}
*/
protected function _loadMappingFile($file)
protected function loadMappingFile($file)
{
// parse contents of $file and return php data structure
}
Expand Down
8 changes: 4 additions & 4 deletions docs/en/reference/native-sql.rst
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ entity.
$rsm->addFieldResult('u', 'id', 'id');
$rsm->addFieldResult('u', 'name', 'name');
$query = $this->_em->createNativeQuery('SELECT id, name FROM users WHERE name = ?', $rsm);
$query = $this->em->createNativeQuery('SELECT id, name FROM users WHERE name = ?', $rsm);
$query->setParameter(1, 'romanb');
$users = $query->getResult();
Expand Down Expand Up @@ -359,7 +359,7 @@ thus owns the foreign key.
$rsm->addFieldResult('u', 'name', 'name');
$rsm->addMetaResult('u', 'address_id', 'address_id');
$query = $this->_em->createNativeQuery('SELECT id, name, address_id FROM users WHERE name = ?', $rsm);
$query = $this->em->createNativeQuery('SELECT id, name, address_id FROM users WHERE name = ?', $rsm);
$query->setParameter(1, 'romanb');
$users = $query->getResult();
Expand Down Expand Up @@ -390,7 +390,7 @@ associations that are lazy.
$sql = 'SELECT u.id, u.name, a.id AS address_id, a.street, a.city FROM users u ' .
'INNER JOIN address a ON u.address_id = a.id WHERE u.name = ?';
$query = $this->_em->createNativeQuery($sql, $rsm);
$query = $this->em->createNativeQuery($sql, $rsm);
$query->setParameter(1, 'romanb');
$users = $query->getResult();
Expand Down Expand Up @@ -423,7 +423,7 @@ to map the hierarchy (both use a discriminator column).
$rsm->addMetaResult('u', 'discr', 'discr'); // discriminator column
$rsm->setDiscriminatorColumn('u', 'discr');
$query = $this->_em->createNativeQuery('SELECT id, name, discr FROM users WHERE name = ?', $rsm);
$query = $this->em->createNativeQuery('SELECT id, name, discr FROM users WHERE name = ?', $rsm);
$query->setParameter(1, 'romanb');
$users = $query->getResult();
Expand Down
6 changes: 3 additions & 3 deletions docs/en/reference/second-level-cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ Execute the ``UPDATE`` and invalidate ``all cache entries`` using ``Query::HINT_
<?php
// Execute and invalidate
$this->_em->createQuery("UPDATE Entity\Country u SET u.name = 'unknown' WHERE u.id = 1")
$this->em->createQuery("UPDATE Entity\Country u SET u.name = 'unknown' WHERE u.id = 1")
->setHint(Query::HINT_CACHE_EVICT, true)
->execute();
Expand All @@ -601,7 +601,7 @@ Execute the ``UPDATE`` and invalidate ``all cache entries`` using the cache API
<?php
// Execute
$this->_em->createQuery("UPDATE Entity\Country u SET u.name = 'unknown' WHERE u.id = 1")
$this->em->createQuery("UPDATE Entity\Country u SET u.name = 'unknown' WHERE u.id = 1")
->execute();
// Invoke Cache API
$em->getCache()->evictEntityRegion('Entity\Country');
Expand All @@ -613,7 +613,7 @@ Execute the ``UPDATE`` and invalidate ``a specific cache entry`` using the cache
<?php
// Execute
$this->_em->createQuery("UPDATE Entity\Country u SET u.name = 'unknown' WHERE u.id = 1")
$this->em->createQuery("UPDATE Entity\Country u SET u.name = 'unknown' WHERE u.id = 1")
->execute();
// Invoke Cache API
$em->getCache()->evictEntity('Entity\Country', 1);
Expand Down
2 changes: 1 addition & 1 deletion docs/en/reference/working-with-objects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ in a central location.
{
public function getAllAdminUsers()
{
return $this->_em->createQuery('SELECT u FROM MyDomain\Model\User u WHERE u.status = "admin"')
return $this->em->createQuery('SELECT u FROM MyDomain\Model\User u WHERE u.status = "admin"')
->getResult();
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/EntityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function transactional(callable $func)
$this->flush();
$this->conn->commit();

return $return ?: true;
return $return;
} catch (\Throwable $e) {
$this->close();
$this->conn->rollBack();
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function hydrateAll($stmt, $resultSetMapping, array $hints = [])
$this->rsm = $resultSetMapping;
$this->hints = $hints;

$this->_em->getEventManager()->addEventListener([Events::onClear], $this);
$this->em->getEventManager()->addEventListener([Events::onClear], $this);

$this->prepare();

Expand Down Expand Up @@ -379,7 +379,7 @@ protected function hydrateColumnInfo($key)

// the current discriminator value must be saved in order to disambiguate fields hydration,
// should there be field name collisions
if ($classMetadata->parentClasses && isset($this->rsm->discriminatorColumns[$ownerMap])) {
if ($classMetadata->getParent() && isset($this->rsm->discriminatorColumns[$ownerMap])) {
return $this->cache[$key] = \array_merge(
$columnInfo,
[
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Mapping/AbstractClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ protected function getParentClasses($name) : array
$parentClasses = [];

foreach (array_reverse($this->getReflectionService()->getParentClasses($name)) as $parentClass) {
if ( ! $this->getDriver()->isTransient($parentClass)) {
if (! $this->getDriver()->isTransient($parentClass)) {
$parentClasses[] = $parentClass;
}
}
Expand Down
12 changes: 7 additions & 5 deletions lib/Doctrine/ORM/ORMInvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,21 +252,23 @@ private static function objToStr($obj) : string
}

/**
* @param array $associationMapping
* @param object $entity
* @param AssociationMetadata $association
* @param object $entity
*
* @return string
*/
private static function newEntityFoundThroughRelationshipMessage(array $associationMapping, $entity) : string
private static function newEntityFoundThroughRelationshipMessage(AssociationMetadata $association, $entity) : string
{
return 'A new entity was found through the relationship \''
. $associationMapping['sourceEntity'] . '#' . $associationMapping['fieldName'] . '\' that was not'
. $association->getSourceEntity() . '#' . $association->getName() . '\' that was not'
. ' configured to cascade persist operations for entity: ' . self::objToStr($entity) . '.'
. ' To solve this issue: Either explicitly call EntityManager#persist()'
. ' on this unknown entity or configure cascade persist'
. ' this association in the mapping for example @ManyToOne(..,cascade={"persist"}).'
. (method_exists($entity, '__toString')
? ''
: ' If you cannot find out which entity causes the problem implement \''
. $associationMapping['targetEntity'] . '#__toString()\' to get a clue.'
. $association->getTargetEntity() . '#__toString()\' to get a clue.'
);
}
}
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -841,9 +841,9 @@ public function loadToOneEntity(ToOneAssociationMetadata $association, $sourceEn
// unset the old value and set the new sql aliased value here. By definition
// unset($identifier[$targetKeyColumn] works here with how UnitOfWork::createEntity() calls this method.
// @todo guilhermeblanco In master we have: $identifier[$targetClass->getFieldForColumn($targetKeyColumn)] =
$identifier[$targetTableAlias . "." . $targetKeyColumn] = $value;

unset($identifier[$targetKeyColumn]);

$identifier[$targetClass->fieldNames[$targetKeyColumn]] = $value;
}

$entity = $this->load($identifier, null, $association);
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Proxy/Factory/StaticProxyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private function transientFieldsFqns(ClassMetadata $metadata) : array
$property
->getDeclaringClass()
->getReflectionClass()
->getProperty($name) // @TODO possible NPR. This should never be null, why is it allowed to be?
->getProperty($name) // @TODO possible NPE. This should never be null, why is it allowed to be?
);
}

Expand All @@ -185,7 +185,7 @@ private function identifierFieldFqns(ClassMetadata $metadata) : array
->getProperty($idField)
->getDeclaringClass()
->getReflectionClass()
->getProperty($idField) // @TODO possible NPR. This should never be null, why is it allowed to be?
->getProperty($idField) // @TODO possible NPE. This should never be null, why is it allowed to be?
);
}

Expand Down
10 changes: 6 additions & 4 deletions lib/Doctrine/ORM/Query/SqlWalker.php
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ public function walkSelectClause($selectClause)
$discrColumn = $class->discriminatorColumn;
$discrColumnName = $discrColumn->getColumnName();
$discrColumnType = $discrColumn->getType();
$quotedColumnName = $this->platform->quoteIdentifier($discrColumn->getColumnName());
$quotedColumnName = $this->platform->quoteIdentifier($discrColumnName);
$sqlTableAlias = $this->getSQLTableAlias($discrColumn->getTableName(), $dqlAlias);
$sqlColumnAlias = $this->getSQLColumnAlias();

Expand Down Expand Up @@ -2134,7 +2134,7 @@ public function walkInstanceOfExpression($instanceOfExpr)
{
$dqlAlias = $instanceOfExpr->identificationVariable;
$class = $this->queryComponents[$dqlAlias]['metadata'];
$discrClass = $this->em->getClassMetadata($class->rootEntityName);
$discrClass = $this->em->getClassMetadata($class->getRootClassName());
$discrColumn = $class->discriminatorColumn;
$discrColumnType = $discrColumn->getType();
$quotedColumnName = $this->platform->quoteIdentifier($discrColumn->getColumnName());
Expand Down Expand Up @@ -2395,6 +2395,8 @@ private function getChildDiscriminatorsFromClassMetadata(ClassMetadata $rootClas

foreach ($instanceOfExpr->value as $parameter) {
if ($parameter instanceof AST\InputParameter) {
$this->rsm->discriminatorParameters[$parameter->name] = $parameter->name;

$sqlParameterList[] = $this->walkInputParameter($parameter);

continue;
Expand All @@ -2408,9 +2410,9 @@ private function getChildDiscriminatorsFromClassMetadata(ClassMetadata $rootClas
if (! $entityClass->getReflectionClass()->isSubclassOf($rootClass->getClassName())) {
throw QueryException::instanceOfUnrelatedClass($entityClassName, $rootClass->getClassName());
}

$discriminators += HierarchyDiscriminatorResolver::resolveDiscriminatorsForClass($entityClass, $this->em);
}

$discriminators += HierarchyDiscriminatorResolver::resolveDiscriminatorsForClass($entityClass, $this->em);
}

foreach (array_keys($discriminators) as $discriminator) {
Expand Down
18 changes: 8 additions & 10 deletions lib/Doctrine/ORM/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -967,11 +967,10 @@ public function join($join, $alias, $conditionType = null, $condition = null, $i
*/
public function innerJoin($join, $alias, $conditionType = null, $condition = null, $indexBy = null)
{
$parentAlias = substr($join, 0, strpos($join, '.'));

$rootAlias = $this->findRootAlias($alias, $parentAlias);

$join = new Expr\Join(
$hasParentAlias = strpos($join, '.');
$parentAlias = substr($join, 0, $hasParentAlias === false ? 0 : $hasParentAlias);
$rootAlias = $this->findRootAlias($alias, $parentAlias);
$join = new Expr\Join(
Expr\Join::INNER_JOIN, $join, $alias, $conditionType, $condition, $indexBy
);

Expand Down Expand Up @@ -1002,11 +1001,10 @@ public function innerJoin($join, $alias, $conditionType = null, $condition = nul
*/
public function leftJoin($join, $alias, $conditionType = null, $condition = null, $indexBy = null)
{
$parentAlias = substr($join, 0, strpos($join, '.'));

$rootAlias = $this->findRootAlias($alias, $parentAlias);

$join = new Expr\Join(
$hasParentAlias = strpos($join, '.');
$parentAlias = substr($join, 0, $hasParentAlias === false ? 0 : $hasParentAlias);
$rootAlias = $this->findRootAlias($alias, $parentAlias);
$join = new Expr\Join(
Expr\Join::LEFT_JOIN, $join, $alias, $conditionType, $condition, $indexBy
);

Expand Down
10 changes: 2 additions & 8 deletions lib/Doctrine/ORM/Tools/EntityGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ public function writeEntityClass(ClassMetadata $metadata, $outputDirectory)
} elseif ($this->updateEntityIfExists) {
file_put_contents($path, $this->generateUpdatedEntityClass($metadata, $path));
}

chmod($path, 0664);
}

Expand Down Expand Up @@ -1106,13 +1107,6 @@ protected function generateDiscriminatorColumnAnnotation(ClassMetadata $metadata

return '@' . $this->annotationsPrefix . 'DiscriminatorColumn(' . $columnDefinition . ')';
}

$discrColumn = $metadata->discriminatorColumn;
$columnDefinition = 'name="' . $discrColumn['name']
. '", type="' . $discrColumn['type']
. '", length=' . $discrColumn['length'];

return '@' . $this->annotationsPrefix . 'DiscriminatorColumn(' . $columnDefinition . ')';
}

/**
Expand Down Expand Up @@ -1731,7 +1725,7 @@ protected function generateEmbeddedPropertyDocBlock(array $embeddedClass)
return implode("\n", $lines);
}

private function generateEntityListenerAnnotation(ClassMetadataInfo $metadata): string
private function generateEntityListenerAnnotation(ClassMetadata $metadata): string
{
if (0 === \count($metadata->entityListeners)) {
return '';
Expand Down
Loading

0 comments on commit e7d61c2

Please sign in to comment.