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

Overriding CRM_Utils_Array results in PHP Fatal error: Cannot redeclare class CRM_Utils_Array

    Details

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

      Description

      Generally when I backport a patch to a client's site I do so in a PHP or template override. I find it's preferable to hacking core – even if the patch comes in the next release – because overrides provide a very obvious indicator of what's changed.

      In the interests of backporting CRM-16333 to a client's site, I created the corresponding CRM/Utils/Array.php file but got this error:

      PHP Fatal error: Cannot redeclare class CRM_Utils_Array in /var/www/example.org/htdocs/wp-content/civicrm_custom_php/CRM/Utils/Array.php on line 38

      I tried deleting the core file to see what else I could learn. Doing so gives the error:

      PHP Fatal error: Class 'CRM_Utils_Array' not found in /var/www/example.org/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Utils/Cache/ArrayCache.php on line 39

      I haven't looked at how the class autoloader works, but this suggests to me there's some sort of race condition, i.e., the core Array util is loaded, then the autoloader is loaded, then the Array override is loaded.

      I can meet my immediate need by simply patching core, but I thought I'd make a bug report for thoroughness.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated: