开发者

Propel Data Load - "default" context does not exist

开发者 https://www.devze.com 2023-03-21 14:42 出处:网络
I am currently stuck on the error The \"default\" context does not exist. when trying to build my data model with the command symfony propel:build --application=frontend --all --and-load --no-confirma

I am currently stuck on the error The "default" context does not exist. when trying to build my data model with the command symfony propel:build --application=frontend --all --and-load --no-confirmation

After lots of Googling it appears this error is caused by using sfContext inside a model or a form so I have found these and commented them out (see below), the error still occurs, does anyone else know a fix?

>> file-     /var/www/html/dev/meeting/config/generated-sfGuardPlugin-schema.xml
>> file-     /var/www/html/dev/meeting/config/generated-schema.xml
>> propel    load data from "/var/www/html/dev/meeting/data/fixtures"
>> propel    load data from "/var/www/html/dev/meeting/plugins/sfGuardPlugin/data/fixtures"

  The "default" context does not exist. 

grep -R sfContext lib/model/*
lib/model/MeetingMeetings.php:    return "";//sfContext::getInstance()->getController()->genUrl('meeting/show?id='.$this->getId(), $full);
lib/model/sfGuardUserProfile.php:    //if(!is_null(sfContext::getInstance())&&($useYou||$useYourself)&&$this->getUserId()==sfContext::getInstance()->getUser()->getId()) {

grep -R sfContext lib/form/*
lib/form/MeetingMeetingsForm开发者_开发百科.class.php:      //sfContext::getInstance()->getUser()->setFlash("info",

Many thanks for your time,


Not sure what information I can provide, does anyone have any other questions?


I resolved this problem by doing the following.

First find all references to sfContext in your model files and find an alternative way to get what ever sfContext was needed for (for example passing it to the method).

Check all library files mentioned inside any models for use of sfContext, repeat above solution.

Use is_null checks on sfContexts where it has to exist so it only does if it required.

The problem in my case was my save method used another library which used sfContext to get the current user, which obviously doesn't exist when inserting data to the model


Just ran into this today with data-load. Instead of modifying the function signature, here's what I did.

if(!sfContext::hasInstance())
  $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'cache', true);
else
  $configuration = sfContext::getInstance()->getConfiguration();

And then I can run stuff like this in my model classes.

$configuration->loadHelpers('Texturizer');

I'm not sure what the 'cache' parameter does in getApplicationConfiguration, but I found that line off of the Jobeet book here http://www.symfony-project.org/jobeet/1_4/Propel/en/21


To resolve the problem quickly, comment the code /lib/form/baseForm.class.php , generate the module, and restores the code

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号