Skip to content

Commit

Permalink
Merge pull request #1829 from simPod/fetch_mode_subselect_batch_size
Browse files Browse the repository at this point in the history
  • Loading branch information
ostrolucky authored Oct 16, 2024
2 parents ca59d84 + 61c432a commit 50064cb
Show file tree
Hide file tree
Showing 23 changed files with 92 additions and 13 deletions.
12 changes: 9 additions & 3 deletions .doctrine-project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@
"slug": "doctrine-bundle",
"versions": [
{
"name": "2.13",
"branchName": "2.13.x",
"name": "2.14",
"branchName": "2.14.x",
"slug": "latest",
"upcoming": true
},
{
"name": "2.13",
"branchName": "2.13.x",
"slug": "2.13",
"current": true
},
{
"name": "2.12",
"branchName": "2.12.x",
"slug": "2.12",
"current": true
"maintained": false
},
{
"name": "2.11",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ on:
jobs:
coding-standards:
name: "Coding Standards"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@5.0.1"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@5.1.0"
with:
composer-options: "--prefer-dist --prefer-stable"
2 changes: 1 addition & 1 deletion .github/workflows/composer-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ on:
jobs:
composer-lint:
name: "Composer Lint"
uses: "doctrine/.github/.github/workflows/composer-lint.yml@5.0.1"
uses: "doctrine/.github/.github/workflows/composer-lint.yml@5.1.0"
4 changes: 2 additions & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
jobs:
phpunit:
name: "PHPUnit"
runs-on: "ubuntu-22.04"
runs-on: "ubuntu-latest"
env:
SYMFONY_REQUIRE: ${{matrix.symfony-require}}
SYMFONY_DEPRECATIONS_HELPER: weak
Expand Down Expand Up @@ -110,7 +110,7 @@ jobs:

upload_coverage:
name: "Upload coverage to Codecov"
runs-on: "ubuntu-22.04"
runs-on: "ubuntu-latest"
needs:
- "phpunit"

Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Documentation"

on:
pull_request:
branches:
- "*.x"
paths:
- ".github/workflows/documentation.yml"
- "docs/**"
push:
branches:
- "*.x"
paths:
- ".github/workflows/documentation.yml"
- "docs/**"

jobs:
documentation:
name: "Documentation"
uses: "doctrine/.github/.github/workflows/[email protected]"
2 changes: 1 addition & 1 deletion .github/workflows/release-on-milestone-closed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
release:
name: "Git tag, release & create merge-up PR"
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@5.0.1"
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@5.1.0"
secrets:
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
jobs:
static-analysis-psalm:
name: "Static Analysis with Psalm"
runs-on: "ubuntu-22.04"
runs-on: "ubuntu-latest"

steps:
- name: "Checkout code"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-dev-stability.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
phpunit:
name: "PHPUnit"
runs-on: "ubuntu-22.04"
runs-on: "ubuntu-latest"
env:
SYMFONY_REQUIRE: ${{matrix.symfony-require}}

Expand Down
2 changes: 1 addition & 1 deletion .symfony.bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ branches:
maintained_branches:
- "2.12.x"
- "2.13.x"
doc_dir: "docs/"
doc_dir: { "2.12.x": "docs/", "2.13.x": "docs/en/" }
current_branch: "2.12.x"
dev_branch: "2.13.x"
1 change: 1 addition & 0 deletions config/schema/doctrine-1.0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
<xsd:attribute name="connection" type="xsd:string" />
<xsd:attribute name="default-repository-class" type="xsd:string" />
<xsd:attribute name="class-metadata-factory-name" type="xsd:string" />
<xsd:attribute name="fetch-mode-subselect-batch-size" type="xsd:int" />
<xsd:attribute name="naming-strategy" type="xsd:string" />
<xsd:attribute name="quote-strategy" type="xsd:string" />
<xsd:attribute name="typed-field-mapper" type="xsd:string" />
Expand Down
1 change: 1 addition & 0 deletions docs/configuration.rst → docs/en/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ Configuration Reference
- Acme\AppBundle\Entity\Order
- Acme\AppBundle\Entity\PhoneNumber
fetch_mode_subselect_batch_size: 2000
# Search for the "ResolveTargetEntityListener" class for a cookbook about this
resolve_target_entities:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ private function getOrmEntityManagersNode(): ArrayNodeDefinition
->scalarNode('quote_strategy')->defaultValue('doctrine.orm.quote_strategy.default')->end()
->scalarNode('typed_field_mapper')->defaultValue('doctrine.orm.typed_field_mapper.default')->end()
->scalarNode('entity_listener_resolver')->defaultNull()->end()
->scalarNode('fetch_mode_subselect_batch_size')->end()
->scalarNode('repository_factory')->defaultValue('doctrine.orm.container_repository_factory')->end()
->arrayNode('schema_ignore_classes')
->prototype('scalar')->end()
Expand Down
4 changes: 4 additions & 0 deletions src/DependencyInjection/DoctrineExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,10 @@ protected function loadOrmEntityManager(array $entityManager, ContainerBuilder $
'setIdentityGenerationPreferences' => $entityManager['identity_generation_preferences'],
];

if (isset($entityManager['fetch_mode_subselect_batch_size'])) {
$methods['setEagerFetchBatchSize'] = $entityManager['fetch_mode_subselect_batch_size'];
}

if (! method_exists(OrmConfiguration::class, 'setLazyGhostObjectEnabled')) {
unset($methods['setLazyGhostObjectEnabled']);
}
Expand Down
15 changes: 13 additions & 2 deletions src/Twig/DoctrineExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
use Doctrine\SqlFormatter\NullHighlighter;
use Doctrine\SqlFormatter\SqlFormatter;
use Symfony\Component\VarDumper\Cloner\Data;
use Twig\DeprecatedCallableInfo;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;

use function addslashes;
use function array_key_exists;
use function array_merge;
use function bin2hex;
use function class_exists;
use function implode;
use function is_array;
use function is_bool;
Expand Down Expand Up @@ -41,12 +44,20 @@ class DoctrineExtension extends AbstractExtension
*/
public function getFilters()
{
return [
new TwigFilter('doctrine_pretty_query', [$this, 'formatQuery'], ['is_safe' => ['html'], 'deprecated' => true]),
$out = [
new TwigFilter('doctrine_prettify_sql', [$this, 'prettifySql'], ['is_safe' => ['html']]),
new TwigFilter('doctrine_format_sql', [$this, 'formatSql'], ['is_safe' => ['html']]),
new TwigFilter('doctrine_replace_query_parameters', [$this, 'replaceQueryParameters']),
];
$options = ['deprecated' => true];
// exists since twig/twig 3.15
if (class_exists(DeprecatedCallableInfo::class)) {
$options = ['deprecation_info' => new DeprecatedCallableInfo('doctrine/doctrine-bundle', '2.1')];
}

return array_merge($out, [
new TwigFilter('doctrine_pretty_query', [$this, 'formatQuery'], ['is_safe' => ['html']] + $options),
]);
}

/**
Expand Down
13 changes: 13 additions & 0 deletions tests/DependencyInjection/AbstractDoctrineExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,19 @@ public function testSchemaIgnoreClasses(): void
$this->assertDICDefinitionMethodCallOnce($def1, 'setSchemaIgnoreClasses', [0 => ['Class\A', 'Class\B']]);
}

public function testFetchModeSubselectBatchSize(): void
{
if (! interface_exists(EntityManagerInterface::class)) {
self::markTestSkipped('This test requires ORM');
}

$container = $this->loadContainer('orm_fetch_mode_subselect_batch_size');

$def1 = $container->getDefinition('doctrine.orm.default_configuration');

$this->assertDICDefinitionMethodCallOnce($def1, 'setEagerFetchBatchSize', [10000]);
}

public function testAttachEntityListeners(): void
{
if (! interface_exists(EntityManagerInterface::class)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" ?>

<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:srv="http://symfony.com/schema/dic/services"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">

<config>
<dbal default-connection="default">
</dbal>

<orm fetch-mode-subselect-batch-size="10000">
</orm>
</config>
</srv:container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
doctrine:
dbal:
default_connection: default

orm:
fetch_mode_subselect_batch_size: 10000

0 comments on commit 50064cb

Please sign in to comment.