propelorm / PropelBundle

PropelBundle for Symfony.
http://propelorm.org/Propel/documentation/#working-with-symfony2
180 stars 156 forks source link

Profiler broken in PropelBundle 1.5.1 #430

Closed ghost closed 7 years ago

ghost commented 8 years ago

Hey,

I've this in my config:

# Propel Configuration
propel:
    dbal:
        default_connection: foo
        connections:
            foo:
                driver: mysql
                user: %database_user%
                password: %database_password%
                dsn: mysql:host=%database_host%;dbname=%database_name%;charset=UTF8
                options: {}
                attributes: {}

If I try to open the profiler, there is an error:

Impossible to access an attribute ("adapter") on a string variable ("foo") in PropelBundle:Panel:configuration.html.twig at line 45

When I specify the adapter instead of the driver there is another error:

Unrecognized option "adapter" under "propel.dbal.connections.foo"

What could be the reason for this?

propel/propel-bundle 1.5.1 Integration of Propel in Symfony2
propel/propel1 1.7.1 Propel is an open-source Object-Relational Mapping (ORM) for PHP5.
symfony/symfony v2.8.8 The Symfony PHP framework

Can anyone help?

Best, Christian

marcj commented 8 years ago

I don't think old Propel is compatible with new Symfony 2.8.8.

ghost commented 8 years ago

Which version should I choose? I just did a composer require propel/propel-bundle. The Version was choosed automatically.

ghost commented 8 years ago

I switched back to PropelBundle 1.4.5. Error is gone now and profiler is working again. Anyway, I'll leave this open.

marcj commented 8 years ago

When possible upgrade to v2.

ghost commented 8 years ago

Unfortunately, not possible. :/ v2 is not compatible with FOSUserBundle.

nibsirahsieu commented 8 years ago

PR #429 should fix this issue.

For a while, you should rename your foo connection by default.

propel:
    dbal:
        default_connection: default
        connections:
            default:
                driver: mysql
                user: %database_user%
                password: %database_password%
                dsn: mysql:host=%database_host%;dbname=%database_name%;charset=UTF8
                options: {}
                attributes: {}
ghost commented 8 years ago

@nibsirahsieu You are right. This fixes the bug. Anyway, I'll leave this open until #429 is merged.

ghost commented 8 years ago

@nibsirahsieu No, I'm wrong. This leads to an error:

Get a No connection information in your runtime configuration file for datasource [main] everytime I request my database.

Do you know more about that?

From propel/propel1/runtime/lib/Propel.php

public static function getMasterConnection($name) // $name is 'main'
{

If I switch back to 'main', then things are fine, but the profiler is not working as expected.

Seems that they are relying on a datasources config param:

/**
 * Returns the name of the default database.
 *
 * @return string Name of the default DB
 */
public static function getDefaultDB()
{
    if (self::$defaultDBName === null) {
        // Determine default database name.
        self::$defaultDBName = isset(self::$configuration['datasources']['default']) && is_scalar(self::$configuration['datasources']['default']) ? self::$configuration['datasources']['default'] : self::DEFAULT_NAME;
    }

    return self::$defaultDBName;
}

How to configure this?

nibsirahsieu commented 8 years ago

it seems you forgot to change the database name in your schema file

nibsirahsieu commented 8 years ago

and don't forget to rebuild your models

ghost commented 8 years ago

Ahh, you are right. I did what you said and now it's working like a charm. Should I close this issue or wait until the PR is merged?

nibsirahsieu commented 8 years ago

no, just leave it open.