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
Pull Request — integration (#2604)
by Brendan
05:28
created

migration_240::upgrade()   C

Complexity

Conditions 11
Paths 128

Size

Total Lines 73
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 11
eloc 31
c 1
b 1
f 0
nc 128
nop 0
dl 0
loc 73
rs 5.2343

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
namespace SymphonyCms\Installer\Migrations;
3
4
use SymphonyCms\Installer\Lib\Migration;
5
use Symphony;
6
use Exception;
7
8
class migration_240 extends Migration
9
{
10
    public static $publish_filtering_disabled = false;
11
12
    public static function getVersion()
13
    {
14
        return '2.4';
15
    }
16
17
    public static function getReleaseNotes()
18
    {
19
        return 'http://getsymphony.com/download/releases/version/2.4/';
20
    }
21
22
    public static function upgrade()
23
    {
24
        // [#702] Update to include Admin Path configuration
25
        if (version_compare(self::$existing_version, '2.4beta2', '<=')) {
26
            // Add missing config value for index view string length
27
            Symphony::Configuration()->set('cell_truncation_length', '75', 'symphony');
28
            // Add admin-path to configuration
29
            Symphony::Configuration()->set('admin-path', 'symphony', 'symphony');
30
        }
31
32
        // [#1626] Update all tables to be UTF-8 encoding/collation
33
        // @link https://gist.github.com/michael-e/5789168
34
        $tables = Symphony::Database()->fetch("SHOW TABLES");
35
        if (is_array($tables) && !empty($tables)) {
36
            foreach ($tables as $table) {
37
                $table = current($table);
38
39
                // If it's not a Symphony table, ignore it
40
                if (!preg_match('/^' . Symphony::Database()->getPrefix() . '/', $table)) {
41
                    continue;
42
                }
43
44
                Symphony::Database()->query(sprintf(
45
                    "ALTER TABLE `%s` CHARACTER SET utf8 COLLATE utf8_unicode_ci",
46
                    $table
47
                ));
48
                Symphony::Database()->query(sprintf(
49
                    "ALTER TABLE `%s` CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci",
50
                    $table
51
                ));
52
            }
53
        }
54
55
        // [#1420] Change date field to be a varchar instead of an ENUM to support prepopulation
56
        try {
57
            Symphony::Database()->query('
58
                ALTER TABLE `tbl_fields_date`
59
                CHANGE `pre_populate` `pre_populate` VARCHAR(80) COLLATE utf8_unicode_ci DEFAULT NULL;
60
            ');
61
        } catch (Exception $ex) {
62
        }
63
64
        // [#1997] Add filtering column to the Sections table
65
        if (!Symphony::Database()->tableContainsField('tbl_sections', 'filter')) {
66
            Symphony::Database()->query("
67
                ALTER TABLE `tbl_sections`
68
                ADD `filter` ENUM('yes','no') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'yes';
69
            ");
70
        }
71
72
        $installed_extensions = Symphony::ExtensionManager()->listInstalledHandles();
73
        if (in_array('publishfiltering', $installed_extensions)) {
74
            Symphony::ExtensionManager()->uninstall('publishfiltering');
75
            self::$publish_filtering_disabled = true;
76
        }
77
78
        // [#1874] XSRF/CRSF options
79
        if (version_compare(self::$existing_version, '2.4beta3', '<=')) {
80
            // How long should a XSRF token be valid
81
            Symphony::Configuration()->set('token_lifetime', '15 minutes', 'symphony');
82
            // Should the token be removed as soon as it has been used?
83
            Symphony::Configuration()->set('invalidate_tokens_on_request', false, 'symphony');
0 ignored issues
show
Documentation introduced by
false is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
84
        }
85
86
        // [#1874] XSRF/CRSF options
87
        if (version_compare(self::$existing_version, '2.4RC1', '<=')) {
88
            // On update, disable XSRF for compatibility purposes
89
            Symphony::Configuration()->set('enable_xsrf', 'no', 'symphony');
90
        }
91
92
        // Update the version information
93
        return parent::upgrade();
94
    }
95
96
    public static function preUpdateNotes()
97
    {
98
        return array(
99
            __("Symphony 2.4 is a major release that contains breaking changes from previous versions. It is highly recommended to review the releases notes and make a complete backup of your installation before updating as these changes may affect the functionality of your site."),
100
            __(
101
                "This release will automatically convert all existing Symphony database tables to %s.",
102
                array("<code>utf8_unicode_ci</code>")
103
            ),
104
            __(
105
                "CRSF has been implemented in this release and is turned off by default. To enable for the backend, change %s from %s to %s in your configuration. To enable for the frontend, update the XSS Filter extension and follow the README.",
106
                array('<code>enable_xsrf</code>', '<code>no</code>', '<code>yes</code>')
107
            )
108
        );
109
    }
110
111
    public static function postUpdateNotes()
112
    {
113
        $notes = array();
114
115
        if (self::$publish_filtering_disabled) {
116
            $notes[] = __("As Symphony 2.4 adds the Publish Filtering extension into the core, the standalone extension has been uninstalled. You can remove it from your installation at any time.");
117
        }
118
119
        $notes[] = __(
120
            "The Dynamic XML Datasource has been deprecated from the core in favour of the %s extension. You will no longer be able to create new Dynamic XML Data Sources from the Symphony Data Source editor. Existing Dynamic XML Data Sources can be edited and will continue to function until Symphony 2.7.0.",
121
            array(
122
                "<a href='http://symphonyextensions.com/extensions/remote_datasource/'>Remote Datasource</a>"
123
            )
124
        );
125
126
            return $notes;
127
    }
128
}
129