| Conditions | 7 |
| Paths | 24 |
| Total Lines | 51 |
| Code Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
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:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 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 |