Search code examples
exceptionpluginssymfony1

sfErrorNotifierPlugin: The "default" context does not exist


I have installed the sfErrorNotifierPlugin. When both options reportErrors/reportPHPErrors reportPHPWarnings/reportWarnings are set to false, everything is ok. But I want to catch PHP exceptions and warnings to receive E-mails, but then all my tasks fail, including clear-cache. After few hours of tests I'm 100% sure that the problem is with set_exception_handler/set_error_handler.

There's a similar question: sfErrorNotifierPlugin on symfony task but the author there is having problems with a custom task. In my case, even built-in tasks fail.


Solution

  • Well, the problem could not be solved this way, unfortunately. Using sfErrorNotifierPlugin, I have enabled reporting PHP warning/errors (apart from symfony exceptions) and this resulted in huge problems, e.g. built-in tasks such as clear-cache failed.

    The solution I chose was to load the plugin only in non-task mode (project configuration class):

      public function setup()
      {
        $this->enableAllPluginsExcept('sfPropelPlugin');
        if ('cli' == php_sapi_name()) $this->disablePlugins('sfErrorNotifierPlugin');
      }
    

    WHen a task is executed, everything works normally. When an app is fired from the browser, emails are sent when exception/warning occurs (maybe someone will find it useful).