craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.28k stars 635 forks source link

[3.1] Project.yaml import fails if SuperTable fields are present. #3558

Closed lukeyouell closed 5 years ago

lukeyouell commented 5 years ago

Description

When using a project.yaml file generated by an existing site on a fresh installation, the contents of the .yaml file aren't being transferred - sections, fields, globals etc don't then exist in the CP.

I'm not seeing any errors that would suggest an issue with the config file.

EDIT:

I've worked out that the issue with transferring my existing site's scaffolding (original issue) is down to custom fields such as super table, not being compatible with 3.1 yet. No error was thrown, I presume it failed because of the super table field and just stopped.

Additional info

lukeyouell commented 5 years ago

I've just attempted this with a fresh installation, a handful of fields and plugins and the transferring of the config file breaks the site.

An Error occurred while handling another error:
craft\errors\SiteNotFoundException: No primary site exists in /Users/foobar/Sites/craft-2/vendor/craftcms/cms/src/services/Sites.php:521
Stack trace:
#0 /Users/foobar/Sites/craft-2/vendor/craftcms/cms/src/web/Request.php(1133): craft\services\Sites->getPrimarySite()
#1 /Users/foobar/Sites/craft-2/vendor/craftcms/cms/src/web/Request.php(172): craft\web\Request->_requestedSite(Object(craft\services\Sites))
#2 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/base/BaseObject.php(109): craft\web\Request->init()
#3 [internal function]: yii\base\BaseObject->__construct(Array)
#4 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/di/Container.php(383): ReflectionClass->newInstanceArgs(Array)
#5 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/di/Container.php(156): yii\di\Container->build('craft\\web\\Reque...', Array, Array)
#6 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/BaseYii.php(349): yii\di\Container->get('craft\\web\\Reque...', Array, Array)
#7 /Users/foobar/Sites/craft-2/vendor/craftcms/cms/src/config/app.web.php(13): yii\BaseYii::createObject(Array)
#8 [internal function]: {closure}()
#9 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/di/Container.php(503): call_user_func_array(Object(Closure), Array)
#10 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/BaseYii.php(351): yii\di\Container->invoke(Object(Closure), Array)
#11 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/di/ServiceLocator.php(137): yii\BaseYii::createObject(Object(Closure))
#12 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/base/Module.php(742): yii\di\ServiceLocator->get('request', true)
#13 /Users/foobar/Sites/craft-2/vendor/craftcms/cms/src/web/Application.php(345): yii\base\Module->get('request', true)
#14 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/di/ServiceLocator.php(74): craft\web\Application->get('request')
#15 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/web/ErrorHandler.php(499): yii\di\ServiceLocator->__get('request')
#16 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/web/ErrorHandler.php(115): yii\web\ErrorHandler->shouldRenderSimpleHtml()
#17 /Users/foobar/Sites/craft-2/vendor/craftcms/cms/src/web/ErrorHandler.php(132): yii\web\ErrorHandler->renderException(Object(craft\errors\SiteNotFoundException))
#18 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/base/ErrorHandler.php(111): craft\web\ErrorHandler->renderException(Object(craft\errors\SiteNotFoundException))
#19 /Users/foobar/Sites/craft-2/vendor/craftcms/cms/src/web/ErrorHandler.php(63): yii\base\ErrorHandler->handleException(Object(craft\errors\SiteNotFoundException))
#20 [internal function]: craft\web\ErrorHandler->handleException(Object(craft\errors\SiteNotFoundException))
#21 {main}
Previous exception:
craft\errors\SiteNotFoundException: No primary site exists in /Users/foobar/Sites/craft-2/vendor/craftcms/cms/src/services/Sites.php:521
Stack trace:
#0 /Users/foobar/Sites/craft-2/vendor/craftcms/cms/src/web/Request.php(1133): craft\services\Sites->getPrimarySite()
#1 /Users/foobar/Sites/craft-2/vendor/craftcms/cms/src/web/Request.php(172): craft\web\Request->_requestedSite(Object(craft\services\Sites))
#2 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/base/BaseObject.php(109): craft\web\Request->init()
#3 [internal function]: yii\base\BaseObject->__construct(Array)
#4 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/di/Container.php(383): ReflectionClass->newInstanceArgs(Array)
#5 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/di/Container.php(156): yii\di\Container->build('craft\\web\\Reque...', Array, Array)
#6 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/BaseYii.php(349): yii\di\Container->get('craft\\web\\Reque...', Array, Array)
#7 /Users/foobar/Sites/craft-2/vendor/craftcms/cms/src/config/app.web.php(13): yii\BaseYii::createObject(Array)
#8 [internal function]: {closure}()
#9 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/di/Container.php(503): call_user_func_array(Object(Closure), Array)
#10 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/BaseYii.php(351): yii\di\Container->invoke(Object(Closure), Array)
#11 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/di/ServiceLocator.php(137): yii\BaseYii::createObject(Object(Closure))
#12 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/base/Module.php(742): yii\di\ServiceLocator->get('request', true)
#13 /Users/foobar/Sites/craft-2/vendor/craftcms/cms/src/web/Application.php(345): yii\base\Module->get('request', true)
#14 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/web/Application.php(160): craft\web\Application->get('request')
#15 /Users/foobar/Sites/craft-2/vendor/craftcms/cms/src/helpers/App.php(430): yii\web\Application->getRequest()
#16 /Users/foobar/Sites/craft-2/vendor/craftcms/cms/src/config/app.php(207): craft\helpers\App::logConfig()
#17 [internal function]: {closure}()
#18 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/di/Container.php(503): call_user_func_array(Object(Closure), Array)
#19 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/BaseYii.php(351): yii\di\Container->invoke(Object(Closure), Array)
#20 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/di/ServiceLocator.php(137): yii\BaseYii::createObject(Object(Closure))
#21 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/base/Module.php(742): yii\di\ServiceLocator->get('log', true)
#22 /Users/foobar/Sites/craft-2/vendor/craftcms/cms/src/web/Application.php(345): yii\base\Module->get('log', true)
#23 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/base/Application.php(508): craft\web\Application->get('log')
#24 /Users/foobar/Sites/craft-2/vendor/craftcms/cms/src/base/ApplicationTrait.php(1171): yii\base\Application->getLog()
#25 /Users/foobar/Sites/craft-2/vendor/craftcms/cms/src/web/Application.php(106): craft\web\Application->_preInit()
#26 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/base/BaseObject.php(109): craft\web\Application->init()
#27 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/base/Application.php(206): yii\base\BaseObject->__construct(Array)
#28 /Users/foobar/Sites/craft-2/vendor/craftcms/cms/src/web/Application.php(97): yii\base\Application->__construct(Array)
#29 [internal function]: craft\web\Application->__construct(Array)
#30 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/di/Container.php(383): ReflectionClass->newInstanceArgs(Array)
#31 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/di/Container.php(156): yii\di\Container->build('craft\\web\\Appli...', Array, Array)
#32 /Users/foobar/Sites/craft-2/vendor/yiisoft/yii2/BaseYii.php(349): yii\di\Container->get('craft\\web\\Appli...', Array, Array)
#33 /Users/foobar/Sites/craft-2/vendor/craftcms/cms/bootstrap/bootstrap.php(252): yii\BaseYii::createObject(Array)
#34 /Users/foobar/Sites/craft-2/vendor/craftcms/cms/bootstrap/web.php(42): require('/Users/foobare...')
#35 /Users/foobar/Sites/craft-2/web/index.php(20): require('/Users/foobare...')
#36 /Users/foobar/.composer/vendor/laravel/valet/server.php(147): require('/Users/foobare...')
#37 {main}
andris-sevcenko commented 5 years ago

Can you send the project.yaml file over to support@craftcms.com? Unable to reproduce the issue mentioned in your comment.

andris-sevcenko commented 5 years ago

As far as the original issue - how did you copy the project.yaml file? Investigating this, I found a tricky issue where copying via terminal changed the modified time for the file, while copying via PhpStorm did not, resulting Craft thinking that the file had not been updated.

lukeyouell commented 5 years ago

@andris-sevcenko I don't mind placing it here for reference:

dateModified: 1544783950
email:
  fromEmail: admin@email.co.uk
  fromName: 'Craft 1 Sender'
  template: null
  transportSettings: null
  transportType: craft\mail\transportadapters\Sendmail
fieldGroups:
  93620624-d06f-4969-a7bf-5a626aef95a1:
    name: Content
  a53ff184-3768-448a-b33e-2d8bfde02216:
    name: Common
fields:
  0f5034b5-a4db-4bd8-9d82-f8356f63eb68:
    contentColumnType: string
    fieldGroup: a53ff184-3768-448a-b33e-2d8bfde02216
    handle: cards
    instructions: ''
    name: Cards
    searchable: true
    settings:
      contentTable: '{{%matrixcontent_cards}}'
      localizeBlocks: false
      maxBlocks: ''
      minBlocks: ''
    translationKeyFormat: null
    translationMethod: site
    type: craft\fields\Matrix
  948cddea-cbdc-4966-9a04-a6de676a8711:
    contentColumnType: text
    fieldGroup: 93620624-d06f-4969-a7bf-5a626aef95a1
    handle: body
    instructions: ''
    name: Body
    searchable: true
    settings:
      charLimit: ''
      code: ''
      columnType: text
      initialRows: '4'
      multiline: ''
      placeholder: ''
    translationKeyFormat: null
    translationMethod: none
    type: craft\fields\PlainText
matrixBlockTypes:
  c539b5ce-169c-404c-a529-4cf9832cafbc:
    field: 0f5034b5-a4db-4bd8-9d82-f8356f63eb68
    fieldLayouts:
      eb04534b-a0d0-49e4-b3a9-f049b239b599:
        tabs:
          -
            fields:
              19e796d8-ae3b-42d3-ad09-1ecb628b6d41:
                required: '0'
                sortOrder: 2
              76fa1d93-53d4-4d41-8e8f-05c090f61538:
                required: '1'
                sortOrder: 1
            name: Content
            sortOrder: 1
    fields:
      19e796d8-ae3b-42d3-ad09-1ecb628b6d41:
        contentColumnType: text
        fieldGroup: null
        handle: description
        instructions: ''
        name: Description
        searchable: '1'
        settings:
          charLimit: ''
          code: ''
          columnType: text
          initialRows: '4'
          multiline: ''
          placeholder: ''
        translationKeyFormat: null
        translationMethod: none
        type: craft\fields\PlainText
      76fa1d93-53d4-4d41-8e8f-05c090f61538:
        contentColumnType: text
        fieldGroup: null
        handle: heading
        instructions: ''
        name: Heading
        searchable: '1'
        settings:
          charLimit: ''
          code: ''
          columnType: text
          initialRows: '4'
          multiline: ''
          placeholder: ''
        translationKeyFormat: null
        translationMethod: none
        type: craft\fields\PlainText
    handle: card
    name: Card
    sortOrder: 1
plugins:
  contact-form:
    edition: standard
    enabled: true
    schemaVersion: 1.0.0
    settings:
      allowAttachments: ''
      prependSender: 'On behalf of'
      prependSubject: 'New message from Craft 1 Sender'
      successFlashMessage: 'Your message has been sent.'
      toEmail: enquiries@email.co.uk
sections:
  3a8e13db-bdcb-4628-8445-82b5805aaff1:
    enableVersioning: true
    entryTypes:
      f3111cb8-b55c-4587-a965-9be16d13b2e6:
        handle: homepage
        hasTitleField: false
        name: Homepage
        sortOrder: 1
        titleFormat: '{section.name|raw}'
        titleLabel: null
    handle: homepage
    name: Homepage
    propagateEntries: true
    siteSettings:
      a72213a0-4eba-4705-a9f3-6c62e6d93bc5:
        enabledByDefault: true
        hasUrls: true
        template: ''
        uriFormat: homepage
    type: single
  936bc15a-683d-4676-9eed-58ee3ba2cefb:
    enableVersioning: true
    entryTypes:
      2f919463-699f-42f4-a731-9d16889478fa:
        handle: contact
        hasTitleField: false
        name: Contact
        sortOrder: 1
        titleFormat: '{section.name|raw}'
        titleLabel: null
    handle: contact
    name: Contact
    propagateEntries: true
    siteSettings:
      a72213a0-4eba-4705-a9f3-6c62e6d93bc5:
        enabledByDefault: true
        hasUrls: true
        template: ''
        uriFormat: contact
    type: single
  9799e4bb-55cc-4895-941b-8a6dbd4358fe:
    enableVersioning: true
    entryTypes:
      31c49107-897b-49cb-9518-4af8d8fb54d2:
        handle: main
        hasTitleField: true
        name: Main
        sortOrder: 1
        titleFormat: null
        titleLabel: Title
    handle: main
    name: Main
    propagateEntries: true
    siteSettings:
      a72213a0-4eba-4705-a9f3-6c62e6d93bc5:
        enabledByDefault: true
        hasUrls: true
        template: ''
        uriFormat: 'main/{slug}'
    structure:
      maxLevels: '3'
      uid: 9359c0d9-6651-4cff-b81d-818d58bffea5
    type: structure
siteGroups:
  81b269fd-807f-4d03-bc45-bdd12c4a6ff6:
    name: 'Craft 1'
sites:
  a72213a0-4eba-4705-a9f3-6c62e6d93bc5:
    baseUrl: '@web/'
    handle: default
    hasUrls: '1'
    language: en-GB
    name: 'Craft 1'
    primary: '1'
    siteGroup: 81b269fd-807f-4d03-bc45-bdd12c4a6ff6
    sortOrder: '1'
system:
  edition: solo
  live: true
  name: 'Craft 1'
  schemaVersion: 3.1.9
  timeZone: Europe/London
users:
  allowPublicRegistration: false
  defaultGroup: null
  photoSubpath: ''
  photoVolumeUid: null
  requireEmailVerification: true
volumes:
  1e80cfa5-062c-4ecc-afd1-a82f402f6537:
    handle: uploads
    hasUrls: true
    name: Uploads
    settings:
      path: '@web/assets/uploads'
    sortOrder: 1
    type: craft\volumes\Local
    url: '@web/assets/uploads'

The file was placed in the config folder before running Craft's setup process.

andris-sevcenko commented 5 years ago

Ah, before. That's not supported yet.

andris-sevcenko commented 5 years ago

Duplicate of #3291

andris-sevcenko commented 5 years ago

Any thoughts on https://github.com/craftcms/cms/issues/3558#issuecomment-447297851?

lukeyouell commented 5 years ago

I've tried loading it before, after, replacing the content of the existing yaml file as well as deleting and fully replacing. Changes are detected but never applied.

andris-sevcenko commented 5 years ago

I've tried loading it before, after, replacing the content of the existing yaml file as well as deleting and fully replacing. Changes are detected but never applied.

I installed a fresh Craft 3.1-beta.4, replaced the contents of the project.yaml with the one you posted above. The only change I did was remove the plugins key from the config. I opened the site dashboard, it offered me to sync the changes, warning me in the process that I had more recent changes already loaded. I went through with the process and all the changes got applied.

What do you mean with "Changes are detected but never applied."?

lukeyouell commented 5 years ago

I managed to get the yaml file working for the fresh installations by transferring the data in blocks (site groups, sites, email etc) and updating in batches.

I've worked out that the issue with transferring my existing site's scaffolding (original issue) is down to custom fields such as super table, not being compatible with 3.1 yet. No error was thrown, I presume it failed because of the super table field and just stopped.

lukeyouell commented 5 years ago

Would it be possible to run the yaml file through some sort of validator before starting the update? This would then error if the yaml file isn't compatible.

andris-sevcenko commented 5 years ago

It's all pretty involved and it's not really possible to wrap up in a transaction, either, because adding new fields adds new columns to tables and MySQL instantly commits any active transactions on schema changes...

Thanks for pinpointing it, though. I'll keep this one open and edit the original title and text to reflect the real issue.

michtio commented 5 years ago

@andris-sevcenko I think this can be closed? SuperTable had done it's updates. And seems to work flawlessly now?

andris-sevcenko commented 5 years ago

You are correct!