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

DB Error when enabling logging

    Details

    • Type: Bug
    • Status: Won't Do
    • Priority: Trivial
    • Resolution: Won't Do
    • Affects Version/s: 4.7.28
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      None
    • Funding Source:
      Needs Funding
    • Verified?:
      No

      Description

      When enabling logging on one CiviCRM instance, i've got the message "DB error" and the logging is not enabled.

      It seems to come from a string replacement that don't work well in my case in CRM/Logging/Schema.php -> fixTimeStampAndNotNullSQL :

      $query = str_ireplace("DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP", '', $query);

      For some reason, in this instance, there is sometimes CURRENT_TIMESTAMP and sometimes CURRENT_TIMESTAMP() – the later is not replaced by the str_ireplace.

      Without trying to understand why it's sometimes a syntax or another, a quick fix is to first replace all CURRENT_TIMESTAMP() to CURRENT_TIMESTAMP before doing the more advanced replacement like so :

      $query = str_ireplace("CURRENT_TIMESTAMP()", "CURRENT_TIMESTAMP", $query);
      $query = str_ireplace("DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP", '', $query);

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                samuelsov Samuel Vanhove
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: