Skip to content
Snippets Groups Projects
Commit 54ab33c0 authored by Jared Hancock's avatar Jared Hancock
Browse files

Retroactively add the `format` column to ticket_thread

This will make upgrades from osTicket < 1.8.0 substantially faster and more
reliable, considering that the previous ticket threads will not need to be
explicitly converted to html.
parent 5dfe337e
No related branches found
No related tags found
No related merge requests found
......@@ -156,21 +156,9 @@ UPDATE `%TABLE_PREFIX%canned_response`
'>', '&gt;'),
'\n', '<br/>');
-- Migrate ticket-thread to HTML
-- XXX: Migrate & -> &amp; ? -- the problem is that there's a fix in 1.7.1
-- that properly encodes these characters, so encoding & would mean possible
-- double encoding.
UPDATE `%TABLE_PREFIX%ticket_thread`
SET `body` = REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
`body`,
'\r', ''),
'\n ', '\n'),
'\n\n\n', '\n\n'),
'\n\n\n', '\n\n'),
'\n\n\n', '\n\n'),
'<', '&lt;'),
'>', '&gt;'),
'\n', '<br/>');
-- Mark all thread entries as text
ALTER TABLE `%TABLE_PREFIX%ticket_thread`
ADD `format` varchar(16) NOT NULL default 'text' AFTER `body`;
-- Finished with patch
UPDATE `%TABLE_PREFIX%config`
......
......@@ -136,6 +136,25 @@ UPDATE `%TABLE_PREFIX%content` SET `content_id` = LAST_INSERT_ID()
DELETE FROM `%TABLE_PREFIX%email_template`
WHERE `code_name` IN ('staff.pwreset', 'user.accesslink');
-- The original patch for d51f303a-dad45ca2.patch.sql migrated all the
-- thread entries from text to html. Now that the format column exists in
-- the ticket_thread table, we opted to retroactively add the format column
-- to the dad45ca2 patch. Therefore, anyone upgrading from osTicket < 1.8.0
-- to v1.8.2 and further will alreay have a `format` column when they arrive
-- at this patch. In such a case, we'll just change the default to 'html'
SET @s = (SELECT IF(
(SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = '%TABLE_PREFIX%ticket_thread'
AND table_schema = DATABASE()
AND column_name = 'format'
) > 0,
"ALTER TABLE `%TABLE_PREFIX%ticket_thread` CHANGE `format` `format` varchar(16) NOT NULL default 'html'",
"ALTER TABLE `%TABLE_PREFIX%ticket_thread` ADD `format` varchar(16) NOT NULL default 'html' AFTER `body`"
));
PREPARE stmt FROM @s;
EXECUTE stmt;
-- Finished with patch
UPDATE `%TABLE_PREFIX%config`
SET `value` = '4323a6a81c35efbf7722b7fc4e475440'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment