THELIA Forum

Welcome to the THELIA support and discusssion forum

Announcement

Rejoignez la communauté sur le Discord Thelia : https://discord.gg/YgwpYEE3y3

Offline


Today when I updated composer i've got major error with propel.

ConnectionException: Unable to open connection

    in /home/michal/thelia/2.0.1/core/vendor/propel/propel/src/Propel/Runtime/Connection/ConnectionFactory.php line 43
    at ConnectionFactory::create(array('dsn' => 'mysql:host=localhost;dbname=thelia;port=3306', 'user' => 'root', 'password' => '', 'classname' => '\Propel\Runtime\Connection\ConnectionWrapper', 'options' => array(array('value' => 'SET NAMES 'UTF8''))), object(MysqlAdapter)) in /home/michal/thelia/2.0.1/core/vendor/propel/propel/src/Propel/Runtime/Connection/ConnectionManagerSingle.php line 76
    at ConnectionManagerSingle->getWriteConnection(object(MysqlAdapter)) in /home/michal/thelia/2.0.1/core/vendor/propel/propel/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php line 339
    at StandardServiceContainer->getWriteConnection('thelia') in /home/michal/thelia/2.0.1/core/vendor/propel/propel/src/Propel/Runtime/ServiceContainer/StandardServiceContainer.php line 321
    at StandardServiceContainer->getConnection('thelia', 'write') in /home/michal/thelia/2.0.1/core/vendor/propel/propel/src/Propel/Runtime/Propel.php line 204
    at Propel::getConnection('thelia') in /home/michal/thelia/2.0.1/core/lib/Thelia/Core/Thelia.php line 73
    at Thelia->initPropel() in /home/michal/thelia/2.0.1/core/lib/Thelia/Core/Thelia.php line 57
    at Thelia->init() in /home/michal/thelia/2.0.1/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php line 92
    at Kernel->__construct('dev', true) in /home/michal/thelia/2.0.1/web/index_dev.php line 30

Error apperas beacuse of propel version:
"propel/propel": "2.0.*@dev"

Everything is fine only on propel version:
"propel/propel": "2.0.0-alpha2"

Besides of that. For example in many base models like \Thelia\Model\Base\ProductQuery.php
there is a function like:

public function findPk($key, $con = null)
    {
        if ($key === null) {
            return null;
        }
        if ((null !== ($obj = ProductTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
            // the object is already in the instance pool
            return $obj;
        }
        if ($con === null) {
            $con = Propel::getServiceContainer()->getReadConnection(ProductTableMap::DATABASE_NAME);
        }
        $this->basePreSelect($con);
        if ($this->formatter || $this->modelAlias || $this->with || $this->select
         || $this->selectColumns || $this->asColumns || $this->selectModifiers
         || $this->map || $this->having || $this->joins) {
            return $this->findPkComplex($key, $con);
        } else {
            return $this->findPkSimple($key, $con);
        }
    }

in propel >= 2.0.3
this function looks like this:

public function findPk($key, ConnectionInterface $con = null)
    {
        if (null === $con) {
            $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
        }

        // As the query uses a PK condition, no limit(1) is necessary.
        $this->basePreSelect($con);
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $pkCols = array_values($this->getTableMap()->getPrimaryKeys());
        if (1 === count($pkCols)) {
            // simple primary key
            $pkCol = $pkCols[0];
            $criteria->add($pkCol->getFullyQualifiedName(), $key);
        } else {
            // composite primary key
            foreach ($pkCols as $pkCol) {
                $keyPart = array_shift($key);
                $criteria->add($pkCol->getFullyQualifiedName(), $keyPart);
            }
        }
        $dataFetcher = $criteria->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
    }

look at the method arugments. PHP will return error on every method that's not fits to it's parent.

  • manu
  • faï tot petar miladiu

Offline


Hello,

never ever use composer update command, use composer install or if you need a new dependency use composer require.

You have to rollback with the previous version of composer.lock file and run composer install.

We are looking for fixing composer.json file.


http://doc.thelia.net/
http://thelia.net/modules
http://raynaud.io
PGP public Key : 0xC6E546A6