|
1
|
|
|
<?php |
|
2
|
|
|
namespace SymphonyCms\Installer\Migrations; |
|
3
|
|
|
|
|
4
|
|
|
use SymphonyCms\Installer\Lib\Migration; |
|
5
|
|
|
use Symphony; |
|
6
|
|
|
use Exception; |
|
7
|
|
|
|
|
8
|
|
|
class migration_221 extends Migration |
|
9
|
|
|
{ |
|
10
|
|
|
public static function getVersion() |
|
11
|
|
|
{ |
|
12
|
|
|
return '2.2.1'; |
|
13
|
|
|
} |
|
14
|
|
|
|
|
15
|
|
|
public static function getReleaseNotes() |
|
16
|
|
|
{ |
|
17
|
|
|
return 'http://getsymphony.com/download/releases/version/2.2.1/'; |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
public static function upgrade() |
|
21
|
|
|
{ |
|
22
|
|
|
// 2.2.1 Beta 1 |
|
23
|
|
|
if (version_compare(self::$existing_version, '2.2.1 Beta 1', '<=')) { |
|
24
|
|
|
Symphony::Configuration()->set('version', '2.2.1 Beta 1', 'symphony'); |
|
25
|
|
|
try { |
|
26
|
|
|
Symphony::Database()->query('CREATE INDEX `session_expires` ON `tbl_sessions` (`session_expires`)'); |
|
27
|
|
|
Symphony::Database()->query('OPTIMIZE TABLE `tbl_sessions`'); |
|
28
|
|
|
} catch (Exception $ex) { |
|
29
|
|
|
} |
|
30
|
|
|
Symphony::Configuration()->write(); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
// 2.2.1 Beta 2 |
|
34
|
|
|
if (version_compare(self::$existing_version, '2.2.1 Beta 2', '<=')) { |
|
35
|
|
|
Symphony::Configuration()->set('version', '2.2.1 Beta 2', 'symphony'); |
|
36
|
|
|
|
|
37
|
|
|
// Add Security Rules from 2.2 to .htaccess |
|
38
|
|
|
try { |
|
39
|
|
|
$htaccess = file_get_contents(DOCROOT . '/.htaccess'); |
|
40
|
|
|
|
|
41
|
|
|
if ($htaccess !== false && !preg_match('/### SECURITY - Protect crucial files/', $htaccess)) { |
|
42
|
|
|
$security = ' |
|
43
|
|
|
### SECURITY - Protect crucial files |
|
44
|
|
|
RewriteRule ^manifest/(.*)$ - [F] |
|
45
|
|
|
RewriteRule ^workspace/(pages|utilities)/(.*)\.xsl$ - [F] |
|
46
|
|
|
RewriteRule ^(.*)\.sql$ - [F] |
|
47
|
|
|
RewriteRule (^|/)\. - [F] |
|
48
|
|
|
|
|
49
|
|
|
### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico"'; |
|
50
|
|
|
|
|
51
|
|
|
$htaccess = str_replace('### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico"', $security, |
|
52
|
|
|
$htaccess); |
|
53
|
|
|
file_put_contents(DOCROOT . '/.htaccess', $htaccess); |
|
54
|
|
|
} |
|
55
|
|
|
} catch (Exception $ex) { |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
// Add correct index to the `tbl_cache` |
|
59
|
|
|
try { |
|
60
|
|
|
Symphony::Database()->query('ALTER TABLE `tbl_cache` DROP INDEX `creation`'); |
|
61
|
|
|
Symphony::Database()->query('CREATE INDEX `expiry` ON `tbl_cache` (`expiry`)'); |
|
62
|
|
|
Symphony::Database()->query('OPTIMIZE TABLE `tbl_cache`'); |
|
63
|
|
|
} catch (Exception $ex) { |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
// Remove Hide Association field from Select Data tables |
|
67
|
|
|
$select_tables = Symphony::Database()->fetchCol("field_id", |
|
68
|
|
|
"SELECT `field_id` FROM `tbl_fields_select`"); |
|
69
|
|
|
|
|
70
|
|
|
if (is_array($select_tables) && !empty($select_tables)) { |
|
71
|
|
|
foreach ($select_tables as $field) { |
|
72
|
|
|
if (Symphony::Database()->tableContainsField('tbl_entries_data_' . $field, |
|
73
|
|
|
'show_association') |
|
74
|
|
|
) { |
|
75
|
|
|
Symphony::Database()->query(sprintf( |
|
76
|
|
|
"ALTER TABLE `tbl_entries_data_%d` DROP `show_association`", |
|
77
|
|
|
$field |
|
78
|
|
|
)); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
// Update Select table to include the sorting option |
|
84
|
|
|
if (!Symphony::Database()->tableContainsField('tbl_fields_select', 'sort_options')) { |
|
85
|
|
|
Symphony::Database()->query('ALTER TABLE `tbl_fields_select` ADD `sort_options` ENUM( "yes", "no" ) COLLATE utf8_unicode_ci NOT NULL DEFAULT "no"'); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
// Remove the 'driver' from the Config |
|
89
|
|
|
Symphony::Configuration()->remove('driver', 'database'); |
|
90
|
|
|
Symphony::Configuration()->write(); |
|
91
|
|
|
|
|
92
|
|
|
// Remove the NOT NULL from the Author tables |
|
93
|
|
|
try { |
|
94
|
|
|
$author = Symphony::Database()->fetchCol("field_id", "SELECT `field_id` FROM `tbl_fields_author`"); |
|
95
|
|
|
|
|
96
|
|
|
foreach ($author as $id) { |
|
97
|
|
|
$table = '`tbl_entries_data_' . $id . '`'; |
|
98
|
|
|
|
|
99
|
|
|
Symphony::Database()->query( |
|
100
|
|
|
'ALTER TABLE ' . $table . ' CHANGE `author_id` `author_id` INT(11) UNSIGNED NULL' |
|
101
|
|
|
); |
|
102
|
|
|
} |
|
103
|
|
|
} catch (Exception $ex) { |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
Symphony::Configuration()->write(); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
// Update the version information |
|
110
|
|
|
return parent::upgrade(); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
public static function postUpdateNotes() |
|
114
|
|
|
{ |
|
115
|
|
|
return array( |
|
116
|
|
|
__('Version %s introduces some improvements and fixes to Static XML Datasources. If you have any Static XML Datasources in your installation, please be sure to re-save them through the Data Source Editor to prevent unexpected results.', |
|
117
|
|
|
array('<code>2.2.1</code>')) |
|
118
|
|
|
); |
|
119
|
|
|
} |
|
120
|
|
|
} |
|
121
|
|
|
|