Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release 2.8.2 into 2.9.x #8485

Merged
merged 40 commits into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
35cf481
Add docs to export-ignore
fezfez Nov 27, 2020
8724589
Housekeeping: Fix wrong typehint - Closes #8421
beberlei Feb 5, 2021
2693a93
fixed entity generation for numeric values (#8434)
julianullrich99 Feb 5, 2021
b06679c
Manually fix cs
greg0ire Feb 6, 2021
2d7acbd
Merge pull request #8457 from greg0ire/cs-20210206
greg0ire Feb 6, 2021
0f655f9
Manually fix cs
greg0ire Feb 7, 2021
792a9a9
Merge pull request #8464 from greg0ire/cs-20210207
greg0ire Feb 7, 2021
fb9b9b2
Manually fix cs
greg0ire Feb 8, 2021
8312ff0
Merge pull request #8353 from fezfez/patch-1
greg0ire Feb 8, 2021
4958180
Merge pull request #8468 from greg0ire/cs-20210208
greg0ire Feb 9, 2021
58c95a9
Manually fix cs
greg0ire Feb 9, 2021
6dbaa39
Merge pull request #8469 from greg0ire/cs-20210209
greg0ire Feb 10, 2021
41729be
Spell "first" properly
greg0ire Feb 11, 2021
61d0f96
Manually fix cs
greg0ire Feb 10, 2021
94e8b1d
Merge pull request #8470 from greg0ire/cs-20210211
greg0ire Feb 12, 2021
01374ca
Ignore rule about lone comment
greg0ire Feb 12, 2021
01ca442
Ignore error about no assignment
greg0ire Feb 12, 2021
4c8831f
Remove unused helper method
greg0ire Feb 12, 2021
f59a0c3
Manually fix cs
greg0ire Feb 12, 2021
9a67b6f
Merge pull request #8474 from greg0ire/cs-20210212
greg0ire Feb 12, 2021
7312dde
Manually fix cs
greg0ire Feb 12, 2021
5e4dae8
Merge pull request #8476 from greg0ire/cs-20210213
greg0ire Feb 13, 2021
b6fd4b5
Automatically fix cs
greg0ire Feb 13, 2021
15f08ed
Manually fix cs
greg0ire Feb 13, 2021
c7f39eb
Merge pull request #8477 from greg0ire/cs-20210214
greg0ire Feb 14, 2021
f833222
Cs fixes1 (#8475)
beberlei Feb 14, 2021
5e11afc
Housekeeping: CS fixes Doctrine\ORM\Mapping\MappingException
beberlei Feb 14, 2021
8f62bd3
Housekeeping: CS fixes Doctrine\ORM\ORMException
beberlei Feb 14, 2021
e45d212
Housekeeping: CS fixes Doctrine\ORM\Mapping\MappingException
beberlei Feb 14, 2021
4e0f683
Merge pull request #8478 from beberlei/CsFixes2
greg0ire Feb 14, 2021
c29370e
Automatically fix cs
greg0ire Feb 14, 2021
416f35d
Manually fix cs
greg0ire Feb 14, 2021
f31dbf8
Merge pull request #8479 from greg0ire/cs-20210215
greg0ire Feb 15, 2021
4aece04
Automatically fix cs
greg0ire Feb 15, 2021
d76cbd7
Manually fix cs
greg0ire Feb 16, 2021
4f864bc
Identifier type is not set when many2many relations are deleted (#8401)
yoshz Feb 16, 2021
3a9b8fd
Housekeeping: Fix cs
beberlei Feb 16, 2021
30a7c2a
[GH-8410] Fix memory leak in new toIterable and state bug. (#8467)
beberlei Feb 16, 2021
ebae57e
Merge pull request #8480 from greg0ire/cs-20210216
greg0ire Feb 16, 2021
49864a7
Merge remote-tracking branch 'origin/2.8.x' into 2.8.x-merge-up-into-…
greg0ire Feb 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/tests export-ignore
/tools export-ignore
/docs export-ignore
/.github export-ignore
.gitattributes export-ignore
.gitignore export-ignore
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/coding-standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ jobs:
- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"

- name: "Install git-phpcs"
run: "wget https://github.com/diff-sniffer/git/releases/download/0.3.2/git-phpcs.phar"
- name: "Install diff-sniffer"
run: "wget https://github.com/diff-sniffer/diff-sniffer/releases/download/0.5.1/diff-sniffer.phar"

- name: "Fetch head branch"
run: "git remote set-branches --add origin $GITHUB_BASE_REF && git fetch origin $GITHUB_BASE_REF"

- name: "Run git-phpcs"
run: "php git-phpcs.phar origin/$GITHUB_BASE_REF...$GITHUB_SHA --report=checkstyle | cs2pr"
- name: "Run diff-sniffer"
run: "php diff-sniffer.phar origin/$GITHUB_BASE_REF...$GITHUB_SHA --report=checkstyle | cs2pr"

- name: "Run phpcbf"
run: "vendor/bin/phpcbf"
Expand Down
32 changes: 20 additions & 12 deletions lib/Doctrine/ORM/AbstractQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use Doctrine\ORM\Internal\Hydration\IterableResult;
use Doctrine\ORM\Mapping\MappingException as ORMMappingException;
use Doctrine\ORM\Query\Parameter;
use Doctrine\ORM\Query\QueryException;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\Persistence\Mapping\MappingException;
use Traversable;
Expand Down Expand Up @@ -793,7 +794,7 @@ public function getResult($hydrationMode = self::HYDRATE_OBJECT)
*
* Alias for execute(null, HYDRATE_ARRAY).
*
* @return array
* @return array<int,mixed>
*/
public function getArrayResult()
{
Expand All @@ -805,7 +806,7 @@ public function getArrayResult()
*
* Alias for execute(null, HYDRATE_SCALAR).
*
* @return array
* @return array<int,mixed>
*/
public function getScalarResult()
{
Expand Down Expand Up @@ -935,7 +936,7 @@ public function hasHint($name)
/**
* Return the key value map of query hints that are currently set.
*
* @return array
* @return array<string,mixed>
*/
public function getHints()
{
Expand All @@ -948,8 +949,8 @@ public function getHints()
*
* @deprecated
*
* @param ArrayCollection|array|null $parameters The query parameters.
* @param string|int|null $hydrationMode The hydration mode to use.
* @param ArrayCollection|mixed[]|null $parameters The query parameters.
* @param string|int|null $hydrationMode The hydration mode to use.
*
* @return IterableResult
*/
Expand Down Expand Up @@ -1000,7 +1001,12 @@ public function toIterable(iterable $parameters = [], $hydrationMode = null): it
$this->setParameters($parameters);
}

$rsm = $this->getResultSetMapping();
$rsm = $this->getResultSetMapping();

if ($rsm->isMixed && count($rsm->scalarMappings) > 0) {
throw QueryException::iterateWithMixedResultNotAllowed();
}

$stmt = $this->_doExecute();

return $this->_em->newHydrator($this->_hydrationMode)->toIterable($stmt, $rsm, $this->_hints);
Expand Down Expand Up @@ -1028,8 +1034,8 @@ public function execute($parameters = null, $hydrationMode = null)
/**
* Execute query ignoring second level cache.
*
* @param ArrayCollection|array|null $parameters
* @param string|int|null $hydrationMode
* @param ArrayCollection|mixed[]|null $parameters
* @param string|int|null $hydrationMode
*
* @return mixed
*
Expand Down Expand Up @@ -1089,8 +1095,8 @@ private function executeIgnoreQueryCache($parameters = null, $hydrationMode = nu
/**
* Load from second level cache or executes the query and put into cache.
*
* @param ArrayCollection|array|null $parameters
* @param string|int|null $hydrationMode
* @param ArrayCollection|mixed[]|null $parameters
* @param string|int|null $hydrationMode
*
* @return mixed
*
Expand Down Expand Up @@ -1232,9 +1238,11 @@ protected function getHash()
$query = $this->getSQL();
$hints = $this->getHints();
$params = array_map(function (Parameter $parameter) {
$value = $parameter->getValue();

// Small optimization
// Does not invoke processParameterValue for scalar values
if (is_scalar($value = $parameter->getValue())) {
// Does not invoke processParameterValue for scalar value
if (is_scalar($value)) {
return $value;
}

Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/ORM/Cache/AssociationCacheEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AssociationCacheEntry implements CacheEntry
/**
* READ-ONLY: Public only for performance reasons, it should be considered immutable.
*
* @var array The entity identifier
* @var array<string, mixed> The entity identifier
*/
public $identifier;

Expand All @@ -40,8 +40,8 @@ class AssociationCacheEntry implements CacheEntry
public $class;

/**
* @param string $class The entity class.
* @param array $identifier The entity identifier.
* @param string $class The entity class.
* @param array<string, mixed> $identifier The entity identifier.
*/
public function __construct($class, array $identifier)
{
Expand All @@ -54,7 +54,7 @@ public function __construct($class, array $identifier)
*
* This method allow Doctrine\Common\Cache\PhpFileCache compatibility
*
* @param array $values array containing property values
* @param array<string, mixed> $values array containing property values
*
* @return AssociationCacheEntry
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Cache/CacheFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function buildCollectionHydrator(EntityManagerInterface $em, array $mappi
/**
* Build a cache region
*
* @param array $cache The cache configuration.
* @param array<string,mixed> $cache The cache configuration.
*
* @return Region The cache region.
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Cache/CollectionCacheEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(array $identifiers)
*
* This method allows for Doctrine\Common\Cache\PhpFileCache compatibility
*
* @param array $values array containing property values
* @param array<string, mixed> $values array containing property values
*
* @return CollectionCacheEntry
*/
Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/ORM/Cache/CollectionCacheKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CollectionCacheKey extends CacheKey
/**
* READ-ONLY: Public only for performance reasons, it should be considered immutable.
*
* @var array The owner entity identifier
* @var array<string, mixed> The owner entity identifier
*/
public $ownerIdentifier;

Expand All @@ -52,9 +52,9 @@ class CollectionCacheKey extends CacheKey
public $association;

/**
* @param string $entityClass The entity class.
* @param string $association The field name that represents the association.
* @param array $ownerIdentifier The identifier of the owning entity.
* @param string $entityClass The entity class.
* @param string $association The field name that represents the association.
* @param array<string, mixed> $ownerIdentifier The identifier of the owning entity.
*/
public function __construct($entityClass, $association, array $ownerIdentifier)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Cache/CollectionHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function buildCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key
* @param CollectionCacheEntry $entry The cached collection entry.
* @param PersistentCollection $collection The collection to load the cache into.
*
* @return array
* @return mixed[]
*/
public function loadCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key, CollectionCacheEntry $entry, PersistentCollection $collection);
}
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Cache/DefaultCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ private function buildCollectionCacheKey(ClassMetadata $metadata, $association,
* @param ClassMetadata $metadata The entity metadata.
* @param mixed $identifier The entity identifier.
*
* @return array
* @return array<string, mixed>
*/
private function toIdentifierArray(ClassMetadata $metadata, $identifier)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ public function loadCacheEntry(ClassMetadata $metadata, CollectionCacheKey $key,
$targetRegion = $targetPersister->getCacheRegion();
$list = [];

/** @var EntityCacheEntry[]|null $entityEntries */
$entityEntries = $targetRegion->getMultiple($entry);

if ($entityEntries === null) {
return null;
}

/** @var EntityCacheEntry[] $entityEntries */
foreach ($entityEntries as $index => $entityEntry) {
$list[$index] = $this->uow->createEntity($entityEntry->class, $entityEntry->resolveAssociationEntries($this->em), self::$hints);
}
Expand Down
13 changes: 8 additions & 5 deletions lib/Doctrine/ORM/Cache/DefaultQueryCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ public function get(QueryCacheKey $key, ResultSetMapping $rsm, array $hints = []
$assocMetadata = $this->em->getClassMetadata($assoc['targetEntity']);

if ($assoc['type'] & ClassMetadata::TO_ONE) {
if (($assocEntry = $assocRegion->get($assocKey = new EntityCacheKey($assocMetadata->rootEntityName, $assoc['identifier']))) === null) {
$assocKey = new EntityCacheKey($assocMetadata->rootEntityName, $assoc['identifier']);
$assocEntry = $assocRegion->get($assocKey);

if ($assocEntry === null) {
if ($this->cacheLogger !== null) {
$this->cacheLogger->entityCacheMiss($assocRegion->getName(), $assocKey);
}
Expand Down Expand Up @@ -398,7 +401,7 @@ private function storeAssociationCache(QueryCacheKey $key, array $assoc, $assocV
* @param string $assocAlias
* @param object $entity
*
* @return array|object
* @return array<object>|object
*/
private function getAssociationValue(ResultSetMapping $rsm, $assocAlias, $entity)
{
Expand All @@ -422,10 +425,10 @@ private function getAssociationValue(ResultSetMapping $rsm, $assocAlias, $entity
}

/**
* @param mixed $value
* @param array $path
* @param mixed $value
* @param array<mixed> $path
*
* @return array|object|null
* @return array<object>|object|null
*/
private function getAssociationPathValue($value, array $path)
{
Expand Down
10 changes: 5 additions & 5 deletions lib/Doctrine/ORM/Cache/EntityCacheEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class EntityCacheEntry implements CacheEntry
/**
* READ-ONLY: Public only for performance reasons, it should be considered immutable.
*
* @var array The entity map data
* @var array<string,mixed> The entity map data
*/
public $data;

Expand All @@ -44,8 +44,8 @@ class EntityCacheEntry implements CacheEntry
public $class;

/**
* @param string $class The entity class.
* @param array $data The entity data.
* @param string $class The entity class.
* @param array<string,mixed> $data The entity data.
*/
public function __construct($class, array $data)
{
Expand All @@ -58,7 +58,7 @@ public function __construct($class, array $data)
*
* This method allow Doctrine\Common\Cache\PhpFileCache compatibility
*
* @param array $values array containing property values
* @param array<string,mixed> $values array containing property values
*
* @return EntityCacheEntry
*/
Expand All @@ -70,7 +70,7 @@ public static function __set_state(array $values)
/**
* Retrieves the entity data resolving cache entries
*
* @return array
* @return array<string, mixed>
*/
public function resolveAssociationEntries(EntityManagerInterface $em)
{
Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/ORM/Cache/EntityCacheKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class EntityCacheKey extends CacheKey
/**
* READ-ONLY: Public only for performance reasons, it should be considered immutable.
*
* @var array The entity identifier
* @var array<string, mixed> The entity identifier
*/
public $identifier;

Expand All @@ -45,8 +45,8 @@ class EntityCacheKey extends CacheKey
public $entityClass;

/**
* @param string $entityClass The entity class name. In a inheritance hierarchy it should always be the root entity class.
* @param array $identifier The entity identifier
* @param string $entityClass The entity class name. In a inheritance hierarchy it should always be the root entity class.
* @param array<string, mixed> $identifier The entity identifier
*/
public function __construct($entityClass, array $identifier)
{
Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/ORM/Cache/Logging/StatisticsCacheLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,23 @@ public function getRegionPutCount($regionName)
}

/**
* @return array
* @return array<string, int>
*/
public function getRegionsMiss()
{
return $this->cacheMissCountMap;
}

/**
* @return array
* @return array<string, int>
*/
public function getRegionsHit()
{
return $this->cacheHitCountMap;
}

/**
* @return array
* @return array<string, int>
*/
public function getRegionsPut()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,27 +128,25 @@ public function getTargetEntityMetadata()
*/
public function loadCollectionCache(PersistentCollection $collection, CollectionCacheKey $key)
{
if (($cache = $this->region->get($key)) === null) {
return null;
}
$cache = $this->region->get($key);

if (($cache = $this->hydrator->loadCacheEntry($this->sourceEntity, $key, $cache, $collection)) === null) {
if ($cache === null) {
return null;
}

return $cache;
return $this->hydrator->loadCacheEntry($this->sourceEntity, $key, $cache, $collection);
}

/**
* {@inheritdoc}
*/
public function storeCollectionCache(CollectionCacheKey $key, $elements)
{
/** @var CachedEntityPersister $targetPersister */
$associationMapping = $this->sourceEntity->associationMappings[$key->association];
$targetPersister = $this->uow->getEntityPersister($this->targetEntity->rootEntityName);
$targetRegion = $targetPersister->getCacheRegion();
$targetHydrator = $targetPersister->getEntityHydrator();
assert($targetPersister instanceof CachedEntityPersister);
$targetRegion = $targetPersister->getCacheRegion();
$targetHydrator = $targetPersister->getEntityHydrator();

// Only preserve ordering if association configured it
if (! (isset($associationMapping['indexBy']) && $associationMapping['indexBy'])) {
Expand Down
Loading