Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like DatabaseUpdater often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use DatabaseUpdater, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
34 | abstract class DatabaseUpdater { |
||
35 | protected static $updateCounter = 0; |
||
36 | |||
37 | /** |
||
38 | * Array of updates to perform on the database |
||
39 | * |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $updates = []; |
||
43 | |||
44 | /** |
||
45 | * Array of updates that were skipped |
||
46 | * |
||
47 | * @var array |
||
48 | */ |
||
49 | protected $updatesSkipped = []; |
||
50 | |||
51 | /** |
||
52 | * List of extension-provided database updates |
||
53 | * @var array |
||
54 | */ |
||
55 | protected $extensionUpdates = []; |
||
56 | |||
57 | /** |
||
58 | * Handle to the database subclass |
||
59 | * |
||
60 | * @var Database |
||
61 | */ |
||
62 | protected $db; |
||
63 | |||
64 | protected $shared = false; |
||
65 | |||
66 | /** |
||
67 | * @var string[] Scripts to run after database update |
||
68 | * Should be a subclass of LoggedUpdateMaintenance |
||
69 | */ |
||
70 | protected $postDatabaseUpdateMaintenance = [ |
||
71 | DeleteDefaultMessages::class, |
||
72 | PopulateRevisionLength::class, |
||
73 | PopulateRevisionSha1::class, |
||
74 | PopulateImageSha1::class, |
||
75 | FixExtLinksProtocolRelative::class, |
||
76 | PopulateFilearchiveSha1::class, |
||
77 | PopulateBacklinkNamespace::class, |
||
78 | FixDefaultJsonContentPages::class, |
||
79 | CleanupEmptyCategories::class, |
||
80 | AddRFCAndPMIDInterwiki::class, |
||
81 | ]; |
||
82 | |||
83 | /** |
||
84 | * File handle for SQL output. |
||
85 | * |
||
86 | * @var resource |
||
87 | */ |
||
88 | protected $fileHandle = null; |
||
89 | |||
90 | /** |
||
91 | * Flag specifying whether or not to skip schema (e.g. SQL-only) updates. |
||
92 | * |
||
93 | * @var bool |
||
94 | */ |
||
95 | protected $skipSchema = false; |
||
96 | |||
97 | /** |
||
98 | * Hold the value of $wgContentHandlerUseDB during the upgrade. |
||
99 | */ |
||
100 | protected $holdContentHandlerUseDB = true; |
||
101 | |||
102 | /** |
||
103 | * Constructor |
||
104 | * |
||
105 | * @param Database $db To perform updates on |
||
106 | * @param bool $shared Whether to perform updates on shared tables |
||
107 | * @param Maintenance $maintenance Maintenance object which created us |
||
108 | */ |
||
109 | protected function __construct( Database &$db, $shared, Maintenance $maintenance = null ) { |
||
110 | $this->db = $db; |
||
111 | $this->db->setFlag( DBO_DDLMODE ); // For Oracle's handling of schema files |
||
112 | $this->shared = $shared; |
||
113 | if ( $maintenance ) { |
||
114 | $this->maintenance = $maintenance; |
||
115 | $this->fileHandle = $maintenance->fileHandle; |
||
116 | } else { |
||
117 | $this->maintenance = new FakeMaintenance; |
||
118 | } |
||
119 | $this->maintenance->setDB( $db ); |
||
120 | $this->initOldGlobals(); |
||
121 | $this->loadExtensions(); |
||
122 | Hooks::run( 'LoadExtensionSchemaUpdates', [ $this ] ); |
||
123 | } |
||
124 | |||
125 | /** |
||
126 | * Initialize all of the old globals. One day this should all become |
||
127 | * something much nicer |
||
128 | */ |
||
129 | private function initOldGlobals() { |
||
130 | global $wgExtNewTables, $wgExtNewFields, $wgExtPGNewFields, |
||
131 | $wgExtPGAlteredFields, $wgExtNewIndexes, $wgExtModifiedFields; |
||
132 | |||
133 | # For extensions only, should be populated via hooks |
||
134 | # $wgDBtype should be checked to specifiy the proper file |
||
135 | $wgExtNewTables = []; // table, dir |
||
136 | $wgExtNewFields = []; // table, column, dir |
||
137 | $wgExtPGNewFields = []; // table, column, column attributes; for PostgreSQL |
||
138 | $wgExtPGAlteredFields = []; // table, column, new type, conversion method; for PostgreSQL |
||
139 | $wgExtNewIndexes = []; // table, index, dir |
||
140 | $wgExtModifiedFields = []; // table, index, dir |
||
141 | } |
||
142 | |||
143 | /** |
||
144 | * Loads LocalSettings.php, if needed, and initialises everything needed for |
||
145 | * LoadExtensionSchemaUpdates hook. |
||
146 | */ |
||
147 | private function loadExtensions() { |
||
148 | if ( !defined( 'MEDIAWIKI_INSTALL' ) ) { |
||
149 | return; // already loaded |
||
150 | } |
||
151 | $vars = Installer::getExistingLocalSettings(); |
||
152 | |||
153 | $registry = ExtensionRegistry::getInstance(); |
||
154 | $queue = $registry->getQueue(); |
||
155 | // Don't accidentally load extensions in the future |
||
156 | $registry->clearQueue(); |
||
157 | |||
158 | // This will automatically add "AutoloadClasses" to $wgAutoloadClasses |
||
159 | $data = $registry->readFromQueue( $queue ); |
||
160 | $hooks = [ 'wgHooks' => [ 'LoadExtensionSchemaUpdates' => [] ] ]; |
||
161 | View Code Duplication | if ( isset( $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'] ) ) { |
|
162 | $hooks = $data['globals']['wgHooks']['LoadExtensionSchemaUpdates']; |
||
163 | } |
||
164 | if ( $vars && isset( $vars['wgHooks']['LoadExtensionSchemaUpdates'] ) ) { |
||
165 | $hooks = array_merge_recursive( $hooks, $vars['wgHooks']['LoadExtensionSchemaUpdates'] ); |
||
166 | } |
||
167 | global $wgHooks, $wgAutoloadClasses; |
||
168 | $wgHooks['LoadExtensionSchemaUpdates'] = $hooks; |
||
169 | if ( $vars && isset( $vars['wgAutoloadClasses'] ) ) { |
||
170 | $wgAutoloadClasses += $vars['wgAutoloadClasses']; |
||
171 | } |
||
172 | } |
||
173 | |||
174 | /** |
||
175 | * @param Database $db |
||
176 | * @param bool $shared |
||
177 | * @param Maintenance $maintenance |
||
178 | * |
||
179 | * @throws MWException |
||
180 | * @return DatabaseUpdater |
||
181 | */ |
||
182 | public static function newForDB( Database $db, $shared = false, $maintenance = null ) { |
||
183 | $type = $db->getType(); |
||
184 | if ( in_array( $type, Installer::getDBTypes() ) ) { |
||
185 | $class = ucfirst( $type ) . 'Updater'; |
||
186 | |||
187 | return new $class( $db, $shared, $maintenance ); |
||
188 | } else { |
||
189 | throw new MWException( __METHOD__ . ' called for unsupported $wgDBtype' ); |
||
190 | } |
||
191 | } |
||
192 | |||
193 | /** |
||
194 | * Get a database connection to run updates |
||
195 | * |
||
196 | * @return Database |
||
197 | */ |
||
198 | public function getDB() { |
||
199 | return $this->db; |
||
200 | } |
||
201 | |||
202 | /** |
||
203 | * Output some text. If we're running from web, escape the text first. |
||
204 | * |
||
205 | * @param string $str Text to output |
||
206 | */ |
||
207 | public function output( $str ) { |
||
208 | if ( $this->maintenance->isQuiet() ) { |
||
209 | return; |
||
210 | } |
||
211 | global $wgCommandLineMode; |
||
212 | if ( !$wgCommandLineMode ) { |
||
213 | $str = htmlspecialchars( $str ); |
||
214 | } |
||
215 | echo $str; |
||
216 | flush(); |
||
217 | } |
||
218 | |||
219 | /** |
||
220 | * Add a new update coming from an extension. This should be called by |
||
221 | * extensions while executing the LoadExtensionSchemaUpdates hook. |
||
222 | * |
||
223 | * @since 1.17 |
||
224 | * |
||
225 | * @param array $update The update to run. Format is [ $callback, $params... ] |
||
226 | * $callback is the method to call; either a DatabaseUpdater method name or a callable. |
||
227 | * Must be serializable (ie. no anonymous functions allowed). The rest of the parameters |
||
228 | * (if any) will be passed to the callback. The first parameter passed to the callback |
||
229 | * is always this object. |
||
230 | */ |
||
231 | public function addExtensionUpdate( array $update ) { |
||
234 | |||
235 | /** |
||
236 | * Convenience wrapper for addExtensionUpdate() when adding a new table (which |
||
237 | * is the most common usage of updaters in an extension) |
||
238 | * |
||
239 | * @since 1.18 |
||
240 | * |
||
241 | * @param string $tableName Name of table to create |
||
242 | * @param string $sqlPath Full path to the schema file |
||
243 | */ |
||
244 | public function addExtensionTable( $tableName, $sqlPath ) { |
||
247 | |||
248 | /** |
||
249 | * @since 1.19 |
||
250 | * |
||
251 | * @param string $tableName |
||
252 | * @param string $indexName |
||
253 | * @param string $sqlPath |
||
254 | */ |
||
255 | public function addExtensionIndex( $tableName, $indexName, $sqlPath ) { |
||
258 | |||
259 | /** |
||
260 | * |
||
261 | * @since 1.19 |
||
262 | * |
||
263 | * @param string $tableName |
||
264 | * @param string $columnName |
||
265 | * @param string $sqlPath |
||
266 | */ |
||
267 | public function addExtensionField( $tableName, $columnName, $sqlPath ) { |
||
270 | |||
271 | /** |
||
272 | * |
||
273 | * @since 1.20 |
||
274 | * |
||
275 | * @param string $tableName |
||
276 | * @param string $columnName |
||
277 | * @param string $sqlPath |
||
278 | */ |
||
279 | public function dropExtensionField( $tableName, $columnName, $sqlPath ) { |
||
282 | |||
283 | /** |
||
284 | * Drop an index from an extension table |
||
285 | * |
||
286 | * @since 1.21 |
||
287 | * |
||
288 | * @param string $tableName The table name |
||
289 | * @param string $indexName The index name |
||
290 | * @param string $sqlPath The path to the SQL change path |
||
291 | */ |
||
292 | public function dropExtensionIndex( $tableName, $indexName, $sqlPath ) { |
||
295 | |||
296 | /** |
||
297 | * |
||
298 | * @since 1.20 |
||
299 | * |
||
300 | * @param string $tableName |
||
301 | * @param string $sqlPath |
||
302 | */ |
||
303 | public function dropExtensionTable( $tableName, $sqlPath ) { |
||
306 | |||
307 | /** |
||
308 | * Rename an index on an extension table |
||
309 | * |
||
310 | * @since 1.21 |
||
311 | * |
||
312 | * @param string $tableName The table name |
||
313 | * @param string $oldIndexName The old index name |
||
314 | * @param string $newIndexName The new index name |
||
315 | * @param string $sqlPath The path to the SQL change path |
||
316 | * @param bool $skipBothIndexExistWarning Whether to warn if both the old |
||
317 | * and the new indexes exist. [facultative; by default, false] |
||
318 | */ |
||
319 | public function renameExtensionIndex( $tableName, $oldIndexName, $newIndexName, |
||
332 | |||
333 | /** |
||
334 | * @since 1.21 |
||
335 | * |
||
336 | * @param string $tableName The table name |
||
337 | * @param string $fieldName The field to be modified |
||
338 | * @param string $sqlPath The path to the SQL change path |
||
339 | */ |
||
340 | public function modifyExtensionField( $tableName, $fieldName, $sqlPath ) { |
||
343 | |||
344 | /** |
||
345 | * |
||
346 | * @since 1.20 |
||
347 | * |
||
348 | * @param string $tableName |
||
349 | * @return bool |
||
350 | */ |
||
351 | public function tableExists( $tableName ) { |
||
354 | |||
355 | /** |
||
356 | * Add a maintenance script to be run after the database updates are complete. |
||
357 | * |
||
358 | * Script should subclass LoggedUpdateMaintenance |
||
359 | * |
||
360 | * @since 1.19 |
||
361 | * |
||
362 | * @param string $class Name of a Maintenance subclass |
||
363 | */ |
||
364 | public function addPostDatabaseUpdateMaintenance( $class ) { |
||
367 | |||
368 | /** |
||
369 | * Get the list of extension-defined updates |
||
370 | * |
||
371 | * @return array |
||
372 | */ |
||
373 | protected function getExtensionUpdates() { |
||
376 | |||
377 | /** |
||
378 | * @since 1.17 |
||
379 | * |
||
380 | * @return string[] |
||
381 | */ |
||
382 | public function getPostDatabaseUpdateMaintenance() { |
||
385 | |||
386 | /** |
||
387 | * @since 1.21 |
||
388 | * |
||
389 | * Writes the schema updates desired to a file for the DB Admin to run. |
||
390 | * @param array $schemaUpdate |
||
391 | */ |
||
392 | private function writeSchemaUpdateFile( $schemaUpdate = [] ) { |
||
405 | |||
406 | /** |
||
407 | * Get appropriate schema variables in the current database connection. |
||
408 | * |
||
409 | * This should be called after any request data has been imported, but before |
||
410 | * any write operations to the database. The result should be passed to the DB |
||
411 | * setSchemaVars() method. |
||
412 | * |
||
413 | * @return array |
||
414 | * @since 1.28 |
||
415 | */ |
||
416 | public function getSchemaVars() { |
||
419 | |||
420 | /** |
||
421 | * Do all the updates |
||
422 | * |
||
423 | * @param array $what What updates to perform |
||
424 | */ |
||
425 | public function doUpdates( $what = [ 'core', 'extensions', 'stats' ] ) { |
||
452 | |||
453 | /** |
||
454 | * Helper function for doUpdates() |
||
455 | * |
||
456 | * @param array $updates Array of updates to run |
||
457 | * @param bool $passSelf Whether to pass this object we calling external functions |
||
458 | */ |
||
459 | private function runUpdates( array $updates, $passSelf ) { |
||
484 | |||
485 | /** |
||
486 | * @param string $version |
||
487 | * @param array $updates |
||
488 | */ |
||
489 | protected function setAppliedUpdates( $version, $updates = [] ) { |
||
501 | |||
502 | /** |
||
503 | * Helper function: check if the given key is present in the updatelog table. |
||
504 | * Obviously, only use this for updates that occur after the updatelog table was |
||
505 | * created! |
||
506 | * @param string $key Name of the key to check for |
||
507 | * @return bool |
||
508 | */ |
||
509 | public function updateRowExists( $key ) { |
||
520 | |||
521 | /** |
||
522 | * Helper function: Add a key to the updatelog table |
||
523 | * Obviously, only use this for updates that occur after the updatelog table was |
||
524 | * created! |
||
525 | * @param string $key Name of key to insert |
||
526 | * @param string $val [optional] Value to insert along with the key |
||
527 | */ |
||
528 | public function insertUpdateRow( $key, $val = null ) { |
||
537 | |||
538 | /** |
||
539 | * Updatelog was changed in 1.17 to have a ul_value column so we can record |
||
540 | * more information about what kind of updates we've done (that's what this |
||
541 | * class does). Pre-1.17 wikis won't have this column, and really old wikis |
||
542 | * might not even have updatelog at all |
||
543 | * |
||
544 | * @return bool |
||
545 | */ |
||
546 | protected function canUseNewUpdatelog() { |
||
550 | |||
551 | /** |
||
552 | * Returns whether updates should be executed on the database table $name. |
||
553 | * Updates will be prevented if the table is a shared table and it is not |
||
554 | * specified to run updates on shared tables. |
||
555 | * |
||
556 | * @param string $name Table name |
||
557 | * @return bool |
||
558 | */ |
||
559 | protected function doTable( $name ) { |
||
575 | |||
576 | /** |
||
577 | * Before 1.17, we used to handle updates via stuff like |
||
578 | * $wgExtNewTables/Fields/Indexes. This is nasty :) We refactored a lot |
||
579 | * of this in 1.17 but we want to remain back-compatible for a while. So |
||
580 | * load up these old global-based things into our update list. |
||
581 | * |
||
582 | * @return array |
||
583 | */ |
||
584 | protected function getOldGlobalUpdates() { |
||
619 | |||
620 | /** |
||
621 | * Get an array of updates to perform on the database. Should return a |
||
622 | * multi-dimensional array. The main key is the MediaWiki version (1.12, |
||
623 | * 1.13...) with the values being arrays of updates, identical to how |
||
624 | * updaters.inc did it (for now) |
||
625 | * |
||
626 | * @return array |
||
627 | */ |
||
628 | abstract protected function getCoreUpdateList(); |
||
629 | |||
630 | /** |
||
631 | * Append an SQL fragment to the open file handle. |
||
632 | * |
||
633 | * @param string $filename File name to open |
||
634 | */ |
||
635 | public function copyFile( $filename ) { |
||
644 | |||
645 | /** |
||
646 | * Append a line to the open filehandle. The line is assumed to |
||
647 | * be a complete SQL statement. |
||
648 | * |
||
649 | * This is used as a callback for sourceLine(). |
||
650 | * |
||
651 | * @param string $line Text to append to the file |
||
652 | * @return bool False to skip actually executing the file |
||
653 | * @throws MWException |
||
654 | */ |
||
655 | public function appendLine( $line ) { |
||
663 | |||
664 | /** |
||
665 | * Applies a SQL patch |
||
666 | * |
||
667 | * @param string $path Path to the patch file |
||
668 | * @param bool $isFullPath Whether to treat $path as a relative or not |
||
669 | * @param string $msg Description of the patch |
||
670 | * @return bool False if patch is skipped. |
||
671 | */ |
||
672 | protected function applyPatch( $path, $isFullPath = false, $msg = null ) { |
||
696 | |||
697 | /** |
||
698 | * Get the full path of a patch file. Originally based on archive() |
||
699 | * from updaters.inc. Keep in mind this always returns a patch, as |
||
700 | * it fails back to MySQL if no DB-specific patch can be found |
||
701 | * |
||
702 | * @param IDatabase $db |
||
703 | * @param string $patch The name of the patch, like patch-something.sql |
||
704 | * @return string Full path to patch file |
||
705 | */ |
||
706 | View Code Duplication | public function patchPath( IDatabase $db, $patch ) { |
|
716 | |||
717 | /** |
||
718 | * Add a new table to the database |
||
719 | * |
||
720 | * @param string $name Name of the new table |
||
721 | * @param string $patch Path to the patch file |
||
722 | * @param bool $fullpath Whether to treat $patch path as a relative or not |
||
723 | * @return bool False if this was skipped because schema changes are skipped |
||
724 | */ |
||
725 | View Code Duplication | protected function addTable( $name, $patch, $fullpath = false ) { |
|
738 | |||
739 | /** |
||
740 | * Add a new field to an existing table |
||
741 | * |
||
742 | * @param string $table Name of the table to modify |
||
743 | * @param string $field Name of the new field |
||
744 | * @param string $patch Path to the patch file |
||
745 | * @param bool $fullpath Whether to treat $patch path as a relative or not |
||
746 | * @return bool False if this was skipped because schema changes are skipped |
||
747 | */ |
||
748 | View Code Duplication | protected function addField( $table, $field, $patch, $fullpath = false ) { |
|
763 | |||
764 | /** |
||
765 | * Add a new index to an existing table |
||
766 | * |
||
767 | * @param string $table Name of the table to modify |
||
768 | * @param string $index Name of the new index |
||
769 | * @param string $patch Path to the patch file |
||
770 | * @param bool $fullpath Whether to treat $patch path as a relative or not |
||
771 | * @return bool False if this was skipped because schema changes are skipped |
||
772 | */ |
||
773 | View Code Duplication | protected function addIndex( $table, $index, $patch, $fullpath = false ) { |
|
788 | |||
789 | /** |
||
790 | * Drop a field from an existing table |
||
791 | * |
||
792 | * @param string $table Name of the table to modify |
||
793 | * @param string $field Name of the old field |
||
794 | * @param string $patch Path to the patch file |
||
795 | * @param bool $fullpath Whether to treat $patch path as a relative or not |
||
796 | * @return bool False if this was skipped because schema changes are skipped |
||
797 | */ |
||
798 | View Code Duplication | protected function dropField( $table, $field, $patch, $fullpath = false ) { |
|
811 | |||
812 | /** |
||
813 | * Drop an index from an existing table |
||
814 | * |
||
815 | * @param string $table Name of the table to modify |
||
816 | * @param string $index Name of the index |
||
817 | * @param string $patch Path to the patch file |
||
818 | * @param bool $fullpath Whether to treat $patch path as a relative or not |
||
819 | * @return bool False if this was skipped because schema changes are skipped |
||
820 | */ |
||
821 | View Code Duplication | protected function dropIndex( $table, $index, $patch, $fullpath = false ) { |
|
834 | |||
835 | /** |
||
836 | * Rename an index from an existing table |
||
837 | * |
||
838 | * @param string $table Name of the table to modify |
||
839 | * @param string $oldIndex Old name of the index |
||
840 | * @param string $newIndex New name of the index |
||
841 | * @param bool $skipBothIndexExistWarning Whether to warn if both the |
||
842 | * old and the new indexes exist. |
||
843 | * @param string $patch Path to the patch file |
||
844 | * @param bool $fullpath Whether to treat $patch path as a relative or not |
||
845 | * @return bool False if this was skipped because schema changes are skipped |
||
846 | */ |
||
847 | protected function renameIndex( $table, $oldIndex, $newIndex, |
||
889 | |||
890 | /** |
||
891 | * If the specified table exists, drop it, or execute the |
||
892 | * patch if one is provided. |
||
893 | * |
||
894 | * Public @since 1.20 |
||
895 | * |
||
896 | * @param string $table Table to drop. |
||
897 | * @param string|bool $patch String of patch file that will drop the table. Default: false. |
||
898 | * @param bool $fullpath Whether $patch is a full path. Default: false. |
||
899 | * @return bool False if this was skipped because schema changes are skipped |
||
900 | */ |
||
901 | public function dropTable( $table, $patch = false, $fullpath = false ) { |
||
922 | |||
923 | /** |
||
924 | * Modify an existing field |
||
925 | * |
||
926 | * @param string $table Name of the table to which the field belongs |
||
927 | * @param string $field Name of the field to modify |
||
928 | * @param string $patch Path to the patch file |
||
929 | * @param bool $fullpath Whether to treat $patch path as a relative or not |
||
930 | * @return bool False if this was skipped because schema changes are skipped |
||
931 | */ |
||
932 | public function modifyField( $table, $field, $patch, $fullpath = false ) { |
||
953 | |||
954 | /** |
||
955 | * Set any .htaccess files or equivilent for storage repos |
||
956 | * |
||
957 | * Some zones (e.g. "temp") used to be public and may have been initialized as such |
||
958 | */ |
||
959 | public function setFileAccess() { |
||
976 | |||
977 | /** |
||
978 | * Purge the objectcache table |
||
979 | */ |
||
980 | public function purgeCache() { |
||
994 | |||
995 | /** |
||
996 | * Check the site_stats table is not properly populated. |
||
997 | */ |
||
998 | protected function checkStats() { |
||
1012 | |||
1013 | # Common updater functions |
||
1014 | |||
1015 | /** |
||
1016 | * Sets the number of active users in the site_stats table |
||
1017 | */ |
||
1018 | protected function doActiveUsersInit() { |
||
1032 | |||
1033 | /** |
||
1034 | * Populates the log_user_text field in the logging table |
||
1035 | */ |
||
1036 | View Code Duplication | protected function doLogUsertextPopulation() { |
|
1049 | |||
1050 | /** |
||
1051 | * Migrate log params to new table and index for searching |
||
1052 | */ |
||
1053 | View Code Duplication | protected function doLogSearchPopulation() { |
|
1065 | |||
1066 | /** |
||
1067 | * Updates the timestamps in the transcache table |
||
1068 | * @return bool |
||
1069 | */ |
||
1070 | protected function doUpdateTranscacheField() { |
||
1080 | |||
1081 | /** |
||
1082 | * Update CategoryLinks collation |
||
1083 | */ |
||
1084 | protected function doCollationUpdate() { |
||
1105 | |||
1106 | /** |
||
1107 | * Migrates user options from the user table blob to user_properties |
||
1108 | */ |
||
1109 | protected function doMigrateUserOptions() { |
||
1116 | |||
1117 | /** |
||
1118 | * Enable profiling table when it's turned on |
||
1119 | */ |
||
1120 | protected function doEnableProfiling() { |
||
1141 | |||
1142 | /** |
||
1143 | * Rebuilds the localisation cache |
||
1144 | */ |
||
1145 | protected function rebuildLocalisationCache() { |
||
1155 | |||
1156 | /** |
||
1157 | * Turns off content handler fields during parts of the upgrade |
||
1158 | * where they aren't available. |
||
1159 | */ |
||
1160 | protected function disableContentHandlerUseDB() { |
||
1169 | |||
1170 | /** |
||
1171 | * Turns content handler fields back on. |
||
1172 | */ |
||
1173 | protected function enableContentHandlerUseDB() { |
||
1181 | } |
||
1182 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.