From 733f2b353ccbed7994c7ef1aa911b53dd06ca3c1 Mon Sep 17 00:00:00 2001 From: Elliott Eggleston Date: Fri, 24 Jan 2020 16:28:57 -0500 Subject: [PATCH] loadServices: tighten up file match regex Before: Civi code living under a path containing the characters php (such as ~/src/php/civicrm) will crash trying to load services with a message like the following: ReflectionException: Class Civi\Api4\Service\Spec\Provider\src does not exist in ReflectionClass->__construct() After: Civi loads services normally no matter what the enclosing path --- CRM/Api4/Services.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CRM/Api4/Services.php b/CRM/Api4/Services.php index 95fd4a2202..ec8190348c 100644 --- a/CRM/Api4/Services.php +++ b/CRM/Api4/Services.php @@ -86,7 +86,7 @@ class CRM_Api4_Services { $container->addResource($resource); foreach (glob("$path*.php") as $file) { $matches = []; - preg_match('/(\w*).php/', $file, $matches); + preg_match('/(\w*)\.php$/', $file, $matches); $serviceName = $namespace . array_pop($matches); $serviceClass = new \ReflectionClass($serviceName); if ($serviceClass->isInstantiable()) { -- 2.25.1