fix: prevent preg_replace null from truncating files to 0 bytes
Generic: Repo Health / Site Health (push) Has been cancelled
Universal: Cascade Main → Dev / Cascade main → branches (push) Has been cancelled
Generic: Repo Health / Access control (push) Has been cancelled
Platform: moko-platform CI / Gate 1: Code Quality (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (push) Has been cancelled
Platform: moko-platform CI / Gate 3: Self-Health Check (push) Has been cancelled
Platform: moko-platform CI / Gate 4: Governance (push) Has been cancelled
Platform: moko-platform CI / Gate 5: Template Integrity (push) Has been cancelled
Platform: moko-platform CI / CI Summary (push) Has been cancelled
Generic: Repo Health / Release configuration (push) Has been cancelled
Generic: Repo Health / Scripts governance (push) Has been cancelled
Generic: Repo Health / Repository health (push) Has been cancelled

preg_replace returns null on error. Without a null check, the result
was written to files as empty content, destroying all XML manifests
during the release pipeline.

Added null guards to all file_put_contents calls after preg_replace
in version_set_platform.php, version_check.php, and version_bump.php.

Authored-by: Moko Consulting
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan Miller
2026-05-28 17:01:12 -05:00
parent 14e177f862
commit 23e777d50d
3 changed files with 16 additions and 8 deletions
+7 -3
View File
@@ -125,7 +125,9 @@ if (file_exists($mokoManifest) && !empty($mokoContent)) {
$mokoContent,
1
);
file_put_contents($mokoManifest, $updated);
if ($updated !== null) {
file_put_contents($mokoManifest, $updated);
}
}
// -- Update README.md --
@@ -136,7 +138,9 @@ if (file_exists($readme) && !empty($readmeContent)) {
$readmeContent,
1
);
file_put_contents($readme, $updated);
if ($updated !== null) {
file_put_contents($readme, $updated);
}
}
// -- Cascade to ALL Joomla extension XML manifests --
@@ -160,7 +164,7 @@ foreach ($xmlPatterns as $pattern) {
"<version>{$newFull}</version>",
$content
);
if ($newContent !== $content) {
if ($newContent !== null && $newContent !== $content) {
file_put_contents($xmlFile, $newContent);
$updatedFiles[] = substr($xmlFile, strlen($root) + 1);
}
+8 -4
View File
@@ -99,13 +99,15 @@ if (count($uniqueVersions) === 1) {
// Fix README.md
if (isset($versions['README.md']) && $versions['README.md'] !== $highestVersion) {
$content = file_get_contents($readme);
$content = preg_replace(
$updated = preg_replace(
'/(VERSION:\s*)\d{2}\.\d{2}\.\d{2}/m',
'${1}' . $highestVersion,
$content,
1
);
file_put_contents($readme, $content);
if ($updated !== null) {
file_put_contents($readme, $updated);
}
echo " Fixed: README.md -> {$highestVersion}\n";
}
@@ -118,12 +120,14 @@ if (count($uniqueVersions) === 1) {
if (!file_exists($file)) continue;
$content = file_get_contents($file);
$content = preg_replace(
$updated = preg_replace(
'|<version>[^<]*</version>|',
"<version>{$highestVersion}</version>",
$content
);
file_put_contents($file, $content);
if ($updated !== null) {
file_put_contents($file, $updated);
}
echo " Fixed: {$source} -> {$highestVersion}\n";
}
+1 -1
View File
@@ -152,7 +152,7 @@ if (in_array($platform, ['waas-component', 'joomla'], true)) {
"<version>{$version}</version>",
$content
);
if ($updated !== $content) {
if ($updated !== null && $updated !== $content) {
file_put_contents($file, $updated);
$relPath = str_replace($root . '/', '', $file);
echo "Joomla: {$relPath}{$version}\n";