Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-15683

preProcess hook doesn't allow you to circumvent fatal errors

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.4.9
    • Fix Version/s: 4.6
    • Component/s: None
    • Labels:
      None
    • Documentation Required?:
      Developer Doc

      Description

      At the moment the preProcess hook is an option but if CiviCRM preProcess throws a fatal then the preProcess hook is never called. The problem here is that disabled contribution pages result in

      "Sorry but we are not able to provide this at the moment.
      The page you requested is currently unavailable.

      Return to home page."

      However, we can't 'get to it' with a hook to do something sensible instead. (redirect according to business rules so as not to lose the donor)

      My thinking is that we could replace

      // check if form is active
      if (empty($this->_values['is_active']))

      { // form is inactive, die a fatal death CRM_Core_Error::fatal(ts('The page you requested is currently unavailable.')); }

      with

      throw new CRM_Core_Exception(ts('The page you requested is currently unavailable.');

      and the calling code could look like

      function buildForm() {
      $this->_formBuilt = TRUE;
      try

      { $this->preProcess(); }

      catch (CRM_Core_Exception $e)

      { //call hook in case it redirects (or a new hook) CRM_Utils_Hook::preProcess(get_class($this), $this); CRM_Core_Fatal($e->getMessage); }

      CRM_Utils_Hook::preProcess(get_class($this), $this);

        Attachments

          Activity

            People

            • Assignee:
              eileen Eileen McNaughton
              Reporter:
              eileen Eileen McNaughton
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: