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

Access to angular modules differs depending on whether debug is enabled or not

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.6.11
    • Fix Version/s: 4.7.1
    • Component/s: Core CiviCRM
    • Labels:
    • Documentation Required?:
      None
    • Funding Source:
      Contributed Code

      Description

      I discovered this problem while testing the [Simple Donate] (https://civicrm.org/extensions/simple-donate) however I think the underlying problem is with core.

      When logged out and with CiviCRM's debug config option enabled, I was able to access the angular simple donate page.

      However, when logged out and with CiviCRM debug config option disabled, the page didn't display the fields and the javascript console reported the error: Error: [$injector:modulerr] http://errors.angularjs.org/1.3.20/$injector/modulerr?p0=crmApp....

      The reason for the error is because the js files that are supposed to be loaded (via the hook_civicrm_angularModules function in simpledonate.php) are not loaded for anon users when debug is turned off.

      I traced the error to the Civi/Angular/Page/Main.php and the registerResources method.

      If debug is enabled, it includes each angular js file directly (via the /bower_components path, which is accessible to anonymous users).

      However, if debug is not enabled, then it seems to build an aggregated javascript file and presents it to the user via the /civicrm/ajax/angular-modules path (which is not accessible to anonymous users).

      I'm not sure what the right behavior is. I suspect that extension authors who use the hook_civicrm_angularModules expect their javascript files to be loaded by anonymous users. I also suspect that there is a good reason for the /civicrm/ajax/angular-modules path to be protected. So perhaps there is a different way to aggregate the javascript files?

      In any event - having different privacy behaviors when debug is enabled or disabled seems incorrect.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jamie Jamie McClelland
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: