From 65ad1454b1dc8325e0d119a0f5520472bf214b43 Mon Sep 17 00:00:00 2001 From: benjamin Date: Tue, 11 Feb 2025 09:10:59 +0000 Subject: [PATCH 1/6] Riverlea rollout - enable Riverlea ext by default from 6.1 --- CRM/Upgrade/Incremental/php/SixOne.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CRM/Upgrade/Incremental/php/SixOne.php b/CRM/Upgrade/Incremental/php/SixOne.php index 2d302894495d..da53fb2ad64a 100644 --- a/CRM/Upgrade/Incremental/php/SixOne.php +++ b/CRM/Upgrade/Incremental/php/SixOne.php @@ -31,6 +31,8 @@ public function upgrade_6_1_alpha1($rev): void { $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); $this->addTask('Replace Clear Caches & Reset Paths with Clear Caches in Nav Menu', 'updateUpdateConfigBackendNavItem'); + + $this->addExtensionTask('Enable Riverlea extension', ['riverlea']); } /** From 2c063eae5b61a3035ae192234b6f1083d3ed665c Mon Sep 17 00:00:00 2001 From: benjamin Date: Fri, 7 Feb 2025 10:19:20 +0000 Subject: [PATCH 2/6] Riverlea rollout - freeze upgrading sites with Automatic to Greenwich --- CRM/Upgrade/Incremental/php/SixOne.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CRM/Upgrade/Incremental/php/SixOne.php b/CRM/Upgrade/Incremental/php/SixOne.php index da53fb2ad64a..52015adfb9e6 100644 --- a/CRM/Upgrade/Incremental/php/SixOne.php +++ b/CRM/Upgrade/Incremental/php/SixOne.php @@ -33,6 +33,28 @@ public function upgrade_6_1_alpha1($rev): void { $this->addTask('Replace Clear Caches & Reset Paths with Clear Caches in Nav Menu', 'updateUpdateConfigBackendNavItem'); $this->addExtensionTask('Enable Riverlea extension', ['riverlea']); + $this->addTask('Freeze "default" theme to Greenwich', 'freezeDefaultThemeToGreenwich'); + } + + /** + * 'default' is being removed as a valid theme choice. + * + * It has always meant Greenwich, so sites previously on + * "default" change this to an explicit value Greenwich. + * + * @return bool + */ + public static function freezeDefaultThemeToGreenwich() { + $themeSettings = ['theme_backend', 'theme_frontend']; + + foreach ($themeSettings as $key) { + $value = \Civi::settings()->get($key); + if ($value === 'default') { + \Civi::settings()->set($key, 'greenwich'); + } + } + + return TRUE; } /** From a1de54f98e4d923b06b969efa253de8ccc889c87 Mon Sep 17 00:00:00 2001 From: benjamin Date: Fri, 7 Feb 2025 11:14:27 +0000 Subject: [PATCH 3/6] Riverlea rollout - remove Themes::DEFAULT_THEME --- Civi/Core/Themes.php | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/Civi/Core/Themes.php b/Civi/Core/Themes.php index 05469ba93710..914eee8ba325 100644 --- a/Civi/Core/Themes.php +++ b/Civi/Core/Themes.php @@ -22,10 +22,10 @@ class Themes extends \Civi\Core\Service\AutoService { /** - * The "default" theme adapts based on the latest recommendation from civicrm.org - * by switching to DEFAULT_THEME at runtime. + * No theme only uses core CSS. It is what you get if your theme is set to an + * unavailable theme. */ - const DEFAULT_THEME = 'greenwich'; + const NO_THEME = 'none'; /** * Fallback is a pseudotheme which can be included in "search_order". @@ -68,13 +68,18 @@ public function __construct($cache = NULL) { */ public function getActiveThemeKey() { if ($this->activeThemeKey === NULL) { - // Ambivalent: is it better to use $config->userFrameworkFrontend or $template->get('urlIsPublic')? - $config = \CRM_Core_Config::singleton(); - $settingKey = $config->userSystem->isFrontEndPage() ? 'theme_frontend' : 'theme_backend'; + $settingKey = \CRM_Utils_System::isFrontEndPage() ? 'theme_frontend' : 'theme_backend'; $themeKey = Civi::settings()->get($settingKey); + + // catch for if 'default' value has stuck around. for as long as anyone + // can remember default meant Greenwich + // TODO: remove this catch around 6.12? if ($themeKey === 'default') { - $themeKey = self::DEFAULT_THEME; + \Civi::log()->debug("Warning: found deprecated value 'default' for '{$settingKey}'. This will be interpreted as Greenwich but this handling may be removed in a future release."); + // fix it for you? + // Civi::settings()->set($settingKey, 'greenwich'); + $themeKey = 'greenwich'; } \CRM_Utils_Hook::activeTheme($themeKey, [ @@ -83,7 +88,7 @@ public function getActiveThemeKey() { ]); $themes = $this->getAll(); - $this->activeThemeKey = isset($themes[$themeKey]) ? $themeKey : self::DEFAULT_THEME; + $this->activeThemeKey = isset($themes[$themeKey]) ? $themeKey : self::NO_THEME; } return $this->activeThemeKey; } @@ -196,18 +201,7 @@ public function resolveUrls($active, $cssExt, $cssFile) { */ protected function buildAll() { $themes = [ - 'default' => [ - 'ext' => 'civicrm', - 'title' => ts('Automatic'), - 'help' => ts('Determine a system default automatically'), - // This is an alias. url_callback, search_order don't matter. - ], - 'greenwich' => [ - 'ext' => 'civicrm', - 'title' => 'Greenwich', - 'help' => ts('CiviCRM 4.x look-and-feel'), - ], - 'none' => [ + self::NO_THEME => [ 'ext' => 'civicrm', 'title' => ts('None (Unstyled)'), 'help' => ts('Disable CiviCRM\'s built-in CSS files.'), From e7921432e204279851792a061aa392892d28f679 Mon Sep 17 00:00:00 2001 From: benjamin Date: Fri, 7 Feb 2025 10:20:43 +0000 Subject: [PATCH 4/6] Riverlea rollout - add NO_THEME, make default for theme settings --- Civi/Core/Themes.php | 21 +++++++++++++++------ settings/Core.setting.php | 4 ++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Civi/Core/Themes.php b/Civi/Core/Themes.php index 914eee8ba325..ea681c887e54 100644 --- a/Civi/Core/Themes.php +++ b/Civi/Core/Themes.php @@ -22,10 +22,14 @@ class Themes extends \Civi\Core\Service\AutoService { /** - * No theme only uses core CSS. It is what you get if your theme is set to an - * unavailable theme. + * Disable core CSS. */ - const NO_THEME = 'none'; + const NO_STYLES = 'none'; + + /** + * Core CSS only. + */ + const NO_THEME = 'no_theme'; /** * Fallback is a pseudotheme which can be included in "search_order". @@ -201,16 +205,21 @@ public function resolveUrls($active, $cssExt, $cssFile) { */ protected function buildAll() { $themes = [ - self::NO_THEME => [ + self::NO_STYLES => [ 'ext' => 'civicrm', - 'title' => ts('None (Unstyled)'), + 'title' => ts('No Styles'), 'help' => ts('Disable CiviCRM\'s built-in CSS files.'), - 'search_order' => ['none', self::FALLBACK_THEME], + 'search_order' => [self::NO_STYLES, self::FALLBACK_THEME], 'excludes' => [ "css/civicrm.css", "css/bootstrap.css", ], ], + self::NO_THEME => [ + 'ext' => 'civicrm', + 'title' => ts('No Theme'), + 'search_order' => [self::NO_THEME, self::FALLBACK_THEME], + ], self::FALLBACK_THEME => [ 'ext' => 'civicrm', 'title' => 'Fallback (Abstract Base Theme)', diff --git a/settings/Core.setting.php b/settings/Core.setting.php index d604f723877d..cdcc96eee877 100644 --- a/settings/Core.setting.php +++ b/settings/Core.setting.php @@ -1184,7 +1184,7 @@ 'pseudoconstant' => array( 'callback' => 'call://themes/getAvailable', ), - 'default' => 'default', + 'default' => 'no_theme', 'add' => '5.16', 'title' => ts('Frontend Theme'), 'is_domain' => 1, @@ -1209,7 +1209,7 @@ 'pseudoconstant' => array( 'callback' => 'call://themes/getAvailable', ), - 'default' => 'default', + 'default' => 'no_theme', 'add' => '5.16', 'title' => ts('Backend Theme'), 'is_domain' => 1, From 9dac61328519131e61e61995ceff0b637ea08fe2 Mon Sep 17 00:00:00 2001 From: benjamin Date: Thu, 6 Feb 2025 16:36:35 +0000 Subject: [PATCH 5/6] Riverlea rollout - unhide Greenwich (can be disabled now) --- ext/greenwich/info.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/ext/greenwich/info.xml b/ext/greenwich/info.xml index 09b82eff3095..9bbea1b9b746 100644 --- a/ext/greenwich/info.xml +++ b/ext/greenwich/info.xml @@ -16,9 +16,6 @@ [civicrm.releaseDate] [civicrm.version] - - mgmt:hidden - stable [civicrm.majorVersion] From bd281912e83d696cdcff3e8a178a5205ff4d98a3 Mon Sep 17 00:00:00 2001 From: benjamin Date: Tue, 11 Feb 2025 20:14:41 +0000 Subject: [PATCH 6/6] fix theme test falling back to NO_THEME if set theme isn't recognised --- tests/phpunit/Civi/Core/ThemesTest.php | 29 +++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/Civi/Core/ThemesTest.php b/tests/phpunit/Civi/Core/ThemesTest.php index 3bbf8d31d2e6..aeda75526445 100644 --- a/tests/phpunit/Civi/Core/ThemesTest.php +++ b/tests/phpunit/Civi/Core/ThemesTest.php @@ -54,10 +54,23 @@ public function getThemeExamples() { // --- Library of tests --- - // Use the default theme, Greenwich. + // Use Minetta from Riverlea + // TODO: why is Greenwich enabled here, but Riverlea is not? + // $cases[] = [ + // [], + // 'minetta', + // 'Minetta (RiverLea ~Greenwich)', + // [ + // 'civicrm-css/civicrm.css' => ["$civicrmBaseUrl/ext/riverlea/core/css/civicrm.css"], + // 'civicrm-css/joomla.css' => ["$civicrmBaseUrl/ext/riverlea/core/css/joomla.css"], + // 'test.extension.uitest-files/foo.css' => ["$civicrmBaseUrl/tests/extensions/test.extension.uitest/files/foo.css"], + // ], + // ]; + + // Use Greenwich $cases[] = [ [], - 'default', + 'greenwich', 'Greenwich', [ 'civicrm-css/civicrm.css' => ["$civicrmBaseUrl/css/civicrm.css"], @@ -82,11 +95,11 @@ public function getThemeExamples() { ], ]; - // Misconfiguration: liza was previously used but then disappeared. Fallback to default, Greenwich. + // Misconfiguration: liza was previously used but then disappeared. Fallback to default, NO_THEME. $cases[] = [ $hookJudy, 'liza', - 'Greenwich', + 'No Theme', [ 'civicrm-css/civicrm.css' => ["$civicrmBaseUrl/css/civicrm.css"], 'civicrm-css/joomla.css' => ["$civicrmBaseUrl/css/joomla.css"], @@ -98,7 +111,7 @@ public function getThemeExamples() { $cases[] = [ $hookJudy, 'none', - 'None (Unstyled)', + 'No Styles', [ 'civicrm-css/civicrm.css' => [], 'civicrm-css/joomla.css' => ["$civicrmBaseUrl/css/joomla.css"], @@ -195,15 +208,20 @@ public static function fakeCallback($themes, $themeKey, $cssExt, $cssFile) { return $map[$themeKey][$cssExt][$cssFile] ?? Themes::PASSTHRU; } + /** + * TODO with all these: why do we have greenwich not minetta here? + */ public function testGetAll(): void { $all = \Civi::service('themes')->getAll(); $this->assertTrue(isset($all['greenwich'])); + // $this->assertTrue(isset($all['minetta'])); $this->assertTrue(isset($all['_fallback_'])); } public function testGetAvailable(): void { $all = \Civi::service('themes')->getAvailable(); $this->assertTrue(isset($all['greenwich'])); + // $this->assertTrue(isset($all['minetta'])); $this->assertFalse(isset($all['_fallback_'])); } @@ -212,6 +230,7 @@ public function testApiOptions(): void { 'field' => 'theme_backend', ]); $this->assertTrue(isset($result['values']['greenwich'])); + // $this->assertTrue(isset($result['values']['minetta'])); $this->assertFalse(isset($result['values']['_fallback_'])); }