Skip to content

Commit 2fe2edd

Browse files
committed
fix: whitelist OpenEMR symbols in composer-require-checker
These symbols come from the host OpenEMR application at runtime. openemr/openemr is a dev-only dependency (not declared in require) so the checker must allow them explicitly. Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8170c99 commit 2fe2edd

6 files changed

Lines changed: 21 additions & 7 deletions

File tree

.composer-require-checker.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
"callable",
1515
"iterable",
1616
"void",
17-
"object"
17+
"object",
18+
"attr",
19+
"xlt",
20+
"OpenEMR\\Common\\Crypto\\CryptoGen",
21+
"OpenEMR\\Common\\Database\\QueryUtils",
22+
"OpenEMR\\Events\\Globals\\GlobalsInitializedEvent",
23+
"OpenEMR\\Services\\Globals\\GlobalSetting"
1824
],
1925
"php-core-extensions": [
2026
"Core",

src/ConfigService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class ConfigService
1717
{
1818
private const UPSERT_SQL = <<<'SQL'
1919
INSERT INTO `globals` (`gl_name`, `gl_index`, `gl_value`)
20-
VALUES (?, 0, ?)
21-
ON DUPLICATE KEY UPDATE `gl_value` = VALUES(`gl_value`)
20+
VALUES (?, 0, ?) AS new
21+
ON DUPLICATE KEY UPDATE `gl_value` = new.`gl_value`
2222
SQL;
2323

2424
/**

src/GlobalsRegistrar.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ static function (GlobalsInitializedEvent $event) use ($descriptor, $globalsBag):
4242

4343
// Enable/disable toggle
4444
$enableSetting = new GlobalSetting(
45-
xlt('Enable ' . $descriptor->sectionName),
45+
sprintf(xlt('Enable %s'), $descriptor->sectionName),
4646
GlobalSetting::DATA_TYPE_BOOL,
4747
'0',
48-
xlt('Enable or disable the ' . $descriptor->sectionName . ' module'),
48+
sprintf(xlt('Enable or disable the %s module'), $descriptor->sectionName),
4949
);
5050
$service->appendToSection(
5151
$descriptor->sectionName,

tests/Mocks/openemr_functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ function xlt(string $text): string
1515
if (!function_exists('attr')) {
1616
function attr(string $text): string
1717
{
18-
return htmlspecialchars($text, ENT_QUOTES);
18+
return htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
1919
}
2020
}

tests/Unit/GlobalsRegistrarTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ public function testRegisterAddsListener(): void
3737
$this->assertTrue($dispatcher->hasListeners(GlobalsInitializedEvent::EVENT_HANDLE));
3838
}
3939

40+
protected function tearDown(): void
41+
{
42+
// Clean up global state written by GlobalsService::save()
43+
// phpcs:ignore Squiz.PHP.GlobalKeyword.NotAllowed
44+
global $GLOBALS_METADATA;
45+
$GLOBALS_METADATA = null;
46+
}
47+
4048
/**
4149
* Dispatch the event and return the captured globals metadata.
4250
*

tests/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// Suppress error_log output during tests
99
ini_set('error_log', '/dev/null');
1010

11-
// Load mock classes before anything else to prevent "class not found" errors
11+
// Load mock classes to shadow real OpenEMR classes (must come after autoloader)
1212
require_once __DIR__ . '/Mocks/MockQueryUtils.php';
1313
require_once __DIR__ . '/Mocks/MockCryptoGen.php';
1414
require_once __DIR__ . '/Mocks/openemr_functions.php';

0 commit comments

Comments
 (0)