1
|
|
|
<?php |
2
|
|
|
namespace SymphonyCms\Installer\Migrations; |
3
|
|
|
|
4
|
|
|
use SymphonyCms\Installer\Lib\Migration; |
5
|
|
|
use Symphony; |
6
|
|
|
use Exception; |
7
|
|
|
|
8
|
|
|
class migration_231 extends Migration |
9
|
|
|
{ |
10
|
|
|
public static function getVersion() |
11
|
|
|
{ |
12
|
|
|
return '2.3.1'; |
13
|
|
|
} |
14
|
|
|
|
15
|
|
|
public static function getReleaseNotes() |
16
|
|
|
{ |
17
|
|
|
return 'http://getsymphony.com/download/releases/version/2.3.1/'; |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public static function upgrade() |
21
|
|
|
{ |
22
|
|
|
// 2.3.1dev |
23
|
|
|
if (version_compare(self::$existing_version, '2.3.1dev', '<=')) { |
24
|
|
|
// Remove unused setting from the Author field |
25
|
|
|
$author_table = 'tbl_fields_author'; |
26
|
|
|
if (Symphony::Database()->tableContainsField($author_table, 'allow_author_change')) { |
27
|
|
|
Symphony::Database()->query("ALTER TABLE `$author_table` DROP `allow_author_change`;"); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
// Author Types [#1219] |
31
|
|
|
if (!Symphony::Database()->tableContainsField($author_table, 'author_types')) { |
32
|
|
|
Symphony::Database()->query("ALTER TABLE `$author_table` ADD `author_types` VARCHAR(255) DEFAULT NULL;"); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
// Entries Modification Date [#983] |
36
|
|
View Code Duplication |
if (!Symphony::Database()->tableContainsField('tbl_entries', 'modification_date')) { |
37
|
|
|
Symphony::Database()->query("ALTER TABLE `tbl_entries` ADD `modification_date` DATETIME NOT NULL;"); |
38
|
|
|
Symphony::Database()->query("ALTER TABLE `tbl_entries` ADD KEY `modification_date` (`modification_date`)"); |
39
|
|
|
Symphony::Database()->query("UPDATE `tbl_entries` SET modification_date = creation_date;"); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
View Code Duplication |
if (!Symphony::Database()->tableContainsField('tbl_entries', 'modification_date_gmt')) { |
43
|
|
|
Symphony::Database()->query("ALTER TABLE `tbl_entries` ADD `modification_date_gmt` DATETIME NOT NULL;"); |
44
|
|
|
Symphony::Database()->query("ALTER TABLE `tbl_entries` ADD KEY `modification_date_gmt` (`modification_date_gmt`)"); |
45
|
|
|
Symphony::Database()->query("UPDATE `tbl_entries` SET modification_date_gmt = creation_date_gmt;"); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
// Cleanup #977, remove `entry_order` & `entry_order_direction` from `tbl_sections` |
49
|
|
|
if (Symphony::Database()->tableContainsField('tbl_sections', 'entry_order')) { |
50
|
|
|
Symphony::Database()->query("ALTER TABLE `tbl_sections` DROP `entry_order`;"); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
if (Symphony::Database()->tableContainsField('tbl_sections', 'entry_order_direction')) { |
54
|
|
|
Symphony::Database()->query("ALTER TABLE `tbl_sections` DROP `entry_order_direction`;"); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
58
|
|
View Code Duplication |
if (version_compare(self::$existing_version, '2.3.1RC1', '<=')) { |
59
|
|
|
// Add Security Rules from 2.2 to .htaccess |
60
|
|
|
try { |
61
|
|
|
$htaccess = file_get_contents(DOCROOT . '/.htaccess'); |
62
|
|
|
|
63
|
|
|
if ($htaccess !== false && preg_match('/### SECURITY - Protect crucial files/', $htaccess)) { |
64
|
|
|
$security = ' |
65
|
|
|
### SECURITY - Protect crucial files |
66
|
|
|
RewriteRule ^manifest/(.*)$ - [F] |
67
|
|
|
RewriteRule ^workspace/(pages|utilities)/(.*)\.xsl$ - [F] |
68
|
|
|
RewriteRule ^(.*)\.sql$ - [F] |
69
|
|
|
RewriteRule (^|/)\. - [F] |
70
|
|
|
|
71
|
|
|
### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico"'; |
72
|
|
|
|
73
|
|
|
$htaccess = str_replace( |
74
|
|
|
'### SECURITY - Protect crucial files.*### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico"', |
75
|
|
|
$security, |
76
|
|
|
$htaccess |
77
|
|
|
); |
78
|
|
|
file_put_contents(DOCROOT . '/.htaccess', $htaccess); |
79
|
|
|
} |
80
|
|
|
} catch (Exception $ex) { |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
// Increase length of password field to accomodate longer hashes |
84
|
|
|
Symphony::Database()->query("ALTER TABLE `tbl_authors` CHANGE `password` `password` VARCHAR( 150 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL"); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
// Update the version information |
88
|
|
|
return parent::upgrade(); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|