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

MariaDB lead to invalid default values for attributes #57

Closed
samuelvogel opened this issue Nov 22, 2017 · 1 comment
Closed

MariaDB lead to invalid default values for attributes #57

samuelvogel opened this issue Nov 22, 2017 · 1 comment
Labels
bug Issues that describe an unexpected behaviour in an existing functionality.

Comments

@samuelvogel
Copy link
Member

samuelvogel commented Nov 22, 2017

When Shopware is run with MariaDB and the old articles attributes definition from before 5.3 is still present (s_articles_attributes) illegal attribute models are generated based on the column definition:

`attr17` date DEFAULT NULL

MariaDB is not officially supported but nevertheless "recommended" in the Shopware performance guide and also by some agencies.

The broken code is generated in /var/cache/production____REVISION___/doctrine/attributes/Article.php:

    /**
     * @var date $attr17
     *
     * @ORM\Column(name="attr17", type="date", nullable=true)
     */
    protected $attr17;

...

    public function __construct()
    {
        ...
        $this->attr15 = "NULL";
        $this->attr16 = "NULL";
        $this->attr17 = new \DateTime("NULL");
        $this->attr18 = "NULL";
        ...
    }

The following exception is thrown, for example when duplicating an article in the backend:
DateTime::__construct(): Failed to parse time string (NULL) at position 0 (N): The timezone could not be found in the database in var/cache/production____REVISION___/doctrine/attributes/Article.php on line 299

The attribute (s_articles_attributes.attr17) was normalized with Shopware 5.3, but this only applies for fresh installations not existing ones which are updated: https://github.com/shopware/shopware/blob/5325f6c831e4f6101ae1669494323475a38dce58/_sql/migrations/808-change-varchar-attributes.php#L32
And it's still possible to create problematic date attributes via the backend:
screenshot 2017-11-22 15 14 48

But the exception thrown for DATE columns is not the only problem, all attributes without a default value will be initialized with the string "NULL" (see attr15 above for example) with all MariaDB versions >= 10.2.7. The MariaDB handling of default values inINFORMATION_SCHEMA deviates from MySQL and the MariaDB devs decided that they do not want to change that anymore, but Doctrine is working on compatibility to both approaches. All of this discussion can be found here (including the linked issues): doctrine/orm#6565

Apparently doctrine/dbal 2.7.0 will resolve this, but even on the Shopware 5.4 branch version 2.5.4 is still shipped.

MySQL 5.7 was released 2015-10-21 and made most of the reasons for recommending MariaDB (better performance and easier configuration/more sensible defaults) obsolete.

@samuelvogel samuelvogel added the bug Issues that describe an unexpected behaviour in an existing functionality. label Nov 22, 2017
@samuelvogel
Copy link
Member Author

PR created: shopware/shopware#1396

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that describe an unexpected behaviour in an existing functionality.
Projects
None yet
Development

No branches or pull requests

1 participant