Forráskód Böngészése

RC3 update packs: Organizations pack finds its module, Messenger config at 15.0.0.DEV

The Organizations 15.0.4 -> 15.0.5 pack named its module 'organizations'.
The module's URI is 'orgs', and every earlier Organizations pack uses that.
BxDolStudioUpdater looks the module up by path and URI, so the update
stopped with "module not found" on every site.

Messenger's own config stayed at 14.0.0.DEV and was compatible with 14.0.0,
while its RC3 pack updates it to 15.0.0. It now reads 15.0.0.DEV and 15.0.x,
like every other module whose config follows its newest pack.

ModuleUpdatePacksTest checks every pack in the repository: module_dir,
module_uri, class_prefix, folder name and home_dir must match the module
it updates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Andrey Yasko 16 órája
szülő
commit
0e26378c98

+ 2 - 2
modules/boonex/messenger/install/config.php

@@ -17,12 +17,12 @@ $aConfig = array(
 	'name' => 'bx_messenger',
 	'title' => 'Messenger',
 	'note' => 'Messenger, instant messages, chat',
-	'version' => '14.0.0.DEV',
+	'version' => '15.0.0.DEV',
 	'vendor' => 'BoonEx',
 	'help_url' => 'http://feed.una.io/?section={module_name}',
 
 	'compatible_with' => array(
-		'14.0.0'
+		'15.0.x'
 	),
 
 	/**

+ 1 - 1
modules/boonex/organizations/updates/15.0.4_15.0.5/install/config.php

@@ -24,7 +24,7 @@ $aConfig = array(
     'home_uri' => 'orgs_update_1504_1505',
 
     'module_dir' => 'boonex/organizations/',
-    'module_uri' => 'organizations',
+    'module_uri' => 'orgs',
 
     'db_prefix' => 'bx_orgs_',
     'class_prefix' => 'BxOrgs',

+ 63 - 0
tests/units/install/ModuleUpdatePacksTest.php

@@ -0,0 +1,63 @@
+<?php
+
+/**
+ * Module update packs (modules/<vendor>/<module>/updates/<from>_<to>/) must name the module they update the way the
+ * installed module is recorded. BxDolStudioUpdater finds the module by `module_dir` and `module_uri`, and builds the
+ * updater class name from `class_prefix`, so a pack that differs from the module's own config fails on every site.
+ */
+class ModuleUpdatePacksTest extends \PHPUnit\Framework\TestCase
+{
+    private static function modulesPath(): string
+    {
+        return __DIR__ . '/../../../modules/';
+    }
+
+    private static function readConfig(string $sPath): array
+    {
+        $aConfig = null;
+        include($sPath);
+        if (!is_array($aConfig))
+            self::fail(substr($sPath, strlen(self::modulesPath())) . ' does not define $aConfig.');
+
+        return $aConfig;
+    }
+
+    public function testPacksMatchTheirModule(): void
+    {
+        $sModules = self::modulesPath();
+        $aPacks = glob($sModules . '*/*/updates/*/install/config.php');
+        $this->assertNotEmpty($aPacks, 'The repository has module update packs.');
+
+        $aModules = [];
+        $aErrors = [];
+        foreach ($aPacks as $sPath) {
+            $sPack = substr(dirname($sPath, 2), strlen($sModules)) . '/';
+            $aPack = self::readConfig($sPath);
+
+            $sModuleDir = $aPack['module_dir'] ?? '';
+            if (strpos($sPack, $sModuleDir . 'updates/') !== 0) {
+                $aErrors[] = "$sPack: module_dir '$sModuleDir' is not the module the pack is in";
+                continue;
+            }
+
+            if (!isset($aModules[$sModuleDir]))
+                $aModules[$sModuleDir] = self::readConfig($sModules . $sModuleDir . 'install/config.php');
+            $aModule = $aModules[$sModuleDir];
+
+            if (($aPack['module_uri'] ?? '') !== $aModule['home_uri'])
+                $aErrors[] = "$sPack: module_uri '" . ($aPack['module_uri'] ?? '') . "' is not the module's home_uri '{$aModule['home_uri']}'";
+
+            if (($aPack['class_prefix'] ?? '') !== $aModule['class_prefix'])
+                $aErrors[] = "$sPack: class_prefix '" . ($aPack['class_prefix'] ?? '') . "' is not the module's '{$aModule['class_prefix']}'";
+
+            $sVersions = ($aPack['version_from'] ?? '') . '_' . ($aPack['version_to'] ?? '');
+            if (basename($sPack) !== $sVersions)
+                $aErrors[] = "$sPack: the folder is not named after version_from and version_to ($sVersions)";
+
+            if (($aPack['home_dir'] ?? '') !== $sModuleDir . 'updates/update_' . $sVersions . '/')
+                $aErrors[] = "$sPack: home_dir '" . ($aPack['home_dir'] ?? '') . "' is not '{$sModuleDir}updates/update_{$sVersions}/'";
+        }
+
+        $this->assertSame([], $aErrors, "Update packs that would not apply:\n" . implode("\n", $aErrors));
+    }
+}