diff --git a/CHANGELOG.md b/CHANGELOG.md index d19ad9c3ee3..ed46e4083e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- Fixed a bug where the control panel could display a notice about the Craft CMS license belonging to a different domain, even when accessing the control panel from the correct domain. ([#16396](https://github.com/craftcms/cms/issues/16396)) - Fixed a bug where field layout elements’ action menus could have an empty action group. ## 5.5.9 - 2025-01-06 diff --git a/src/base/ApplicationTrait.php b/src/base/ApplicationTrait.php index c5283a76602..4666726f5f8 100644 --- a/src/base/ApplicationTrait.php +++ b/src/base/ApplicationTrait.php @@ -619,7 +619,7 @@ public function getEditionHandle(): string */ public function getLicensedEdition(): ?CmsEdition { - $licenseInfo = $this->getCache()->get('licenseInfo') ?: []; + $licenseInfo = $this->getCache()->get(App::licenseInfoCacheKey()) ?: []; if (!isset($licenseInfo['craft']['edition'])) { return null; diff --git a/src/base/FieldInterface.php b/src/base/FieldInterface.php index 39c7631caeb..bf05ff7bf93 100644 --- a/src/base/FieldInterface.php +++ b/src/base/FieldInterface.php @@ -315,9 +315,9 @@ public function useFieldset(): bool; public function getInputHtml(mixed $value, ?ElementInterface $element): string; /** - * Returns a static (non-editable) version of the field’s input HTML. + * Returns a read-only version of the field’s input HTML. * - * This function is called to output field values when viewing element drafts. + * This method is called to output field values when viewing element revisions. * * @param mixed $value The field’s value * @param ElementInterface $element The element the field is associated with diff --git a/src/helpers/Api.php b/src/helpers/Api.php index 4a5b76aa5ee..3bf39761f20 100644 --- a/src/helpers/Api.php +++ b/src/helpers/Api.php @@ -206,7 +206,8 @@ public static function processResponseHeaders(array $headers): void // license info if (isset($headers['x-craft-license-info'])) { - $oldLicenseInfo = $cache->get('licenseInfo') ?: []; + $licenseInfoCacheKey = App::licenseInfoCacheKey(); + $oldLicenseInfo = $cache->get($licenseInfoCacheKey) ?: []; $licenseInfo = []; $allCombinedInfo = array_filter(explode(',', reset($headers['x-craft-license-info']))); foreach ($allCombinedInfo as $combinedInfo) { @@ -235,7 +236,7 @@ public static function processResponseHeaders(array $headers): void 'timestamp' => $timestamp, ]; } - $cache->set('licenseInfo', $licenseInfo, $duration); + $cache->set($licenseInfoCacheKey, $licenseInfo, $duration); } } diff --git a/src/helpers/App.php b/src/helpers/App.php index 0ca7b5033e4..f30e65de242 100644 --- a/src/helpers/App.php +++ b/src/helpers/App.php @@ -1295,6 +1295,21 @@ public static function createFormattingLocale(): Locale return Craft::$app->getLocale(); } + /** + * Returns the cache key that licensing info should be stored with. + * + * @return string + * @internal + */ + public static function licenseInfoCacheKey(): string + { + $request = Craft::$app->getRequest(); + if ($request->getIsConsoleRequest()) { + return 'licenseInfo'; + } + return sprintf('licenseInfo@%s', $request->getHostName()); + } + /** * Returns all known licensing issues. * @@ -1312,7 +1327,8 @@ public static function licensingIssues(bool $withUnresolvables = true, bool $fet $updatesService = Craft::$app->getUpdates(); $cache = Craft::$app->getCache(); - $isInfoCached = $cache->exists('licenseInfo') && $updatesService->getIsUpdateInfoCached(); + $licenseInfoCacheKey = static::licenseInfoCacheKey(); + $isInfoCached = $cache->exists($licenseInfoCacheKey) && $updatesService->getIsUpdateInfoCached(); if (!$isInfoCached) { if (!$fetch) { @@ -1324,7 +1340,7 @@ public static function licensingIssues(bool $withUnresolvables = true, bool $fet $issues = []; - $allLicenseInfo = $cache->get('licenseInfo') ?: []; + $allLicenseInfo = $cache->get($licenseInfoCacheKey) ?: []; $pluginsService = Craft::$app->getPlugins(); $generalConfig = Craft::$app->getConfig()->getGeneral(); $consoleUrl = rtrim(Craft::$app->getPluginStore()->craftIdEndpoint, '/'); diff --git a/src/services/Plugins.php b/src/services/Plugins.php index 842a7ff2cec..567fcdba0cc 100644 --- a/src/services/Plugins.php +++ b/src/services/Plugins.php @@ -1013,7 +1013,7 @@ public function getPluginInfo(string $handle): array $info['hasCpSettings'] = ($plugin !== null && $plugin->hasCpSettings); $info['licenseKey'] = $pluginInfo['licenseKey'] ?? null; - $licenseInfo = Craft::$app->getCache()->get('licenseInfo') ?? []; + $licenseInfo = Craft::$app->getCache()->get(App::licenseInfoCacheKey()) ?? []; $pluginCacheKey = StringHelper::ensureLeft($handle, 'plugin-'); $info['licenseId'] = $licenseInfo[$pluginCacheKey]['id'] ?? null; $info['licensedEdition'] = $licenseInfo[$pluginCacheKey]['edition'] ?? null; @@ -1195,10 +1195,11 @@ public function setPluginLicenseKey(string $handle, ?string $licenseKey = null): // Clear the plugin's cached license key status $cache = Craft::$app->getCache(); - $licenseInfo = $cache->get('licenseInfo') ?? []; + $cacheKey = App::licenseInfoCacheKey(); + $licenseInfo = $cache->get($cacheKey) ?? []; if (isset($licenseInfo[$handle])) { unset($licenseInfo[$handle]); - $cache->set('licenseInfo', $licenseInfo); + $cache->set($cacheKey, $licenseInfo); } return true; diff --git a/src/web/twig/variables/Cp.php b/src/web/twig/variables/Cp.php index 9e191897377..de6266dd1fb 100644 --- a/src/web/twig/variables/Cp.php +++ b/src/web/twig/variables/Cp.php @@ -505,7 +505,7 @@ public function settings(): array public function areAlertsCached(): bool { // The license key status gets cached on each Craftnet request - return (Craft::$app->getCache()->get('licenseInfo') !== false); + return (Craft::$app->getCache()->get(App::licenseInfoCacheKey()) !== false); } /**