Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.10] Add a check whether we are running the core backend template and issue an info when that is not the case #2133

Closed
jgerman-bot opened this issue Nov 26, 2021 · 0 comments · Fixed by #2135 or #2373

Comments

@jgerman-bot
Copy link

New language relevant PR in upstream repo: joomla/joomla-cms#35107 Here are the upstream changes:

Click to expand the diff!
diff --git a/administrator/components/com_joomlaupdate/models/default.php b/administrator/components/com_joomlaupdate/models/default.php
index 1e8160fdb91f..bd6c803d5067 100644
--- a/administrator/components/com_joomlaupdate/models/default.php
+++ b/administrator/components/com_joomlaupdate/models/default.php
@@ -1799,4 +1799,63 @@ protected function translateExtensionName(&$item)
 		// Translate the extension name if possible
 		$item->name = strip_tags(JText::_($item->name));
 	}
+
+	/**
+	 * Checks whether a given template is active
+	 *
+	 * @param   string  $template  The template name to be checked
+	 *
+	 * @return  boolean
+	 *
+	 * @since   __DEPLOY_VERSION__
+	 */
+	public function isTemplateActive($template)
+	{
+		$db = $this->getDbo();
+		$query = $db->getQuery(true);
+
+		$query->select(
+			$db->qn(
+				array(
+					'id',
+					'home'
+				)
+			)
+		)->from(
+			$db->qn('#__template_styles')
+		)->where(
+			$db->qn('template') . ' = ' . $db->q($template)
+		);
+
+		$templates = $db->setQuery($query)->loadObjectList();
+
+		$home = array_filter(
+			$templates,
+			function($value)
+			{
+				return $value->home > 0;
+			}
+		);
+
+		$ids = JArrayHelper::getColumn($templates, 'id');
+
+		$menu = false;
+
+		if (count($ids))
+		{
+			$query = $db->getQuery(true);
+
+			$query->select(
+				'COUNT(*)'
+			)->from(
+				$db->qn('#__menu')
+			)->where(
+				$db->qn('template_style_id') . ' IN(' . implode(',', $ids) . ')'
+			);
+
+			$menu = $db->setQuery($query)->loadResult() > 0;
+		}
+
+		return $home || $menu;
+	}
 }
diff --git a/administrator/components/com_joomlaupdate/views/default/tmpl/default_preupdatecheck.php b/administrator/components/com_joomlaupdate/views/default/tmpl/default_preupdatecheck.php
index 346e0b968591..9b5ffcf18a0f 100644
--- a/administrator/components/com_joomlaupdate/views/default/tmpl/default_preupdatecheck.php
+++ b/administrator/components/com_joomlaupdate/views/default/tmpl/default_preupdatecheck.php
@@ -44,6 +44,16 @@
 	)
 );
 
+if (version_compare($this->updateInfo['latest'], '4', '>=') && $this->isBackendTemplateIsis === false)
+{
+	JFactory::getApplication()->enqueueMessage(
+		JText::_(
+			'COM_JOOMLAUPDATE_VIEW_DEFAULT_NON_CORE_BACKEND_TEMPLATE_USED_NOTICE'
+		),
+		'info'
+	);
+}
+
 ?>
 <h2>
 	<?php echo JText::sprintf('COM_JOOMLAUPDATE_VIEW_DEFAULT_PREUPDATE_CHECK', $this->updateInfo['latest']); ?>
diff --git a/administrator/components/com_joomlaupdate/views/default/view.html.php b/administrator/components/com_joomlaupdate/views/default/view.html.php
index 815bb5aafefc..c64170864a42 100644
--- a/administrator/components/com_joomlaupdate/views/default/view.html.php
+++ b/administrator/components/com_joomlaupdate/views/default/view.html.php
@@ -101,6 +101,7 @@ public function display($tpl = null)
 		$this->phpOptions             = $model->getPhpOptions();
 		$this->phpSettings            = $model->getPhpSettings();
 		$this->nonCoreExtensions      = $model->getNonCoreExtensions();
+		$this->isBackendTemplateIsis  = (bool) $model->isTemplateActive('isis');
 
 		// Disable the critical plugins check for non-major updates.
 		$this->nonCoreCriticalPlugins = array();
diff --git a/administrator/language/en-GB/en-GB.com_joomlaupdate.ini b/administrator/language/en-GB/en-GB.com_joomlaupdate.ini
index 655c45c43ee1..314d99cdc92d 100644
--- a/administrator/language/en-GB/en-GB.com_joomlaupdate.ini
+++ b/administrator/language/en-GB/en-GB.com_joomlaupdate.ini
@@ -79,6 +79,7 @@ COM_JOOMLAUPDATE_VIEW_DEFAULT_EXTENSION_WARNING_UNKNOWN="Unkown error"
 COM_JOOMLAUPDATE_VIEW_DEFAULT_EXTENSION_SERVER_ERROR="Update Server error"
 COM_JOOMLAUPDATE_VIEW_DEFAULT_EXTENSIONS="Extensions Pre-Update Check"
 COM_JOOMLAUPDATE_VIEW_DEFAULT_EXTENSIONS_NONE="No extensions installed."
+COM_JOOMLAUPDATE_VIEW_DEFAULT_NON_CORE_BACKEND_TEMPLATE_USED_NOTICE="We detected that you are not using a core admin template. You might find the upgrade process smoother if you <a href='index.php?option=com_templates&view=styles&client_id=1'>switch</a> to use the Isis template."
 COM_JOOMLAUPDATE_VIEW_DEFAULT_NON_CORE_PLUGIN_BEING_CHECKED="The system is currently checking these plugins to see if they could cause problems during the upgrade.<br><br>Please be patient while the checks are completed."
 COM_JOOMLAUPDATE_VIEW_DEFAULT_NON_CORE_PLUGIN_CONFIRMATION="Do you wish to ignore the warnings about potentially incompatible plugins and to proceed with the upgrade?"
 COM_JOOMLAUPDATE_VIEW_DEFAULT_POTENTIALLY_DANGEROUS_PLUGIN="Potential Upgrade Issue"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment