PayumBundle
PayumBundle copied to clipboard
Symfony 4: Doctrine ORM Mapping for PaymentToken not added in prod-Environment
When using PayumBundle in Symfony 4 (flex), the Doctrine ORM mapping information for the PaymentToken Entity are not loaded when APP_ENV=prod.
This leads to an exception when trying to override the definition of the hash-Column (via @attributeOverride) to make it comaptible with utf8mb4_unicode_ci encoding (see Issue #319 ).
More information below.
The cause of this problem seems to be if there is a additional config/packages/prod/doctrine.yaml (as created by the default Symfony 4 setup) file with some additional configuration for Doctrine in the Production-Environment. The issue seems to be in the prepend()-Method of the Payum\Bundle\PayumBundle\DependencyInjection\PayumExtension class (see https://github.com/Payum/PayumBundle/blob/master/DependencyInjection/PayumExtension.php#L81 )
If I delete the file config/packages/prod/doctrine.yaml or when APP_ENV=dev, everything works fine.
Further information
Error when running composer install
The Command composer install --no-dev outputs the following:
Loading composer repositories with package information
Installing dependencies from lock file
Nothing to install or update
Generating autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 1
!!
!! In MappingException.php line 139:
!!
!! Invalid field override named 'hash' for class 'App\Entity\PaymentToken'.
!!
!!
!!
Script @auto-scripts was called via post-install-cmd
.env
APP_ENV=prod
# ...
PaymentToken.php
<?php
/**
* PaymentToken.php
* @author: Kim D. Jeker <[email protected]>
* @since 15.03.2019
*/
declare(strict_types=1);
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Payum\Core\Model\Token;
/**
* @ORM\Table
* @ORM\Entity
* @ORM\AttributeOverrides({
* @ORM\AttributeOverride(name="hash",
* column=@ORM\Column(
* type = "string",
* length = 191,
* )
* )
* })
*/
class PaymentToken extends Token
{
}
config/packages/prod/doctrine.yaml
doctrine:
orm:
auto_generate_proxy_classes: false
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
Had the same issue, but found that the culprit, at least im my case, was the doctrine orm
auto_generate_proxy_classes: false setting in production mode.
Fixed it for now by setting auto_generate_proxy_classes: 2
see: AbstractProxyFactory.php