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

CiviCRM Settings can only be overloaded if they are scalars

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.2.0
    • Fix Version/s: 4.2.0
    • Component/s: None
    • Labels:
      None

      Description

      A goal of the CRM_Core_BAO_Setting::getItem() approach to configuration is to allow downstream to specify settings as .php files which can be easily transferred between different CiviCRM instances. Specifically, it allows one to use statements like:

      define('settinggroup.settingname', 'settingvalue');

      This works if the value is a scalar. However, if the value is an array (like with 'mailing_backend'), then it fails.

      Proposal: Update getItems() to also read settings from a global array, e.g.

      $civicrm_setting['settinggroup']['settingname'] = 'settingvalue';

      (I can fix this very quickly – but I wanted to make sure there wasn't some big design consideration.)

      As an example use-case, it would be helpful to unit-test email applications by replacing the normal email handler (SMTP, sendmail, etc) with a mock (in-memory) handler. This could be done by allowing the unit-test to modify the 'mailing_backend' option (for the duration of the test).

      (The patches here are very simple - I'm making a ticket to get a second-opinion on the design.)

        Attachments

          Activity

            People

            • Assignee:
              lobo Donald A. Lobo
              Reporter:
              timotten Tim Otten
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: