Java 2 Ada

Symfony cryptic error: Error importing plugins/sfPropelPlugin/lib/propel/builder/SfPeerBuilder.php

By Stephane Carrez 2009-02-08 17:47:49

After the migration to Symfony 1.2, when I wanted to use the command symfony propel:build-model, I was getting the following cryptic error:

>> propel Running "om" phing task phingcall Error importing plugins/sfPropelPlugin/lib/propel/builder/SfPeerBuilder.php Execution of target "om" failed for the following reason: /usr/share/php/symfony/plugins/sfPropelPlugin/lib/vendor/propel-generator/build- propel.xml:465:22: Execution of the target buildfile failed. Aborting. phing /usr/share/php/symfony/plugins/sfPropelPlugin/lib/vendor/propel-generator/build-propel.xml:465:22: Execution of the target buildfile failed. Aborting. Some problems occurred when executing the task: build-propel.xml:465:22: Execution of the target buildfile failed. Aborting. Read the logs to fix them

After searching for some time, I've found that this error comes from a bad definition in my 'config/propel.ini' file. The propel.ini file contained definitions like:

propel.builder.peer.class = plugins.sfPropelPlugin.lib.propel.builder.SfPeerBuilder propel.builder.object.class = plugins.sfPropelPlugin.lib.propel.builder.SfObjectBuilder

And they should be defined as follows:

propel.builder.peer.class = plugins.sfPropelPlugin.lib.builder.SfPeerBuilder propel.builder.object.class = plugins.sfPropelPlugin.lib.builder.SfObjectBuilder

Once the propel configuration was fixed, the symfony command was working again.

If you have this kind of problem, I suggest the following:

  • Create an empty blank application with Symfony (symfony init-app test)
  • Make a diff of the 'config' directory between your application and the blank application
  • Report any suspicious change to fix your configuration
3 comments

Upgrading Symfony projects to release 1.2

By Stephane Carrez 2009-02-01 14:04:35

I had two projects to upgrade on my desktop running Ubuntu 8. The upgrade process is described in Upgrading Projects from 1.1 to 1.2 but even if you follow it, this is really not easy.

Symfony Installation

First, I had to remove a previous symfony installation:

 sudo pear uninstall symfony/symfony

For some reasons, I had still the Propel plugin installed, so I've removed what remains with the command;

 $ sudo rm -rf /usr/share/php/symfony         

Then, I've installed the new Symfony version with pear:

 $ sudo pear install symfony/symfony-1.2.3    

(The Symfony installation is described in Installation 1.2).

Upgrade to 1.2

After Symfony installation, I've started to migrate my applications to the new version. You have to run these commands in each project:

 $ php symfony project:upgrade1.2
 $ php symfony propel:build-model

The prope:build-forms command failed because I had to remove old plugins and update the sfGuardPlugin:

 $ symfony plugin:install sfGuardPlugin
 $ php symfony propel:build-forms
 $ php symfony propel:build-filters

Then clear Symfony cache (the sudo was necessary because some files are owned by www-data user)

 $ sudo php symfony cc

Problems and fixes

Now come the issues!!!. You have to check you application and fix each problem. Unlike Ada or Java, there is no compilation check so every change of API is only detected when you execute the code.

After upgrading, I got this error:

 Fatal error: Call to undefined method DebugPDOStatement::setInt()
  in /home/.../lib/model /AssertViewerPager.php on line 35

This is due to the upgrade of Propel from 1.2 to 1.3. Propel is now using PHP Data Objects, which is a very good thing. The following must be changed:

 $statement = $con->prepareStatement("SELECT ID, VALUE 
                                       FROM Dictionary WHERE KEY = ?");
 $statement->setString(1, $value);
 $rs = $statement->executeQuery();
 while($rs->next()) {
   print "ID: " . $rs->getString("ID") . "  VALUE: " 
           . $rs->getString("VALUE") . "\n";
 }

into

 $statement = $con->prepare("SELECT ID, VALUE 
                                        FROM Dictionary WHERE KEY = ?");
 $statement->bindValue(1, $value);
 $statement->execute();
 while ($row = $statement->fetch()) {
   print "ID: " . $row['ID'] . "  VALUE: " . $row['VALUE'] . "\n";
 }

After fixting the database issues, I found another cryptic error:

 Catchable fatal error: Argument 1 passed to
   sfPatternRouting::configureRoute()
   must be an instance of sfRoute, string given,
  called in /usr/share/php/symfony/routing/
   sfPatternRouting.class.php on line 245 
 and defined in /usr/share/php/symfony/routing 
  /sfPatternRouting.class.php on line 256

It was caused by the sfGuardPlugin which was not updated correctly. I had to remove it and install it from scratch.

Another error caused by the migration:

 Fatal error: Call to undefined method 
   BasePeer::getmapbuilder() 
  in /home/.../lib/model /om/
  BaseLogEmitterPeer.php on line 66

To solve this, I had to remove the 'om' directory and rebuild the model with:

 symfony propel:build-model

There could be other issues that I've not reported... In any case, making sure that everything works after the upgrade is painful.

3 comments
  • Page 1