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

Symfony 4: Doctrine ORM Mapping for PaymentToken not added in prod-Environment #489

Open
kije opened this issue Mar 18, 2019 · 1 comment

Comments

@kije
Copy link

kije commented Mar 18, 2019

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 <kim.jeker@suxesiv.ch>
 * @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
@virtualize
Copy link

virtualize commented Apr 12, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants