Geeklog-Core / geeklog

Geeklog - The Secure CMS.
https://www.geeklog.net
24 stars 19 forks source link

Theme Detection problem which resulted in an error after Upgrade #996

Closed eSilverStrike closed 4 years ago

eSilverStrike commented 4 years ago

Related to #992

I had this issue when upgrading Geeklog.net from 2.2.0 to 2.2.1

When upgrading I had in the layout folder the denim theme and the glnet_curve theme which is a child theme of denim. That is it.

At the end of the upgrade process on the success.php page I was shown a blank page.

After looking into the issue it was because the main theme in the Geeklog config was still set to "professional". If that happens lib-common automatically switches it to denim_three now (instead of denim).

One of the reasons I didn't notice the problem before the upgrade is because in the Geeklog configuration the theme option if not found defaults to the first item in the list which happens to be "denim" (but should have been glnet_curve)

Also I notice in the config table that the default for the themes config option is denim. We should change this to denim_three for the upgrade from Geeklog 2.2.0 to 2.2.1

Not sure if we want to deal with this whole issue now or leave some of it until Geeklog v2.2.2 and with #992

eSilverStrike commented 4 years ago

Reworked theme compatibility check from #814. If theme is invalid will attempt to find a valid one to use.

Note: @mystralkk - Theme functions again require the theme name at the end of the function name since Geeklog may need to load multiple themes functions.php files to look for one that has the correct Geeklog version.

Added config options

$_CONF['theme_geeklog_default'] = 'denim_three'; // Geeklog default theme. If this changes then remember to change default theme in Installer for Install class and config-install.php files
$_CONF['theme_site_default'] = $_CONF['theme']; // Store original theme set in config

Added config option below which should be set to the version of Geeklog that has had the last changes to any new template variables or file changes happen that can make a theme incompatible with an older version of Geeklog.

$_CONF['min_theme_gl_version'] = '2.2.1'; // Template changes happened so update min version

if a themes setting for 'theme_gl_version' does not match this then it is not considered valid.

Added function COM_validateTheme which checks to see if theme passed is considered valid or not.

COM_getThemes now uses COM_validateTheme and only returns valid themes by default.

If Site default theme is set to an invalid theme root users will now be notified by a system message.

COM_handleError and COM_rootDebugClean fixes as it could modify the GLOBALS variable in certain cases which caused an infinite loop error. Also fixed error message not displaying if Language arrays not set yet by lib-common.

COM_handleError also supports Geeklog specific errors by the function COM_handleGeeklogError. COM_handleGeeklogError is meant to be used when some sort of Geeklog error (like an incorrect config option like a theme) cannot be fixed and execution must stop.

eSilverStrike commented 4 years ago

More changes than I like introduced here since we are in Beta, but I wanted to do things the right away. This fix also deals partially with stuff mentioned in #992 for v2.2.2