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

Constant CIVICRM_MYSQL_STRICT and associated logic obfuscate debugging

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 4.7.25
    • Fix Version/s: None
    • Component/s: Core CiviCRM
    • Labels:
      None
    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      None
    • Funding Source:
      Needs Funding
    • Verified?:
      No

      Description

      Background

      See VOL-299, in particular this comment and the one that follows it, to see how this feature, which I think is supposed to facilitate debugging (or at least encourage good coding practices), makes reproducing a reported bug very difficult.

      Summary

      CiviCRM uses a constant CIVICRM_MYSQL_STRICT to toggle some "strict" SQL behavior. If the constant is not defined, CiviCRM uses a method CRM_Utils_System::isDevelopment() to toggle the behavior. I haven't investigated this thoroughly, but in at least two cases, setting this flag causes the global database configuration for sql_mode to be overridden, making it very difficult to debug errors with reproduction steps such as:

      • Set your global MySQL config so that sql_mode is set to X.
      • Perform these actions in your browser.

      Recommendation

      Instead of blindly overriding sql_mode, CiviCRM should inspect the setting and make changes to it according to whatever development behaviors we are trying to encourage: enable mode X, disabling mode Y, etc.

      We are already doing this better in at least one other part of the code base, but the approach appears to be ad hoc. Likewise, recent work in core seems like it could be better encapsulated in a utility class so we don't have to do the same string gymnastics all over the code base.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pittstains Frank J. Gómez
                Reporter:
                pittstains Frank J. Gómez
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: