/** * Run the upgrader * * @return string HTML report */ public function run() { $tables = get_entity_tables_by_type(id_of('faculty_staff'), false); if (!in_array('chunk', $tables)) { return '<p>This upgrade has already been run. There is nothing to do.</p>'; } else { // This should take considerably less time than one hour! // This should make sure things aren't killed partway through set_time_limit(3600); $success = reason_move_table_fields(id_of('faculty_staff'), 'chunk', 'faculty_staff', $this->user_id()); if ($success) { return '<p>Successfully moved faculty/staff content in the chunk table to the faculty_staff table.</p>'; } else { $ret = '<p>Unable to move the content from the chunk to the faculty/staff table. Please look in your PHP error logs for information about the cause of this error. This error may cause problems with Reason modules or queries; we recommend restoring your latest backup, identifying and fixing the cause on a testing server, and re-running this upgrade.</p>'; $err = error_get_last(); if (!empty($err)) { $ret .= '<p>Last error: "' . htmlspecialchars($err['message']) . '"</p>'; } return $ret; } } }
protected function _move_table_fields($from) { $ret = ''; set_time_limit(3600); $success = reason_move_table_fields($this->_type_id(), $from, $this->_destination_table(), $this->user_id()); if ($success) { $ret .= '<p>Successfully moved ' . $this->_type_unique_name() . ' content in the ' . $from . ' table to the ' . $this->_destination_table() . ' table.</p>'; } else { $ret = '<p>Unable to move the content from the ' . $from . ' table to the ' . $this->_destination_table() . ' table. Please look in your PHP error logs for information about the cause of this error. This error may cause problems with Reason modules or queries; we recommend restoring your latest backup, identifying and fixing the cause on a testing server, and re-running this upgrade.</p>'; $err = error_get_last(); if (!empty($err)) { $ret .= '<p>Last error: "' . htmlspecialchars($err['message']) . '"</p>'; } } return $ret; }