From d1f60655cf912562ddd38575417c43c0294a3208 Mon Sep 17 00:00:00 2001 From: David Snopek Date: Mon, 7 Aug 2017 09:11:09 -0500 Subject: [PATCH] Use 2nd argument of dirname() and add a comment explaining paths. --- CRM/Core/ClassLoader.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CRM/Core/ClassLoader.php b/CRM/Core/ClassLoader.php index b5025a4e4e..98bcdc82ff 100644 --- a/CRM/Core/ClassLoader.php +++ b/CRM/Core/ClassLoader.php @@ -96,8 +96,13 @@ class CRM_Core_ClassLoader { * @return void */ protected function requireComposerAutoload() { - $civicrm_base_path = dirname(dirname(__DIR__)); - $top_path = dirname(dirname(dirname(dirname(dirname(__DIR__))))); + // We are trying to locate 'vendor/autoload.php'. When installing CiviCRM + // manually from the built tarball, that will be two directories up in the + // civicrm-core directory. However, if civicrm-core was installed via + // composer as a library, that'll be 5 directories up where composer was + // run (ex. the Drupal root on a Drupal 8 site). + $civicrm_base_path = dirname(__DIR__, 2); + $top_path = dirname(__DIR__, 5); if (file_exists($civicrm_base_path . '/vendor/autoload.php')) { require_once $civicrm_base_path . '/vendor/autoload.php'; -- 2.25.1