dgrigg / Craft-Migration-Manager

Deprecated - Migration Manager for Craft CMS
MIT License
39 stars 15 forks source link

Can't migrate accentuated classes - Class not found #49

Closed MichaelCaraccio closed 5 years ago

MichaelCaraccio commented 5 years ago

Some on my entries have accents, and when I created a migration the class of the migrated entry is accentuated too! The creation of the migration is successfull, but when I try to migrate it from production environnement, the following error occured :

Error:

Error
Class 'craft\contentmigrations\m190206_181015_migration_entry_théolaur' not found

    1. in /home/clients/3723fd0999eae3cde8e8969455853f77/web/beta/vendor/craftcms/cms/src/db/MigrationManager.php at line 119
    110111112113114115116117118119120121122123124125126127128

                            {
            if (!is_dir($this->migrationPath)) {
                throw new Exception("Can't instantiate migrations because the migration folder doesn't exist");
            }

            $file = $this->migrationPath . DIRECTORY_SEPARATOR . $name . '.php';
            $class = $this->migrationNamespace . '\\' . $name;
            require_once $file;

            return new $class;
        }

        /**
         * Upgrades the application by applying new migrations.
         *
         * @param int $limit The number of new migrations to be applied. If 0, it means
         * applying all available new migrations.
         * @throws MigrationException on migrate failure
         */

Migration Manager generated the following class :

<?php

namespace craft\contentmigrations;

use craft\db\Migration;
//use craft\db\MigrationManager;
//use craft\helpers\MigrationHelper;

use firstborn\migrationmanager\MigrationManager;

/**
 * Generated migration
 */
class m190206_181015_migration_entry_théolaur extends Migration
{
    /**
    Migration manifest:

    ENTRY
        - théolaur
            */

private $json = <<<JSON
{"content":{"entries":[{"slug":"théolaur","section":"clients","sites":{"default":{"slug":"théolaur","section":"clients","enabled":"1","site":"default","enabledForSite":"1","postDate":{"date":"2019-02-01 15:46:00.000000","timezone_type":3,"timezone":"Europe/Zurich"},"expiryDate":null,"title":"Théolaur","entryType":"clients","fields":{"clientImage":[{"elementType":"craft\\\\elements\\\\Asset","filename":"theolaur.png","folder":"clients","source":"images"}],"clientType":["couleur"]}},"french":{"slug":"théolaur","section":"clients","enabled":"1","site":"french","enabledForSite":"1","postDate":{"date":"2019-02-01 15:46:00.000000","timezone_type":3,"timezone":"Europe/Zurich"},"expiryDate":null,"title":"Théolaur","entryType":"clients","fields":{"clientImage":[{"elementType":"craft\\\\elements\\\\Asset","filename":"theolaur.png","folder":"clients","source":"images"}],"clientType":["couleur"]}},"german":{"slug":"théolaur","section":"clients","enabled":"1","site":"german","enabledForSite":"1","postDate":{"date":"2019-02-01 15:46:00.000000","timezone_type":3,"timezone":"Europe/Zurich"},"expiryDate":null,"title":"Théolaur","entryType":"clients","fields":{"clientImage":[{"elementType":"craft\\\\elements\\\\Asset","filename":"theolaur.png","folder":"clients","source":"images"}],"clientType":["couleur"]}}}}]}}
JSON;

    /**
     * Any migration code in here is wrapped inside of a transaction.
     * Returning false will rollback the migration
     *
     * @return bool
     */
    public function safeUp()
    {
        return MigrationManager::getInstance()->migrations->import($this->json);    }

    public function safeDown()
    {
        echo "m190206_181015_migration_entry_théolaur cannot be reverted.\n";
        return false;
    }
}

Solution

I fixed it by changing "m190206_181015_migration_entry_théolaur" class name with "m190206_181015_migration_entry_theolaur".

CraftCMS

PHP version | 7.2.14 Craft edition & version | Craft Solo 3.1.8 Database driver & version | MySQL 5.6.33 Migration Manager | 3.0.17

MichaelCaraccio commented 5 years ago

Sorry! To make it work I had to change the name of the class (without accents) but also the name of the file! Thanks

filip-van-hoeckel commented 5 years ago

We are currently facing the same issue and are testing this solution. Should this solve the issue, I'd mark this as a huge bug.

dgrigg commented 5 years ago

@MichaelCaraccio @filip-van-hoeckel working on a fix for this.

dgrigg commented 5 years ago

@MichaelCaraccio @filip-van-hoeckel fixed in latest release