craftcms / cms

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

[4.x]: Migration almost worked #12264

Closed loqus closed 1 year ago

loqus commented 1 year ago

What happened?

Description

I'm getting a good front-end, but the CP gives: Setting unknown property: craft\fieldlayoutelements\entries\EntryTitleField::fieldUid

Steps to reproduce

  1. Migrate to v4

Expected behavior

Actual behavior

Craft CMS version

Craft Pro 3.7.55.2 to 4

PHP version

8.0.25

Operating system and version

CentOs 7

Database type and version

MariaDb 10.5.17

Image driver and version

No response

Installed plugins and versions

-

brianjhanson commented 1 year ago

Do you have any more of a stack trace you can provide to help narrow down where that error would be coming from? Do you see it when running the migrations or after they're all done?

loqus commented 1 year ago

error-dashboard (1)

loqus commented 1 year ago

So what I did was uninstall all non compatible plugins, ran the step by step updating guide. All went well. The front-end shows well. The login page for the cp also works. After logging in I get this error.

loqus commented 1 year ago

I got a little further, I looked into the differences in the composer file from a clean install and the current install. The differences were: "require-dev": { "yiisoft/yii2-shell": "^2.0.3" }, and "vlucas/phpdotenv": "^5.4.0", <= mine was set to a version ^2.4

After updating composer got a new error in the dashboard

Fatal error: Uncaught TypeError: Dotenv\Dotenv::__construct(): Argument #1 ($store) must be of type Dotenv\Store\StoreInterface, string given, called in /web/index.php on line 201 and defined in /vendor/vlucas/phpdotenv/src/Dotenv.php:60 Stack trace: #0 /web/index.php(201): Dotenv\Dotenv->__construct() #1 {main} thrown in /vendor/vlucas/phpdotenv/src/Dotenv.php on line 60

It seems to be coming from these lines in index.php

if (file_exists(CRAFT_BASE_PATH.'/.env')) { (new Dotenv\Dotenv(CRAFT_BASE_PATH))->load(); }

brianjhanson commented 1 year ago

Our recommendations on the entry scripts have been updated a bit in four. I'd recommend checking your configuration against the Craft starter project. Based on the lines you've shared here, you'll at least want to update the index.php to

// Load dotenv?
if (class_exists(Dotenv\Dotenv::class)) {
    // By default, this will allow .env file values to override environment variables
    // with matching names. Use `createUnsafeImmutable` to disable this.
    Dotenv\Dotenv::createUnsafeMutable(CRAFT_BASE_PATH)->safeLoad();
}

However, I think that might be unrelated to the other issue. Can you run a project-config/apply --force to see if that clears up your issue? I have a feeling it might be the same issue as #11925

brandonkelly commented 1 year ago

Sounds to me like there was a Git merge conflict on one of your entry types’ project config YAML files at some point (config/project/entryTypes/...), which wasn’t resolved correctly.

I’m not sure why this error wouldn’t show up until your Craft 4 upgrade, as this is all the same code as in Craft 3.

I suspect you could resolve it by running the following command in Craft 3, prior to upgrading:

> php craft project-config/rebuild
loqus commented 1 year ago

Ok I'll try that first before updating. So I made a copy of the DB and set up a new dev env. Ran the rebuild and got: PHP Fatal Error 'yii\base\ErrorException' with message 'Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in vendor/yiisoft/yii2/db/Command.php:381' so it seems it cannot find something it needs

loqus commented 1 year ago

It's a shit load of work, but maybe it's best to re-create the website starting with a blank craft 4 slate. Unless I can somehow easily export and import some things (but most is based on matixes) unless you are going to support v3 forever

brandonkelly commented 1 year ago

Can you try increasing your memory_limit PHP setting?

loqus commented 1 year ago

I went from 128 to 512 and that seemed to do the trick. I'll try updating to 4 tomorrow

loqus commented 1 year ago

Amazing @brandonkelly @brianjhanson ! With your help it worked out perfectly. Thanks so much. craft-4

brandonkelly commented 1 year ago

Glad to hear it!