Pez Cuckow
Pez Cuckow

Reputation: 14422

Propel Data Load - "default" context does not exist

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?

Upvotes: 2

Views: 1480

Answers (3)

cyber cyber1621
cyber cyber1621

Reputation: 167

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

Upvotes: 1

yellottyellott
yellottyellott

Reputation: 985

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

Upvotes: 1

Pez Cuckow
Pez Cuckow

Reputation: 14422

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

Upvotes: 1

Related Questions