Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

propel SQLDiffTasks returns adapter error #741

Closed
eelkevdbos opened this issue Aug 18, 2013 · 10 comments
Closed

propel SQLDiffTasks returns adapter error #741

eelkevdbos opened this issue Aug 18, 2013 · 10 comments

Comments

@eelkevdbos
Copy link

SQLDiffTasks returns an error. On line 112 of SQLDiffTasks.php the method hasPendingMigrations gets called. This fires eventually the initConnection method inside Propel.php without the Propel class being initialized by the init method. Without initializing, the self::$configuration stays empty and the correct adapter configurations cannot be read. This will throw an Exception on getDB line 756.

We're using propel 1.7.*@dev and postgresql 9.1. My suggestion would be to check wether the Propel class has been initiated in the getDB or the initConnection method and if not, initialize it.

I haven't worked out a solution myself because I don't know how to link to the generic path of the compiled php configuration file. Otherwise, I would ammend the methods mentioned above with 3 lines of code:

if(!self::isInit())) {
    self::init($genericPathToCompiledConfigFileHere);
}
@staabm
Copy link
Member

staabm commented Aug 18, 2013

Seems to be the fix for #725 (comment)

@eelkevdbos
Copy link
Author

We only need a propel-guru to find us the method to reference the compiled php configuration file. Some builder classes seem to have access to it.

@eelkevdbos
Copy link
Author

Does anyone know how to link the compiled php buildtime configuration file? That would be a real lifesafer!

@ghost
Copy link

ghost commented Oct 21, 2013

Hi all,
I Had the same problem using propel-gen diff with mysql adapter. Also, the class PropelSQLDiffTask could not call Propel::init because the file wasn't included

I solve the "propel" problem putting

require_once dirname(__FILE__) . '/../../../runtime/lib/Propel.php';

at the top of the PropelSQLDiffTask class file

for loading and initializing propel, I modified my build.properties file writing

propel.diff.runtimeconf = /path/to/my/runtimeconf.php

and then in the main of PropelSQLDiffTask I put this snippet

if (!Propel::isInit()) {
            Propel::init($generatorConfig->getBuildProperty("diffRuntimeconf"));
}

just after the $generatorConfig = $this->getGeneratorConfig(); command.

Hope this help.

Dany

@ghost
Copy link

ghost commented Oct 21, 2013

idem the same thing in class PropelMigrationTask

@tacone
Copy link

tacone commented Dec 27, 2013

Experiencing the same problem with mysql on 1.7.1-dev and 1.7.0.

Works as expected with 1.6.9

@exptom
Copy link
Contributor

exptom commented Jan 7, 2014

I'm also getting this same problem in 1.7.0.
1.6.9 works correctly.

@chbiel
Copy link

chbiel commented Feb 4, 2014

Is there an update on this issue? Migration and Diff task are not usable anymore but there is no good fix found yet

@eelkevdbos
Copy link
Author

I dont know how to write tests for this specific case, so generally there will be no fix accepted. I have a solution though that will work.

On line 652 of Propel.php:

$adapter = isset($conparams['adapter']) ? DBAdapter::factory($conparams['adapter']) : self::getDB($name);

Will do the trick. If there is anyone that can write a test that will expose the problem in version 1.7.1-dev and will fix it with this line, it would be really great. Right now, im considering just to fork 1.7.1-dev and apply the fix.

@tacone
Copy link

tacone commented Feb 4, 2014

Last time I looked in Propel's tests I could not wrap my head around them. They just felt like a big mess to me.
You may try to submit a pull request anyway asking mantainers to write the test themselves.

eelkevdbos added a commit to eelkevdbos/Propel that referenced this issue Feb 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants