GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — integration ( 5cdb31...81c93f )
by Brendan
04:03
created

migration_221   A

Complexity

Total Complexity 18

Size/Duplication

Total Lines 108
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 108
rs 10
wmc 18
lcom 1
cbo 4

4 Methods

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