1

I'm trying to upgrade from 3.3.15 -> 3.5.5 from control panel.

I run it via docker so all I need is to update the composer.lock file to have the correct dependencies and everything should be fine the next time I rebuild the image, but something strange is happening.

After selecting the upgrade, it runs for a few minutes and then just gets an internal server error. It logs the following:

craft_1        | [21-Aug-2020 07:38:50] WARNING: [pool www] child 146 said into stderr: "NOTICE: PHP message: PHP Fatal error:  Uncaught Error: Class 'Yii' not found in /app/vendor/yiisoft/yii2/validators/IpValidator.php:218"
craft_1        | [21-Aug-2020 07:38:50] WARNING: [pool www] child 146 said into stderr: "Stack trace:"
craft_1        | [21-Aug-2020 07:38:50] WARNING: [pool www] child 146 said into stderr: "#0 /app/vendor/yiisoft/yii2/base/BaseObject.php(109): yii\validators\IpValidator->init()"
craft_1        | [21-Aug-2020 07:38:50] WARNING: [pool www] child 146 said into stderr: "#1 /app/vendor/yiisoft/yii2/web/Request.php(345): yii\base\BaseObject->__construct()"
craft_1        | [21-Aug-2020 07:38:50] WARNING: [pool www] child 146 said into stderr: "#2 /app/vendor/yiisoft/yii2/web/Request.php(1877): yii\web\Request->getIpValidator()"
craft_1        | [21-Aug-2020 07:38:50] WARNING: [pool www] child 146 said into stderr: "#3 /app/vendor/yiisoft/yii2/web/Request.php(1859): yii\web\Request->getSecureForwardedHeaderTrustedParts()"
craft_1        | [21-Aug-2020 07:38:50] WARNING: [pool www] child 146 said into stderr: "#4 /app/vendor/yiisoft/yii2/web/Request.php(1084): yii\web\Request->getSecureForwardedHeaderTrustedPart('proto')"
craft_1        | 2020/08/21 07:38:50 [error] 139#139: *4 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Class 'Yii' not found in /app/vendor/yiisoft/yii2/validators/IpValidator.php:218

which is a bit odd, why would a dependency disappear when upgrading like this? After this attempted upgrade, the install is left in a broken state, giving 500 errors (and the same error, Yii not found) for all requests. Reverting the composer.json + composer.lock file and reinstalling dependencies restores functionality.

I had the same issue when trying to upgrade to 3.4, but postponed the upgrade at that point because I had other priorities.

I can add, remove and upgrade plugins from the store without problems with this image. I have composer.json and composer.lock writable, as well as the vendor folder, storage, and migrations.

EDIT: It actually seems like the change in 3.3.16 is causing this, the upgrade of yii to 2.0.30. Doing this:

bash-4.4# composer require craftcms/cms:3.3.16
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Can only install one of: yiisoft/yii2[2.0.30, 2.0.21].
    - Can only install one of: yiisoft/yii2[2.0.30, 2.0.21].
    - Can only install one of: yiisoft/yii2[2.0.30, 2.0.21].
    - craftcms/cms 3.3.16 requires yiisoft/yii2 ~2.0.30.0 -> satisfiable by yiisoft/yii2[2.0.30].
    - Installation request for craftcms/cms 3.3.16 -> satisfiable by craftcms/cms[3.3.16].
    - Installation request for yiisoft/yii2 (locked at 2.0.21) -> satisfiable by yiisoft/yii2[2.0.21].


Installation failed, reverting ./composer.json to its original content.

I don't understand why it complains about yii2 being locked to that version. Nothing in composer.lock is explicitly stating that version, they all use ~ versions.

But even when I delete the lock file, the vendor folder, and runs a composer install it seems to successfully install 2.0.30 of Yii2 but I still get that message, I'm starting to get very frustrated at composer...

EDIT 2: This is my composer file:

{
  "repositories": [
    {
      "type": "artifact",
      "url": "composer-artifacts/"
    }
  ],
  "require": {
    "aws/aws-sdk-php": "^3.112",
    "carlcs/craft-redactorcustomstyles": "3.0.2",
    "codemix/yii2-streamlog": "^1.2",
    "craftcms/aws-s3": "^1.2",
    "craftcms/cms": "^3.3.15",
    "craftcms/redactor": "2.3.3.2",
    "dolphiq/redirect": "1.0.24",
    "mmikkel/retcon": "2.0.12",
    "thejoshsmith/craft-title-to-sidebar": "1.0.1",
    "verbb/super-table": "2.3.3",
    "vlucas/phpdotenv": "^3.4.0"
  },
  "autoload": {
    "psr-4": {
      "rex\\craft\\modules\\": "modules/"
    }
  },
  "config": {
    "sort-packages": true,
    "optimize-autoloader": true,
    "platform": {
      "php": "7.0"
    },
    "github-oauth": {
      "github.com": "xxxxxx"
    }
  },
  "scripts": {
    "post-root-package-install": [
      "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ]
  }
}

EDIT 3: I used the same setup on a completely brand new 3.5.5 setup and did the upgrade to 3.5.6 without a hickup. Seems like there is some issues with 3.3.15 and upgrades, or perhaps some of the plugins (although I tried removing them from composer.json and it still fails).

EDIT 4: I tried running ./craft update all within the container now, and the output just states:

bash-5.0# ./craft update all
Fetching available updates ... done
Performing 6 updates:

    - craft 3.3.15 => 3.5.9
    - aws-s3 1.2.5 => 1.2.11
    - redactor 2.3.3.2 => 2.4.0
    - redactor-custom-styles 3.0.2 => 3.0.4
    - redirect 1.0.24 => 1.1.1
    - retcon 2.0.12 => 2.2.1

Backup the database? (yes|no) [yes]:no
Skipping database backup.
Performing update with Composer ... error: An error occurred

Output:

<warning>Package "craftcms/vue-asset" listed for update is not installed. Ignoring.</warning>
<warning>Package "danielstjules/stringy" listed for update is not installed. Ignoring.</warning>
<warning>Package "yiisoft/yii2-shell" listed for update is not installed. Ignoring.</warning>
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for carlcs/craft-redactorcustomstyles 3.0.4 -> satisfiable by carlcs/craft-redactorcustomstyles[3.0.4].
    - carlcs/craft-redactorcustomstyles 3.0.4 requires craftcms/redactor ^2.7.0 -> satisfiable by craftcms/redactor[2.7.4, 2.7.3, 2.7.2, 2.7.1, 2.7.0] but these conflict with your requirements or minimum-stability.

<warning>Running update with --no-dev does not mean require-dev is ignored, it just means the packages will not be installed. If dev requirements are blocking the update you have to resolve those problems.</warning>


Revert the Composer changes? (yes|no) [yes]:

EDIT 5:

I have found the culprit, but don't really understand why this works in some versions but not in others.

In general.php, I'm using yii\web\Request to figure out the "local" hostname

use yii\web\Request;
$request = new Request;

... 

'@baseUrlPrefix' => getenv('BASE_URL_PREFIX') ?: $request->getHostInfo(),

when setting an alias. That fails for some reason, on certain versions (of Yii? don't know).

4
  • What's in your composer.json file? Commented Aug 21, 2020 at 15:28
  • @RitterKnight I added my composer file. I have tried to set everything as "allow minor" changes with ^ but still no go.
    – jishi
    Commented Aug 24, 2020 at 9:01
  • There's a lot going on here, but your last edit (#4) is easy enough. The Redactor Custom Styles plugin at 3.0.4 requires Redactor > 2.7.0. github.com/carlcs/craft-redactorcustomstyles/blob/v3/… Change to "carlcs/craft-redactorcustomstyles": "^3.0.2", and "craftcms/redactor": "^2.3.3.2", then run composer update and that should resolve that one.
    – Brad Bell
    Commented Sep 9, 2020 at 20:21
  • @BradBell When I choose to only upgrade craft, it just silently fails with error 255. everything I try ends up with the error that use Yii throws an error, albeit it being present in the vendor folder correctly. I even copied the composer.json/composer.lock from another working 3.5 site and ran composer install, and I still end up with the same error. I don't understand how my config or database state could trigger such a low level dependency error?
    – jishi
    Commented Sep 10, 2020 at 7:59

2 Answers 2

2
+100

You can't create an new yii\web\Request instance in general.php because Craft isn't fully initialized yet. It worked in previous versions but the Craft team seem to have changed the loading order.

You must find another way to define you site base URL.

0

Did you try removing composer.lock file and the vendor directory and then doing a fresh composer install?

7
  • Yes, that was one of the first things I tried. It says it has installed everything correctly, but in the end Yii2 is still missing.
    – jishi
    Commented Sep 9, 2020 at 18:04
  • What's weirder is that vendor/yiisoft/yii2 is actually there. Could it be something off with autoload? I'm not sure how that stuff works...
    – jishi
    Commented Sep 9, 2020 at 18:50
  • I had similar issues when updating an older version of craft, I remember it was due to an incomaptible plugin. Could you try (temporarily) removing some of them and try running composer install again? Commented Sep 10, 2020 at 7:04
  • I have tried that as well, removing all plugins and only keeping craftcms, still the same issue. I even did a setup of a completely new project (which do work), then copy composer.json and composer.lock from that structure into my current install, but it still fails. I'm starting to wonder if there is something wrong with the bootstrap files, but index.php is identical and everything else seems to load from the vendor folder...
    – jishi
    Commented Sep 10, 2020 at 7:14
  • Have you tried manually setting the craft version in composer.json, ditching the lock file, vendor dir and doing a composer install? So bypassing craft update altogether Commented Sep 10, 2020 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.