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
04:35
created

migration_222::upgrade()   C

Complexity

Conditions 7
Paths 24

Size

Total Lines 51
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 7
eloc 26
c 1
b 1
f 0
nc 24
nop 0
dl 0
loc 51
rs 6.9743

How to fix   Long Method   

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_222 extends Migration
9
{
10
    public static function getVersion()
11
    {
12
        return '2.2.2';
13
    }
14
15
    public static function getReleaseNotes()
16
    {
17
        return 'http://getsymphony.com/download/releases/version/2.2.2/';
18
    }
19
20
    public static function upgrade()
21
    {
22
        // 2.2.2 Beta 1
23
        if (version_compare(self::$existing_version, '2.2.2 Beta 1', '<=')) {
24
            Symphony::Configuration()->set('version', '2.2.2 Beta 1', 'symphony');
25
26
            // Rename old variations of the query_caching configuration setting
27
            if (Symphony::Configuration()->get('disable_query_caching', 'database')) {
28
                $value = (Symphony::Configuration()->get(
29
                    'disable_query_caching',
30
                    'database'
31
                ) === "no") ? "on" : "off";
32
33
                Symphony::Configuration()->set('query_caching', $value, 'database');
34
                Symphony::Configuration()->remove('disable_query_caching', 'database');
35
            }
36
37
            // Add Session GC collection as a configuration parameter
38
            Symphony::Configuration()->set('session_gc_divisor', '10', 'symphony');
39
40
            // Save the manifest changes
41
            Symphony::Configuration()->write();
42
        }
43
44
        // 2.2.2 Beta 2
45
        if (version_compare(self::$existing_version, '2.2.2 Beta 2', '<=')) {
46
            Symphony::Configuration()->set('version', '2.2.2 Beta 2', 'symphony');
47
            try {
48
                // Change Textareas to be MEDIUMTEXT columns
49
                $textarea_tables = Symphony::Database()->fetchCol(
50
                    "field_id",
51
                    "SELECT `field_id` FROM `tbl_fields_textarea`"
52
                );
53
54
                foreach ($textarea_tables as $field) {
55
                    Symphony::Database()->query(sprintf(
56
                        "ALTER TABLE `tbl_entries_data_%d` CHANGE `value` `value` MEDIUMTEXT, CHANGE `value_formatted` `value_formatted` MEDIUMTEXT",
57
                        $field
58
                    ));
59
                    Symphony::Database()->query(sprintf('OPTIMIZE TABLE `tbl_entries_data_%d`', $field));
60
                }
61
            } catch (Exception $ex) {
62
            }
63
64
            // Save the manifest changes
65
            Symphony::Configuration()->write();
66
        }
67
68
        // Update the version information
69
        return parent::upgrade();
70
    }
71
}
72