From f69786e464e4f26e86f6dbf6bf728f184d71ccb1 Mon Sep 17 00:00:00 2001 From: Elliott Eggleston Date: Thu, 20 Feb 2020 20:34:13 -0500 Subject: [PATCH] Fix two more php-finding regexes Before: Civi code living under a path containing the characters php (such as ~/src/php/civicrm) will fail to load the API4 explorer with a message like the following: ReflectionException: "Class \Civi\Api4\src does not exist" After: API4 explorer loads no matter what the enclosing path Very similar to PR #16377 --- Civi/Api4/Action/Entity/Get.php | 2 +- Civi/Api4/Action/GetActions.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Civi/Api4/Action/Entity/Get.php b/Civi/Api4/Action/Entity/Get.php index 2b42ea237565..01980abde1fe 100644 --- a/Civi/Api4/Action/Entity/Get.php +++ b/Civi/Api4/Action/Entity/Get.php @@ -58,7 +58,7 @@ protected function getRecords() { if (is_dir($dir)) { foreach (glob("$dir/*.php") as $file) { $matches = []; - preg_match('/(\w*).php/', $file, $matches); + preg_match('/(\w*)\.php$/', $file, $matches); if ( (!$toGet || in_array($matches[1], $toGet)) && is_a('\Civi\Api4\\' . $matches[1], '\Civi\Api4\Generic\AbstractEntity', TRUE) diff --git a/Civi/Api4/Action/GetActions.php b/Civi/Api4/Action/GetActions.php index a1d2b9413272..bb82f93555cb 100644 --- a/Civi/Api4/Action/GetActions.php +++ b/Civi/Api4/Action/GetActions.php @@ -66,7 +66,7 @@ private function scanDir($dir) { if (is_dir($dir)) { foreach (glob("$dir/*.php") as $file) { $matches = []; - preg_match('/(\w*).php/', $file, $matches); + preg_match('/(\w*)\.php$/', $file, $matches); $actionName = array_pop($matches); $actionClass = new \ReflectionClass('\\Civi\\Api4\\Action\\' . $this->_entityName . '\\' . $actionName); if ($actionClass->isInstantiable() && $actionClass->isSubclassOf('\\Civi\\Api4\\Generic\\AbstractAction')) {