craftcms / aws-s3

Amazon S3 volume type for Craft CMS.
https://plugins.craftcms.com/aws-s3
MIT License
61 stars 28 forks source link

Can't migrate from Craft 2 -> 3.1 AWS #38

Closed bossanova808 closed 5 years ago

bossanova808 commented 5 years ago

After my initial migration, I log into the CP and this plugin is in an uninstalled state (as it is not present in C2 I guess). When I then attempt to install, it gives the error and the CP is then unreachable:

yii\base\UnknownPropertyException: Setting unknown property: craft\awss3\Volume::urlPrefix in /var/www/vhosts/c3-dev/vendor/yiisoft/yii2/base/Component.php:209
Stack trace:
#0 /var/www/vhosts/c3-dev/vendor/yiisoft/yii2/BaseYii.php(546): yii\base\Component->__set('urlPrefix', 'https://s3-ap-s...')
#1 /var/www/vhosts/c3-dev/vendor/yiisoft/yii2/base/BaseObject.php(107): yii\BaseYii::configure(Object(craft\awss3\Volume), Array)
#2 /var/www/vhosts/c3-dev/vendor/craftcms/cms/src/helpers/Component.php(80): yii\base\BaseObject->__construct(Array)
#3 /var/www/vhosts/c3-dev/vendor/craftcms/cms/src/services/Volumes.php(499): craft\helpers\Component::createComponent(Array, 'craft\\base\\Volu...')
#4 /var/www/vhosts/c3-dev/vendor/craftcms/cms/src/services/Volumes.php(222): craft\services\Volumes->createVolume(Array)
#5 /var/www/vhosts/c3-dev/vendor/craftcms/cms/src/services/Volumes.php(236): craft\services\Volumes->getAllVolumes()
#6 /var/www/vhosts/c3-dev/vendor/craftcms/cms/src/models/VolumeFolder.php(93): craft\services\Volumes->getVolumeById(4)
#7 /var/www/vhosts/c3-dev/vendor/craftcms/cms/src/fields/Assets.php(805): craft\models\VolumeFolder->getVolume()
#8 /var/www/vhosts/c3-dev/vendor/craftcms/cms/src/fields/Assets.php(124): craft\fields\Assets->_folderSourceToVolumeSource('folder:df4ad037...')
#9 /var/www/vhosts/c3-dev/vendor/yiisoft/yii2/base/BaseObject.php(109): craft\fields\Assets->init()
#10 /var/www/vhosts/c3-dev/vendor/craftcms/cms/src/fields/BaseRelationField.php(173): yii\base\BaseObject->__construct(Array)
#11 /var/www/vhosts/c3-dev/vendor/craftcms/cms/src/helpers/Component.php(80): craft\fields\BaseRelationField->__construct(Array)
#12 /var/www/vhosts/c3-dev/vendor/craftcms/cms/src/services/Fields.php(548): craft\helpers\Component::createComponent(Array, 'craft\\base\\Fiel...')
#13 /var/www/vhosts/c3-dev/vendor/craftcms/cms/src/services/Fields.php(573): craft\services\Fields->createField(Array)
#14 /var/www/vhosts/c3-dev/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1536): craft\services\Fields->getAllFields()
#15 /var/www/vhosts/c3-dev/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1073): craft\elements\db\ElementQuery->customFields()
#16 /var/www/vhosts/c3-dev/vendor/yiisoft/yii2/db/QueryBuilder.php(227): craft\elements\db\ElementQuery->prepare(Object(craft\db\mysql\QueryBuilder))
#17 /var/www/vhosts/c3-dev/vendor/yiisoft/yii2/db/Query.php(146): yii\db\QueryBuilder->build(Object(craft\elements\db\UserQuery))
#18 /var/www/vhosts/c3-dev/vendor/yiisoft/yii2/db/Query.php(274): yii\db\Query->createCommand(Object(craft\db\Connection))
#19 /var/www/vhosts/c3-dev/vendor/craftcms/cms/src/db/Query.php(177): yii\db\Query->one(NULL)
#20 /var/www/vhosts/c3-dev/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1215): craft\db\Query->one(NULL)
#21 /var/www/vhosts/c3-dev/vendor/craftcms/cms/src/elements/User.php(367): craft\elements\db\ElementQuery->one()
#22 /var/www/vhosts/c3-dev/vendor/yiisoft/yii2/web/User.php(690): craft\elements\User::findIdentity('1')
#23 /var/www/vhosts/c3-dev/vendor/craftcms/cms/src/web/User.php(474): yii\web\User->renewAuthStatus()
#24 /var/www/vhosts/c3-dev/vendor/yiisoft/yii2/web/User.php(192): craft\web\User->renewAuthStatus()
#25 /var/www/vhosts/c3-dev/vendor/yiisoft/yii2/web/User.php(360): yii\web\User->getIdentity()
#26 /var/www/vhosts/c3-dev/vendor/craftcms/cms/src/web/User.php(189): yii\web\User->getIsGuest()
#27 /var/www/vhosts/c3-dev/vendor/craftcms/cms/src/web/Application.php(259): craft\web\User->getIsGuest()
#28 /var/www/vhosts/c3-dev/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#29 /var/www/vhosts/c3-dev/web/index.php(21): yii\base\Application->run()
#30 {main}

This occurs even though I have my settings for the volumes in .env and config/volumes.php

genert commented 5 years ago

Are you using "dev-craft-3.1" in your composer as version for this library?

See #35

billythekid commented 5 years ago

I'm getting this as well, I am using dev-craft-3.1.

yii\base\UnknownPropertyException: Setting unknown property: craft\awss3\Volume::urlPrefix in /Users/btk/sites/m-g/fireplaces/vendor/yiisoft/yii2/base/Component.php:209
Stack trace:
#0 /Users/btk/sites/m-g/fireplaces/vendor/yiisoft/yii2/BaseYii.php(546): yii\base\Component->__set('urlPrefix', '//s3-eu-west-1....')
#1 /Users/btk/sites/m-g/fireplaces/vendor/yiisoft/yii2/base/BaseObject.php(107): yii\BaseYii::configure(Object(craft\awss3\Volume), Array)
#2 /Users/btk/sites/m-g/fireplaces/vendor/craftcms/cms/src/helpers/Component.php(80): yii\base\BaseObject->__construct(Array)
#3 /Users/btk/sites/m-g/fireplaces/vendor/craftcms/cms/src/services/Volumes.php(499): craft\helpers\Component::createComponent(Array, 'craft\\base\\Volu...')
#4 /Users/btk/sites/m-g/fireplaces/vendor/craftcms/cms/src/services/Volumes.php(222): craft\services\Volumes->createVolume(Array)
#5 /Users/btk/sites/m-g/fireplaces/vendor/craftcms/cms/src/services/Volumes.php(160): craft\services\Volumes->getAllVolumes()
#6 /Users/btk/sites/m-g/fireplaces/vendor/craftcms/cms/src/services/Volumes.php(203): craft\services\Volumes->getViewableVolumes()
#7 /Users/btk/sites/m-g/fireplaces/vendor/craftcms/cms/src/web/twig/variables/Cp.php(109): craft\services\Volumes->getTotalViewableVolumes()
#8 /Users/btk/sites/m-g/fireplaces/vendor/twig/twig/lib/Twig/Extension/Core.php(1626): craft\web\twig\variables\Cp->nav()
#9 /Users/btk/sites/m-g/fireplaces/vendor/craftcms/cms/src/helpers/Template.php(73): twig_get_attribute(Object(craft\web\twig\Environment), Object(Twig_Source), Object(craft\web\twig\variables\Cp), 'nav', Array, 'method', false, false)
#10 /Users/btk/sites/m-g/fireplaces/storage/runtime/compiled_templates/a5/a5664df881df1f7834be809924583c9f6232433454771557f2076fcbcf848897.php(195): craft\helpers\Template::attribute(Object(craft\web\twig\Environment), Object(Twig_Source), Object(craft\web\twig\variables\Cp), 'nav', Array, 'method')
#11 /Users/btk/sites/m-g/fireplaces/vendor/twig/twig/lib/Twig/Template.php(189): __TwigTemplate_11c343741dd478385592b3fe741516418121a5d74860df7e2723f65e1cadbc87->block_body(Array, Array)
#12 /Users/btk/sites/m-g/fireplaces/storage/runtime/compiled_templates/58/58ec77900a1007b82638db3717f18e766bce0ede4bbcc24f287021f14de931e9.php(60): Twig_Template->displayBlock('body', Array, Array)
#13 /Users/btk/sites/m-g/fireplaces/vendor/twig/twig/lib/Twig/Template.php(386): __TwigTemplate_2dd1f502044680a025bba9041847033bdd6b85eeb3db2ff43f4af04d56a91310->doDisplay(Array, Array)
#14 /Users/btk/sites/m-g/fireplaces/vendor/craftcms/cms/src/web/twig/Template.php(49): Twig_Template->displayWithErrorHandling(Array, Array)
#15 /Users/btk/sites/m-g/fireplaces/vendor/twig/twig/lib/Twig/Template.php(363): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#16 /Users/btk/sites/m-g/fireplaces/vendor/craftcms/cms/src/web/twig/Template.php(31): Twig_Template->display(Array, Array)
#17 /Users/btk/sites/m-g/fireplaces/storage/runtime/compiled_templates/5a/5a5f9bbb7c9a75ef9d698dd2805441dc6fcc2e58d8a4648d28db4f392a1dfd01.php(40): craft\web\twig\Template->display(Array, Array)
#18 /Users/btk/sites/m-g/fireplaces/vendor/twig/twig/lib/Twig/Template.php(386): __TwigTemplate_e88457a12af2a316c465720c7c8a5d89516b7f3e814b4631ababbb6b3587bc83->doDisplay(Array, Array)
#19 /Users/btk/sites/m-g/fireplaces/vendor/craftcms/cms/src/web/twig/Template.php(49): Twig_Template->displayWithErrorHandling(Array, Array)
#20 /Users/btk/sites/m-g/fireplaces/vendor/twig/twig/lib/Twig/Template.php(363): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#21 /Users/btk/sites/m-g/fireplaces/vendor/craftcms/cms/src/web/twig/Template.php(31): Twig_Template->display(Array, Array)
#22 /Users/btk/sites/m-g/fireplaces/storage/runtime/compiled_templates/a5/a5664df881df1f7834be809924583c9f6232433454771557f2076fcbcf848897.php(95): craft\web\twig\Template->display(Array, Array)
#23 /Users/btk/sites/m-g/fireplaces/vendor/twig/twig/lib/Twig/Template.php(386): __TwigTemplate_11c343741dd478385592b3fe741516418121a5d74860df7e2723f65e1cadbc87->doDisplay(Array, Array)
#24 /Users/btk/sites/m-g/fireplaces/vendor/craftcms/cms/src/web/twig/Template.php(49): Twig_Template->displayWithErrorHandling(Array, Array)
#25 /Users/btk/sites/m-g/fireplaces/vendor/twig/twig/lib/Twig/Template.php(363): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#26 /Users/btk/sites/m-g/fireplaces/vendor/craftcms/cms/src/web/twig/Template.php(31): Twig_Template->display(Array, Array)
#27 /Users/btk/sites/m-g/fireplaces/storage/runtime/compiled_templates/1c/1caa472eb58784a39a199654d92171058cec38f8f5cf025f9bbc72604345ed8e.php(47): craft\web\twig\Template->display(Array, Array)
#28 /Users/btk/sites/m-g/fireplaces/vendor/twig/twig/lib/Twig/Template.php(386): __TwigTemplate_4c1ce0ff118493051b7c9f74dd1ddcb7bcf340428bd1257d0b8409fa0cb9a0eb->doDisplay(Array, Array)
#29 /Users/btk/sites/m-g/fireplaces/vendor/craftcms/cms/src/web/twig/Template.php(49): Twig_Template->displayWithErrorHandling(Array, Array)
#30 /Users/btk/sites/m-g/fireplaces/vendor/twig/twig/lib/Twig/Template.php(363): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#31 /Users/btk/sites/m-g/fireplaces/vendor/craftcms/cms/src/web/twig/Template.php(31): Twig_Template->display(Array, Array)
#32 /Users/btk/sites/m-g/fireplaces/vendor/twig/twig/lib/Twig/Template.php(371): craft\web\twig\Template->display(Array)
#33 /Users/btk/sites/m-g/fireplaces/vendor/twig/twig/lib/Twig/Environment.php(289): Twig_Template->render(Array)
#34 /Users/btk/sites/m-g/fireplaces/vendor/craftcms/cms/src/web/View.php(337): Twig_Environment->render('settings/plugin...', Array)
#35 /Users/btk/sites/m-g/fireplaces/vendor/craftcms/cms/src/web/View.php(384): craft\web\View->renderTemplate('settings/plugin...', Array)
#36 /Users/btk/sites/m-g/fireplaces/vendor/craftcms/cms/src/web/Controller.php(161): craft\web\View->renderPageTemplate('settings/plugin...', Array)
#37 /Users/btk/sites/m-g/fireplaces/vendor/craftcms/cms/src/controllers/TemplatesController.php(78): craft\web\Controller->renderTemplate('settings/plugin...', Array)
#38 [internal function]: craft\controllers\TemplatesController->actionRender('settings/plugin...', Array)
#39 /Users/btk/sites/m-g/fireplaces/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#40 /Users/btk/sites/m-g/fireplaces/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#41 /Users/btk/sites/m-g/fireplaces/vendor/craftcms/cms/src/web/Controller.php(109): yii\base\Controller->runAction('render', Array)
#42 /Users/btk/sites/m-g/fireplaces/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('render', Array)
#43 /Users/btk/sites/m-g/fireplaces/vendor/craftcms/cms/src/web/Application.php(297): yii\base\Module->runAction('templates/rende...', Array)
#44 /Users/btk/sites/m-g/fireplaces/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('templates/rende...', Array)
#45 /Users/btk/sites/m-g/fireplaces/vendor/craftcms/cms/src/web/Application.php(286): yii\web\Application->handleRequest(Object(craft\web\Request))
#46 /Users/btk/sites/m-g/fireplaces/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#47 /Users/btk/sites/m-g/fireplaces/web/index.php(21): yii\base\Application->run()
#48 /Users/btk/.composer/vendor/laravel/valet/server.php(147): require('/Users/billyfag...')
#49 {main}
bossanova808 commented 5 years ago

Well, as a rule I'm trying to keep active in dev versions of things out of my composer & stick to at least 'beta' stuff. I know it's only a little change and easy to change back, but historically I've found that I sometimes leave dev versions in (because I'm spinning many plates) - and then end up pulling in some code that is ... less than ideal...because I'm not following every repo, I don't always know a release has happened etc. It may just be I don't understand composer well enough to feel confident, too.

Speaking more generally, I guess I just kinda have an expectation that first party plugins of fairly fundamental importance (i.e. volumes) & their migrations from previous major releases - will be made compatible & substantially tested before the release of a major platform update. Given I was following along with Craft 3.0 and Commerce 2 right up to the latest beta of that & all was well (in terms of migrations) - the amount of breakage that came with the final release of Commerce 2 requiring Craft 3.1 has been a bit of a nasty surprise...

andris-sevcenko commented 5 years ago

@bossanova808 point taken. In hindsight, 3.1 was too big of a release and we should have split that one up in at least two different releases - soft-deletes and project config. Pushing out one large release, especially with features that were developed side-by-side really hamstrung our testing efforts this time.

As for this specific issue.

This occurs even though I have my settings for the volumes in .env and config/volumes.php

That's probably exactly why it's occurring. This is because the setting names have changed and you are setting a urlPrefix property in your config/volumes.php file, which no longer exists. Can you check if that's the case?

andris-sevcenko commented 5 years ago

Once a faulty migration is ruled out, I'll cut a release. If that's indeed the config/volumes.php file, then you would have the exact same issues going to 3.0.x.

bossanova808 commented 5 years ago

Hi Andris - thanks for getting back to me (and apologies for grumpiness).

I definitely don't have urlPrefix in my volumes.php....and I did not have an issue with the migration to 3.0 (I was not using volumes.php with that, I've recently created it along the way to trying to solve this...)

This is my volumes.php right now:

<?php

return [
    's3Images' => [
        'hasUrls' => true,
        'url' => 'https://'.getenv('S3_IMAGES_BUCKET').'.s3.amazonaws.com/',
        'keyId' => getenv('S3_API_KEY'),
        'secret' => getenv('S3_SECRET'),
        'bucket' => getenv('S3_IMAGES_BUCKET'),
        'region' => getenv('S3_REGION'),
    ],
    's3files' => [
        'hasUrls' => true,
        'url' => 'https://'.getenv('S3_FILES_BUCKET').'.s3.amazonaws.com/',
        'keyId' => getenv('S3_API_KEY'),
        'secret' => getenv('S3_SECRET'),
        'bucket' => getenv('S3_FILES_BUCKET'),
        'region' => getenv('S3_REGION'),
    ],
];
bossanova808 commented 5 years ago

(and the migration fails with or without that file in place)

andris-sevcenko commented 5 years ago

@bossanova808 will test. Have some ideas about what might be going wrong. As soon as I have this sorted out, I'll cut a release.

bossanova808 commented 5 years ago

No problems - thankyou. I do have a support ticket in with a link to a db etc...if that helps

bossanova808 commented 5 years ago

I do note in the asset sources table there is still urlPrefix etc in the settings saved in there...it's like the migration for the plugin install is not running (the code in _convertVolumes()). Indeed when I install the plugin from the command line I don't see any migration running (and assume that is the same when I trigger the install via the CP)

But I will leave you to it - it's late here and the wife will get cranky with me if I hold up the evening too long...

andris-sevcenko commented 5 years ago

Fixed via 3cb4190

andris-sevcenko commented 5 years ago

We'll try to get a release out today that adresses this.

bossanova808 commented 5 years ago

Thanks Andris - tested this jut now and it indeed appears to solve the issue. Clicking on the volume settings gives me an error about missing expires, but I suspect that I just need to add that to my volumes.php to solve that...will try that out as soon as I am near an appropriate computer.