Jump to content

Recommended Posts

I just updated a site as follows:

cd /var/www/concrete5
composer update

Among other changes, the following were made (more on this later):

  - Updating concrete5/core (8.5.2 => 8.5.4): Downloading (100%)
  - Updating doctrine/collections (1.6.4 => 1.6.5): Downloading (100%)
  - Updating doctrine/lexer (1.2.0 => 1.2.1): Downloading (100%)
  - Updating doctrine/inflector (1.3.1 => 1.4.3): Downloading (100%)
  - Updating doctrine/cache (1.10.0 => 1.10.1): Downloading (100%)
  - Updating doctrine/annotations (1.10.2 => 1.10.3): Downloading (100%)
  - Updating doctrine/common (2.12.0 => 2.13.3): Downloading (100%)
  - Updating doctrine/instantiator (1.3.0 => 1.3.1): Downloading (100%)
  - Updating doctrine/orm (v2.7.2 => v2.7.3): Downloading (100%)


When accessing the site, I now have the following error:

errno: 150 "Foreign key constraint is incorrectly formed

I expected I should have first used concrete5's update script, but too late for that.  So, then I changed composer.json require concrete5/core from ^8.5 to 8.5.2 hoping to return to the previous state.

Concreete5 was downgraded as desired, but now I get the following error:

Class 'Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain' not found

On another concrete5 site which still works, I have the following two files, however, on the broken one I only have the second:

  • vendor/doctrine/persistence/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php:13:    class MappingDriverChain extends \Doctrine\Persistence\Mapping\Driver\MappingDriverChain
  • vendor/doctrine/persistence/lib/Doctrine/Persistence/Mapping/Driver/MappingDriverChain.php:17:class MappingDriverChain implements MappingDriver

So, now I will attempt to downgrade doctrine from 2.7.3 to 2.7.2.  The base composer.json file has no reference to Doctrine, but there are two other related composer files:

vendor/concrete5/doctrine-xml/composer.json

{
    "name": "concrete5/doctrine-xml",
    "description": "Define database structure via XML using Doctrine data types",
    "keywords": [
        "doctrine",
        "xml",
        "structure",
        "database",
        "schema"
    ],
    "homepage": "https://github.com/concrete5/doctrine-xml",
    "license": "MIT",
    "autoload": {
        "psr-4": {
            "DoctrineXml\\": "src/"
        }
    },
    "require": {
        "php": ">=5.3"
    },
    "require-dev": {
        "doctrine/dbal": "2.5.*"
    }
}

vendor/concrete5/dependency-patches/composer.json

{
    "type":"library",
    "license":"MIT",
    "name":"concrete5/dependency-patches",
    "description":"Patches required for concrete5 dependencies",
    "homepage":"https://github.com/concrete5/dependency-patches",
    "authors":[
        {
            "name":"Michele Locati",
            "email":"michele@locati.it",
            "role":"author",
            "homepage":"https://mlocati.github.io"
        }
    ],
    "require":{
        "mlocati/composer-patcher": "^1.0.0"
    },
    "extra":{
        "patches": {
            "doctrine/annotations:1.2.7": {
                "Fix access array offset on value of type null": "doctrine/annotations/access-array-offset-on-null.patch"
            },
            "doctrine/orm:2.5.14": {
                "Fix UnitOfWork::createEntity()": "doctrine/orm/UnitOfWork-createEntity-continue.patch"
            },
            "zendframework/zend-stdlib:2.7.7": {
                "Fix ArrayObject::unserialize()": "zendframework/zend-stdlib/ArrayObject-unserialize-continue.patch"
            },
            "sunra/php-simple-html-dom-parser:1.5.2": {
                "Fix minus in regular expressions": "sunra/php-simple-html-dom-parser/minus-in-regular-expressions.patch"
            },
            "phpunit/phpunit:4.8.36": {
                "Avoid each() in Getopt": "phpunit/phpunit/Getopt-each.patch"
            },
            "tedivm/jshrink:1.1.0": {
                "Fix continue switch in Minifier": "tedivm/jshrink/fix-minifier-loop.patch",
                "Update to upstream version 1.3.2": "tedivm/jshrink/update-upstream-1.3.2.patch"
            },
            "zendframework/zend-code:2.6.3": {
                "Fix continue switch in FileGenerator and MethodReflection": "zendframework/zend-code/switch-continue.patch"
            },
            "zendframework/zend-http:2.6.0": {
                "Remove support for the X-Original-Url and X-Rewrite-Url headers": "zendframework/zend-http/no-x-original-url-x-rewrite.patch"
            },
            "zendframework/zend-mail:2.7.3": {
                "Fix idn_to_ascii deprecation warning": "zendframework/zend-mail/fix-idn_to_ascii-deprecation-warning.patch"
            },
            "zendframework/zend-validator:2.8.2": {
                "Fix idn_to_ascii/idn_to_utf8 deprecation warning": "zendframework/zend-validator/fix-idn_to_-deprecation-warning.patch"
            }
        }
    }
}

Neither seem to be applicable, but the doctrine version has to be specified somewhere.   How does composer determine which version and how can I downgrade the dependency package?  Thanks

 

PS.  As a hack solution, I replaced the entire vendor/doctrine directory from one from another site, and have things working.  Still, want to know how to do this right.

Edited by NotionCommotion
Link to comment
https://forums.phpfreaks.com/topic/310927-downgrade-a-composer-dependency-package/
Share on other sites

Unless someone at Doctrine did something wrong, a patch version update like 8.5.2 -> 8.5.4 or 2.7.2 -> 2.7.3 should not break anything. I would first look at the two minor version upgrades: doctrine/inflector (1.3 -> 1.4) and doctrine/common (2.12 -> 2.13).

But is that really the problem that needs to be solved? Did you look into the foreign key constraint error first?

23 hours ago, requinix said:

Unless someone at Doctrine did something wrong, a patch version update like 8.5.2 -> 8.5.4 or 2.7.2 -> 2.7.3 should not break anything. I would first look at the two minor version upgrades: doctrine/inflector (1.3 -> 1.4) and doctrine/common (2.12 -> 2.13).

But is that really the problem that needs to be solved? Did you look into the foreign key constraint error first?

Yes, I spent some time but there are 376 tables to sort through.  I would rather get to some usable state and migrate the applicable data.

PS.  My hack solution didn't quite get me there as there as expected many missing classes.

Edited by NotionCommotion

With composer you should be keeping your composer.lock file in your version control.  If you upgrade and things don't work out then just revert your composer.lock and composer.json files, delete the entire vendor directory and run composer install and it will re-install whatever versions you previously had specified in the lock file.

Googling your foreign key error seems to indicate a likely cause is column type mis-match.  Maybe one of those updates changed the type of a column from int to bigint or similar.  You'll need to check your different constraints to verify they match.

  • Like 1

Thanks kicken,  Both of your comments helped me.  Never realized the implications of the composer.lock file until now, and will defiantly keep it under version control.  Regarding the FK error, you were right and it turned out to be utf versus utf8mb4.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.