Subversion Repositories oidplus

Rev

Rev 817 | Rev 989 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 817 Rev 830
Line 127... Line 127...
127
                $this->initRequireTables(array('config'));
127
                $this->initRequireTables(array('config'));
128
 
128
 
129
                // Do the database tables need an update?
129
                // Do the database tables need an update?
130
                // It is important that we do it immediately after connecting,
130
                // It is important that we do it immediately after connecting,
131
                // because the database structure might change and therefore various things might fail.
131
                // because the database structure might change and therefore various things might fail.
132
                // Note: The config setting "database_version" is inserted in setup/sql/...sql, not in the OIDplus core init
-
 
133
 
-
 
134
                $res = $this->query("SELECT value FROM ###config WHERE name = 'database_version'");
-
 
135
                $row = $res->fetch_array();
-
 
136
                if ($row == null) {
-
 
137
                        throw new OIDplusConfigInitializationException(_L('Cannot determine database version (the entry "database_version" inside the table "###config" is probably missing)'));
-
 
138
                }
-
 
139
                $version = $row['value'];
-
 
140
                if (!is_numeric($version) || ($version < 200) || ($version > 999)) {
-
 
141
                        throw new OIDplusConfigInitializationException(_L('Entry "database_version" inside the table "###config" seems to be wrong (expect number between 200 and 999)'));
-
 
142
                }
-
 
143
 
-
 
144
                $update_files = glob(OIDplus::localpath().'includes/db_updates/update*.inc.php');
132
                require_once __DIR__.'/../db_updates/run.inc.php';
145
                foreach ($update_files as $update_file) {
-
 
146
                        include_once $update_file;
133
                oidplus_dbupdate($this);
147
                }
-
 
148
                while (function_exists($function_name = "oidplus_dbupdate_".$version."_".($version+1))) {
-
 
149
                        $prev_version = $version;
-
 
150
                        $function_name($this, $version);
-
 
151
                        if ($version != $prev_version+1) {
-
 
152
                                // This should usually not happen, since the update-file should increase the version
-
 
153
                                // or throw an Exception by itself
-
 
154
                                throw new OIDplusException(_L('Database update %1 -> %2 failed (script reports new version to be %3)',$prev_version,$prev_version+1,$version));
-
 
155
                        }
-
 
156
                }
-
 
157
 
134
 
158
                // Now that our database is up-to-date, we check if database tables are existing
135
                // Now that our database is up-to-date, we check if database tables are existing
159
                // without config table, because it was checked above
136
                // without config table, because it was checked above
160
                $this->initRequireTables(array('objects', 'asn1id', 'iri', 'ra'/*, 'config'*/));
137
                $this->initRequireTables(array('objects', 'asn1id', 'iri', 'ra'/*, 'config'*/));
161
 
138