Merge pull request #5118 from totten/master-mgdent-test
[civicrm-core.git] / CRM / Core / Invoke.php
index 531954ede60a4e604082946e9558dfd571f3eb95..3a50bfe161c4ec64a7a5bf7dbfda9e709c3d9278 100644 (file)
@@ -72,6 +72,10 @@ class CRM_Core_Invoke {
     if ($args[0] !== 'civicrm') {
       return NULL;
     }
+    // CRM-15901: Turn off PHP errors display for all ajax calls
+    if (CRM_Utils_Array::value(1, $args) == 'ajax' || CRM_Utils_Array::value('snippet', $_REQUEST)) {
+      ini_set('display_errors', 0);
+    }
 
     if (!defined('CIVICRM_SYMFONY_PATH')) {
       // Traditional Civi invocation path
@@ -121,7 +125,7 @@ class CRM_Core_Invoke {
   }
 
   /**
-   * Perform general setup
+   * Perform general setup.
    *
    * @param array $args
    *   List of path parts.
@@ -267,12 +271,11 @@ class CRM_Core_Invoke {
       }
 
       $result = NULL;
-      if (is_array($item['page_callback'])) {
-        if ($item['page_callback']{0} !== '\\') {
-          // Legacy class-loading for PHP 5.2 namespaces; not sure it's needed, but counter-productive for PHP 5.3 namespaces
-          require_once str_replace('_', DIRECTORY_SEPARATOR, $item['page_callback'][0]) . '.php';
-        }
-        $result = call_user_func($item['page_callback']);
+      // WISHLIST: Refactor this. Instead of pattern-matching on page_callback, lookup
+      // page_callback via Civi\Core\Resolver and check the implemented interfaces. This
+      // would require rethinking the default constructor.
+      if (is_array($item['page_callback']) || strpos($item['page_callback'], ':')) {
+        $result = call_user_func(Civi\Core\Resolver::singleton()->get($item['page_callback']));
       }
       elseif (strstr($item['page_callback'], '_Form')) {
         $wrapper = new CRM_Utils_Wrapper();
@@ -284,10 +287,6 @@ class CRM_Core_Invoke {
       }
       else {
         $newArgs = explode('/', $_GET[$config->userFrameworkURLVar]);
-        if ($item['page_callback']{0} !== '\\') {
-          // Legacy class-loading for PHP 5.2 namespaces; not sure it's needed, but counter-productive for PHP 5.3 namespaces
-          require_once str_replace('_', DIRECTORY_SEPARATOR, $item['page_callback']) . '.php';
-        }
         $mode = 'null';
         if (isset($pageArgs['mode'])) {
           $mode = $pageArgs['mode'];
@@ -323,7 +322,7 @@ class CRM_Core_Invoke {
   }
 
   /**
-   * This function contains the default action
+   * This function contains the default action.
    *
    * @param $action
    *
@@ -345,7 +344,7 @@ class CRM_Core_Invoke {
   }
 
   /**
-   * Show the message about CiviCRM versions
+   * Show the message about CiviCRM versions.
    *
    * @param CRM_Core_Smarty $template
    */