craftcms / cms

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

HTTP ERROR 500 after upgrade to 4, propably PHP (8) issue [3.x]: #11638

Closed hhentschel closed 2 years ago

hhentschel commented 2 years ago

What happened?

Description

After upgrading to version 4 i get an HTTP ERROR 500. I can't even access the CP. I followed these and these steps.

i am on localhost and using Mamp pro. There i changed the PHP Version for this project to PHP 8.1.1. i also change this to the according php version in my .bash_profile

export PATH=/Applications/MAMP/bin/php/php8.1.10/bin/:$PATH alias phpmamp='/Applications/MAMP/bin/php/php8.1.1/bin/php'

when i revert the changes in composer.json to the 3.x. Craft Version and all the plugins to their older version, i get access to cp and the site works.

i think it has something to do with the php version. i looked at the logs, but i dont find any erros there.

Craft CMS version

3.7.48

PHP version

8.1.1

Operating system and version

Linux 4.19.0-17-amd64

Database type and version

MySQL 5.7.34

Image driver and version

Imagick 3.5.1 (ImageMagick 6.9.6-2)

Installed plugins and versions

CKEditor | 1.3.0 Expanded Singles - 1.2.0 Neo 2.13.15 Redactor 2.10.10 SEOmatic 3.4.36 Template Comments 1.2.0 Twigpack 1.2.17

RetroChaos commented 2 years ago

I had a similar issue. What do the logs in your craft/storage/logs say? That may help the actual Craft team diagnose the issue further.

Personally, what I did was try to upgrade Craft without any plugins first.

If that doesn't work, I exported my old db, did a fresh Craft install, installed the plugins I wanted, copied across my templates and assets, then restore my db via the command line.

hhentschel commented 2 years ago

Thanks. In the logs is nothing, what looks like an error.

I tried only update cms, without plugins, but then i get requirements errors.

ok, maybe i do that fresh install, i was hoping to avoid that.

hhentschel commented 2 years ago

i made a fresh craft 4 install.

what is the best practice for the next steps?

i copied the config project folder and tried a rebuild, but then i get this: Craft CMS is installed with schema version of 4.0.0.9 while 3.7.33 was expected.

when i try to import the db via phpmyadmin i get the error: Cannot add foreign key constraint

how do i restore the db via the command line?

RetroChaos commented 2 years ago

https://craftcms.com/docs/4.x/console-commands.html#db/restore

eg. php craft db/backup path/to/file.sq --drop-all-tables

I need to do one last test and document my steps properly, which I'm due to do tomorrow.

hhentschel commented 2 years ago

thanks a lot, would be very nice to read through your tests.

restoring the db via comman line, gives me the same error as importing: ERROR 1217 (23000) at line 2296: Cannot delete or update a parent row: a foreign key constraint fails

RetroChaos commented 2 years ago

If you cannot restore the backup anywhere then there seems to be an issue with your database at the point of backup. Are there any migrations pending?

I did this anyway:

  1. Filesystem Backup
  2. Database backup (eg. php craft db/backup backup-3x.sql)
  3. Delete the entire install/folder
  4. Re-install
  5. Re-install plugins
  6. Restore /template and any sub-directories in /web (be careful with index.php in the webroot, do not overwrite)
  7. Restore database (eg. php craft db/restore backup-3x.sql). Don't drop any tables but clear the cache
brandonkelly commented 2 years ago

I’m not sure how a fresh install would make things any easier. Let’s just get to the bottom of the 500 response.

As a starting point, make sure Dev Mode is enabled in config/general.php:

'devMode' => true,

That should surface the actual error that is occurring. What is the error?

brandonkelly commented 2 years ago

Closing due to inactivity. Feel free to respond if you want to pick this back up though.

SimonSoutas commented 10 months ago

Yo, had the same problem, for anybody wondering: It was because I had something in my custom module which wasn't upgraded to php 8 properly 😅