Skip to content

Commit 38b6c68

Browse files
authored
[5.1] Fix duplicate Brotli .htaccess postinstall message after update from 4.4 (#43182)
* Don't insert postinstall msg if it already exists * No INSERT IGNORE/ON CONFLICT DO NOTHING * Prevent displaying the post-installation message if Brotli support already integrated into the .htaccess file. -> new installation of 4.4.4
1 parent 6b34b48 commit 38b6c68

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

administrator/components/com_admin/postinstall/htaccessbrotli.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,11 @@
2626
*/
2727
function admin_postinstall_htaccessbrotli_condition()
2828
{
29-
return true;
29+
$htaccessContent = '';
30+
31+
if (is_file(JPATH_ROOT . '/.htaccess') || is_file(JPATH_ROOT . '/htaccess.txt')) {
32+
$htaccessContent = file_get_contents(is_file(JPATH_ROOT . '/.htaccess') ? JPATH_ROOT . '/.htaccess' : JPATH_ROOT . '/htaccess.txt');
33+
}
34+
35+
return !str_contains($htaccessContent, 'E=no-brotli:1');
3036
}
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
--
22
-- Add post-installation message about Brotli compression in .htaccess
33
--
4-
INSERT IGNORE INTO `#__postinstall_messages` (`extension_id`, `title_key`, `description_key`, `action_key`, `language_extension`, `language_client_id`, `type`, `action_file`, `action`, `condition_file`, `condition_method`, `version_introduced`, `enabled`)
5-
SELECT `extension_id`, 'COM_ADMIN_POSTINSTALL_MSG_HTACCESS_BROTLI_TITLE', 'COM_ADMIN_POSTINSTALL_MSG_HTACCESS_BROTLI_DESCRIPTION', '', 'com_admin', 1, 'message', '', '', 'admin://components/com_admin/postinstall/htaccessbrotli.php', 'admin_postinstall_htaccessbrotli_condition', '5.1.0', 1 FROM `#__extensions` WHERE `name` = 'files_joomla';
4+
-- This statement had to be modified to prevent duplicate postinstall messages
5+
-- when updating from 4.4.
6+
-- See https://github.com/joomla/joomla-cms/pull/43182 for details.
7+
--
8+
INSERT INTO `#__postinstall_messages` (`extension_id`, `title_key`, `description_key`, `action_key`, `language_extension`, `language_client_id`, `type`, `action_file`, `action`, `condition_file`, `condition_method`, `version_introduced`, `enabled`)
9+
SELECT `extension_id`, 'COM_ADMIN_POSTINSTALL_MSG_HTACCESS_BROTLI_TITLE', 'COM_ADMIN_POSTINSTALL_MSG_HTACCESS_BROTLI_DESCRIPTION', '', 'com_admin', 1, 'message', '', '', 'admin://components/com_admin/postinstall/htaccessbrotli.php', 'admin_postinstall_htaccessbrotli_condition', '5.1.0', 1
10+
FROM `#__extensions`
11+
WHERE `name` = 'files_joomla'
12+
AND (SELECT COUNT(a.`postinstall_message_id`) FROM `#__postinstall_messages` a WHERE a.`title_key` = 'COM_ADMIN_POSTINSTALL_MSG_HTACCESS_BROTLI_TITLE') = 0;
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
--
22
-- Add post-installation message about Brotli compression in .htaccess
33
--
4+
-- This statement had to be modified to prevent duplicate postinstall messages
5+
-- when updating from 4.4.
6+
-- See https://github.com/joomla/joomla-cms/pull/43182 for details.
7+
--
48
INSERT INTO "#__postinstall_messages" ("extension_id", "title_key", "description_key", "action_key", "language_extension", "language_client_id", "type", "action_file", "action", "condition_file", "condition_method", "version_introduced", "enabled")
5-
SELECT "extension_id", 'COM_ADMIN_POSTINSTALL_MSG_HTACCESS_BROTLI_TITLE', 'COM_ADMIN_POSTINSTALL_MSG_HTACCESS_BROTLI_DESCRIPTION', '', 'com_admin', 1, 'message', '', '', 'admin://components/com_admin/postinstall/htaccessbrotli.php', 'admin_postinstall_htaccessbrotli_condition', '5.1.0', 1 FROM "#__extensions" WHERE "name" = 'files_joomla'
6-
ON CONFLICT DO NOTHING;
9+
SELECT "extension_id", 'COM_ADMIN_POSTINSTALL_MSG_HTACCESS_BROTLI_TITLE', 'COM_ADMIN_POSTINSTALL_MSG_HTACCESS_BROTLI_DESCRIPTION', '', 'com_admin', 1, 'message', '', '', 'admin://components/com_admin/postinstall/htaccessbrotli.php', 'admin_postinstall_htaccessbrotli_condition', '5.1.0', 1
10+
FROM "#__extensions"
11+
WHERE "name" = 'files_joomla'
12+
AND (SELECT COUNT(a."postinstall_message_id") FROM "#__postinstall_messages" a WHERE a."title_key" = 'COM_ADMIN_POSTINSTALL_MSG_HTACCESS_BROTLI_TITLE') = 0;

0 commit comments

Comments
 (0)