* typo from r86708
[lhc/web/wiklou.git] / includes / installer / OracleUpdater.php
1 <?php
2 /**
3 * Oracle-specific updater.
4 *
5 * @file
6 * @ingroup Deployment
7 */
8
9 /**
10 * Class for handling updates to Oracle databases.
11 *
12 * @ingroup Deployment
13 * @since 1.17
14 */
15 class OracleUpdater extends DatabaseUpdater {
16 protected function getCoreUpdateList() {
17 return array(
18 // 1.16
19 array( 'doNamespaceDefaults' ),
20 array( 'doFKRenameDeferr' ),
21 array( 'doFunctions17' ),
22 array( 'doSchemaUpgrade17' ),
23 array( 'doInsertPage0' ),
24 );
25 }
26
27 /**
28 * MySQL uses datatype defaults for NULL inserted into NOT NULL fields
29 * In namespace case that results into insert of 0 which is default namespace
30 * Oracle inserts NULL, so namespace fields should have a default value
31 */
32 protected function doNamespaceDefaults() {
33 $this->output( "Altering namespace fields with default value ... " );
34 $meta = $this->db->fieldInfo( 'page', 'page_namespace' );
35 if ( $meta->defaultValue() != null ) {
36 $this->output( "defaults seem to present on namespace fields\n" );
37 return;
38 }
39
40 $this->applyPatch( 'patch_namespace_defaults.sql', false );
41 $this->output( "ok\n" );
42 }
43
44 /**
45 * Uniform FK names + deferrable state
46 */
47 protected function doFKRenameDeferr() {
48 $this->output( "Altering foreign keys ... " );
49 $meta = $this->db->query( 'SELECT COUNT(*) cnt FROM user_constraints WHERE constraint_type = \'R\' AND deferrable = \'DEFERRABLE\'' );
50 $row = $meta->fetchRow();
51 if ( $row && $row['cnt'] > 0 ) {
52 $this->output( "at least one FK is deferrable, considering up to date\n" );
53 return;
54 }
55
56 $this->applyPatch( 'patch_fk_rename_deferred.sql', false );
57 $this->output( "ok\n" );
58 }
59
60 /**
61 * Recreate functions to 17 schema layout
62 */
63 protected function doFunctions17() {
64 $this->output( "Recreating functions ... " );
65 $this->applyPatch( 'patch_create_17_functions.sql', false );
66 $this->output( "ok\n" );
67 }
68
69 /**
70 * Schema upgrade 16->17
71 * there are no incremental patches prior to this
72 */
73 protected function doSchemaUpgrade17() {
74 $this->output( "Updating schema to 17 ... " );
75 // check if iwlinks table exists which was added in 1.17
76 if ( $this->db->tableExists( $this->db->tableName( 'iwlinks' ) ) ) {
77 $this->output( "schema seem to be up to date.\n" );
78 return;
79 }
80 $this->applyPatch( 'patch_16_17_schema_changes.sql', false );
81 $this->output( "ok\n" );
82 }
83
84 /**
85 * Insert page (page_id = 0) to prevent FK constraint violation
86 */
87 protected function doInsertPage0() {
88 $this->output( "Inserting page 0 if missing ... " );
89 $row = array(
90 'page_id' => 0,
91 'page_namespace' => 0,
92 'page_title' => ' ',
93 'page_counter' => 0,
94 'page_is_redirect' => 0,
95 'page_is_new' => 0,
96 'page_random' => 0,
97 'page_touched' => $this->db->timestamp(),
98 'page_latest' => 0,
99 'page_len' => 0
100 );
101 $this->db->insert( 'page', $row, 'OracleUpdater:doInserPage0', array( 'IGNORE' ) );
102 $this->output( "ok\n" );
103 }
104
105 /**
106 * Overload: after this action field info table has to be rebuilt
107 */
108 public function doUpdates( $what = array( 'core', 'extensions', 'purge' ) ) {
109 parent::doUpdates( $what );
110
111 $this->db->query( 'BEGIN fill_wiki_info; END;' );
112 }
113
114 }