8000 [DI] the reproducer for bug #29246 by nicolas-grekas · Pull Request #29252 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DI] the reproducer for bug #29246 #29252

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions reproducer-29246/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=6055ddd43cc57a932559ce2520118d8f
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
#TRUSTED_HOSTS=localhost,example.com
###< symfony/framework-bundle ###

###> doctrine/doctrine-bundle ###
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# Configure your db driver and server_version in config/packages/doctrine.yaml
DATABASE_URL=sqlite:///%kernel.project_dir%/var/data.db
###< doctrine/doctrine-bundle ###
7 changes: 7 additions & 0 deletions reproducer-29246/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
###> symfony/framework-bundle ###
/.env.local
/.env.*.local
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###
34 changes: 34 additions & 0 deletions reproducer-29246/.lando.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: sf
recipe: lemp

config:
php: 7.2
webroot: public
database: mariadb

tooling:
php:
service: appserver
description: Run PHP commands
cmd:
- php
composer:
service: appserver
description: Run Composer commands
cmd:
- composer
bash:
service: appserver
description: Run bash commands
cmd:
- bash
- -xc
sf:
service: appserver
description: Run Symfony commands
cmd:
- bin/console

events:
post-start:
appserver: "composer install --working-dir=$LANDO_MOUNT"
40 changes: 40 additions & 0 deletions reproducer-29246/bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env php
<?php

use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;

set_time_limit(0);

require dirname(__DIR__).'/vendor/autoload.php';

if (!class_exists(Application::class)) {
throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
}

$input = new ArgvInput();
if (null !== $_ENV['APP_ENV'] = $input->getParameterOption(['--env', '-e'], null, true)) {
putenv('APP_ENV='.$_ENV['APP_ENV']);
// force loading .env files when --env is defined
$_SERVER['APP_ENV'] = null;
}

if ($input->hasParameterOption('--no-debug', true)) {
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
}

require dirname(__DIR__).'/src/.bootstrap.php';

if ($_SERVER['APP_DEBUG']) {
umask(0000);

if (class_exists(Debug::class)) {
Debug::enable();
}
}

$kernel = new Kernel($_SERVER['APP_ENV'], $_SERVER['APP_DEBUG']);
$application = new Application($kernel);
$application->run($input);
56 changes: 56 additions & 0 deletions reproducer-29246/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"prefer-stable": true,
"minimum-stability": "dev",
"require": {
"msgphp/user-bundle": "0.7.*",
"symfony/console": "dev-master",
"symfony/flex": "^1.1",
"symfony/framework-bundle": "dev-master",
"symfony/orm-pack": "^1.0",
"symfony/yaml": "dev-master"
},
"require-dev": {
"symfony/dotenv": "dev-master"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"replace": {
"paragonie/random_compat": "2.*",
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php71": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php56": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"id": "",
"allow-contrib": true,
"require": "4.2.*"
}
}
}
9 changes: 9 additions & 0 deletions reproducer-29246/config/bundles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
MsgPhp\UserBundle\MsgPhpUserBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
];
17 changes: 17 additions & 0 deletions reproducer-29246/config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci

orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
mappings:
app:
dir: '%kernel.project_dir%/src/Entity'
type: annotation
prefix: App\Entity
alias: App
32 changes: 32 additions & 0 deletions reproducer-29246/config/packages/framework.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
framework:
secret: '%env(APP_SECRET)%'
#default_locale: en
#csrf_protection: true
#http_method_override: true

# Enables session support. Note that the session will ONLY be started if you read or write from it.
# Remove or comment this section to explicitly disable session support.
session:
handler_id: ~
cookie_secure: auto
cookie_samesite: lax

#esi: true
#fragments: true
php_errors:
log: true

cache:
# Put the unique name of your app here: the prefix seed
# is used to compute stable namespaces for cache keys.
#prefix_seed: your_vendor_name/app_name

# The app cache caches to the filesystem by default.
# Other options include:

# Redis
#app: cache.adapter.redis
#default_redis_provider: redis://localhost

# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
#app: cache.adapter.apcu
22 changes: 22 additions & 0 deletions reproducer-29246/config/packages/msgphp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

use MsgPhp\{Eav, User};
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return function (ContainerConfigurator $container) {
$container->extension('msgphp_user', [
'class_mapping' => [
User\Entity\User::class => \App\Entity\User\User::class,
User\Entity\UserEmail::class => \App\Entity\User\UserEmail::class,
User\Entity\Username::class => \App\Entity\User\Username::class,
],
'username_lookup' => [
['target' => User\Entity\UserEmail::class, 'field' => 'email', 'mapped_by' => 'user'],
],
]);

$container->parameters()
->set('msgphp.doctrine.mapping_config', [
'key_max_length' => 191,
]);
};
31 changes: 31 additions & 0 deletions reproducer-29246/config/packages/prod/doctrine.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
doctrine:
orm:
metadata_cache_driver:
type: service
id: doctrine.system_cache_provider
query_cache_driver:
type: service
id: doctrine.system_cache_provider
result_cache_driver:
type: service
id: doctrine.result_cache_provider

services:
doctrine.result_cache_provider:
class: Symfony\Component\Cache\DoctrineProvider
public: false
arguments:
- '@doctrine.result_cache_pool'
doctrine.system_cache_provider:
class: Symfony\Component\Cache\DoctrineProvider
public: false
arguments:
- '@doctrine.system_cache_pool'

framework:
cache:
pools:
doctrine.result_cache_pool:
adapter: cache.app
doctrine.system_cache_pool:
adapter: cache.system
4 changes: 4 additions & 0 deletions reproducer-29246/config/packages/test/framework.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
framework:
test: true
session:
storage_id: session.storage.mock_file
8 changes: 8 additions & 0 deletions reproducer-29246/config/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
parameters:
locale: 'en'

services:
_defaults:
autowire: true
autoconfigure: true
public: false
27 changes: 27 additions & 0 deletions reproducer-29246/public/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

use App\Kernel;
use Symfony\Component\Debug\Debug;
use Symfony\Component\HttpFoundation\Request;

require dirname(__DIR__).'/src/.bootstrap.php';

if ($_SERVER['APP_DEBUG']) {
umask(0000);

Debug::enable();
}

if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
}

if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
Request::setTrustedHosts(explode(',', $trustedHosts));
}

$kernel = new Kernel($_SERVER['APP_ENV'], $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
21 changes: 21 additions & 0 deletions reproducer-29246/src/.bootstrap.php
A851
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

use Symfony\Component\Dotenv\Dotenv;

require dirname(__DIR__).'/vendor/autoload.php';

if (!array_key_exists('APP_ENV', $_SERVER)) {
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] ?? null;
}

if ('prod' !== $_SERVER['APP_ENV']) {
if (!class_exists(Dotenv::class)) {
throw new RuntimeException('The "APP_ENV" environment variable is not set to "prod". Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
}

(new Dotenv())->loadEnv(dirname(__DIR__).'/.env');
}

$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $_SERVER['APP_ENV'] ?: $_ENV['APP_ENV'] ?: 'dev';
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
34 changes: 34 additions & 0 deletions reproducer-29246/src/Entity/User/User.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace App\Entity\User;

use Doctrine\ORM\Mapping as ORM;
use MsgPhp\Domain\Event\DomainEventHandlerInterface;
use MsgPhp\Domain\Event\DomainEventHandlerTrait;
use MsgPhp\User\Entity\Credential\EmailPassword;
use MsgPhp\User\Entity\Features\EmailPasswordCredential;
use MsgPhp\User\Entity\User as BaseUser;
use MsgPhp\User\UserIdInterface;

/**
* @ORM\Entity()
*/
class User extends BaseUser implements DomainEventHandlerInterface
{
use EmailPasswordCredential;
use DomainEventHandlerTrait;

/** @ORM\Id() @ORM\Column(type="msgphp_user_id", length=191) */
private $id;

public function __construct(UserIdInterface $id, string $email, string $password)
{
$this->id = $id;
$this->credential = new EmailPassword($email, $password);
}

public function getId(): UserIdInterface
{
return $this->id;
}
}
Loading
0