本文整理汇总了PHP中upgrade_log函数的典型用法代码示例。如果您正苦于以下问题:PHP upgrade_log函数的具体用法?PHP upgrade_log怎么用?PHP upgrade_log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了upgrade_log函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: xmldb_tool_bloglevelupgrade_install
function xmldb_tool_bloglevelupgrade_install()
{
global $CFG, $OUTPUT;
// this is a hack - admins were long ago instructed to upgrade blog levels,
// the problem is that blog is not supposed to be course level activity!!
if (!empty($CFG->bloglevel_upgrade_complete)) {
// somebody already upgrades, we do not need this any more
unset_config('bloglevel_upgrade_complete');
return;
}
if (!isset($CFG->bloglevel)) {
// fresh install?
return;
}
if ($CFG->bloglevel == BLOG_COURSE_LEVEL || $CFG->bloglevel == BLOG_GROUP_LEVEL) {
// inform admins that some settings require attention after upgrade
$site = get_site();
$a = new StdClass();
$a->sitename = $site->fullname;
$a->fixurl = "{$CFG->wwwroot}/{$CFG->admin}/tool/bloglevelupgrade/index.php";
$subject = get_string('bloglevelupgrade', 'tool_bloglevelupgrade');
$description = get_string('bloglevelupgradedescription', 'tool_bloglevelupgrade', $a);
// can not use messaging here because it is not configured yet!
upgrade_log(UPGRADE_LOG_NOTICE, null, $subject, $description);
set_config('tool_bloglevelupgrade_pending', 1);
echo $OUTPUT->notification($description);
}
}
开发者ID:nigeldaley,项目名称:moodle,代码行数:28,代码来源:install.php
示例2: xmldb_main_upgrade
/**
*
* @global stdClass $CFG
* @global stdClass $USER
* @global moodle_database $DB
* @global core_renderer $OUTPUT
* @param int $oldversion
* @return bool always true
*/
function xmldb_main_upgrade($oldversion)
{
global $CFG, $USER, $DB, $OUTPUT;
require_once $CFG->libdir . '/db/upgradelib.php';
// Core Upgrade-related functions
$dbman = $DB->get_manager();
// loads ddl manager and xmldb classes
////////////////////////////////////////
///upgrade supported only from 1.9.x ///
////////////////////////////////////////
if ($oldversion < 2008030600) {
//NOTE: this table was added much later later in dev cycle, but we need it here, upgrades from pre PR1 not supported
/// Define table upgrade_log to be created
$table = new xmldb_table('upgrade_log');
/// Adding fields to table upgrade_log
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('type', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
$table->add_field('plugin', XMLDB_TYPE_CHAR, '100', null, null, null, null);
$table->add_field('version', XMLDB_TYPE_CHAR, '100', null, null, null, null);
$table->add_field('targetversion', XMLDB_TYPE_CHAR, '100', null, null, null, null);
$table->add_field('info', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
$table->add_field('details', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
$table->add_field('backtrace', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
/// Adding keys to table upgrade_log
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
/// Adding indexes to table upgrade_log
$table->add_index('timemodified', XMLDB_INDEX_NOTUNIQUE, array('timemodified'));
$table->add_index('type-timemodified', XMLDB_INDEX_NOTUNIQUE, array('type', 'timemodified'));
/// Create table for upgrade_log
$dbman->create_table($table);
/// Main savepoint reached
upgrade_main_savepoint(true, 2008030600);
}
if ($oldversion < 2008030601) {
//NOTE: this table was added much later later in dev cycle, but we need it here, upgrades from pre PR1 not supported
/// Define table log_queries to be created
$table = new xmldb_table('log_queries');
/// Adding fields to table log_queries
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('qtype', XMLDB_TYPE_INTEGER, '5', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
$table->add_field('sqltext', XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null);
$table->add_field('sqlparams', XMLDB_TYPE_TEXT, 'big', null, null, null, null);
$table->add_field('error', XMLDB_TYPE_INTEGER, '5', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
$table->add_field('info', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
$table->add_field('backtrace', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
$table->add_field('exectime', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null);
$table->add_field('timelogged', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
/// Adding keys to table log_queries
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
/// Conditionally launch create table for log_queries
$dbman->create_table($table);
/// Main savepoint reached
upgrade_main_savepoint(true, 2008030601);
}
if ($oldversion < 2008030602) {
@unlink($CFG->dataroot . '/cache/languages');
if (file_exists("{$CFG->dataroot}/lang")) {
// rename old lang directory so that the new and old langs do not mix
if (rename("{$CFG->dataroot}/lang", "{$CFG->dataroot}/oldlang")) {
$oldlang = "{$CFG->dataroot}/oldlang";
} else {
$oldlang = "{$CFG->dataroot}/lang";
}
} else {
$oldlang = '';
}
// TODO: fetch previously installed languages ("*_utf8") found in $oldlang from moodle.org
upgrade_set_timeout(60 * 20);
// this may take a while
// TODO: add some info file to $oldlang describing what to do with "$oldlang/*_utf8_local" dirs
// Main savepoint reached
upgrade_main_savepoint(true, 2008030602);
}
if ($oldversion < 2008030700) {
upgrade_set_timeout(60 * 20);
// this may take a while
/// Define index contextid-lowerboundary (not unique) to be dropped form grade_letters
$table = new xmldb_table('grade_letters');
$index = new xmldb_index('contextid-lowerboundary', XMLDB_INDEX_NOTUNIQUE, array('contextid', 'lowerboundary'));
/// Launch drop index contextid-lowerboundary
if ($dbman->index_exists($table, $index)) {
$dbman->drop_index($table, $index);
}
/// Define index contextid-lowerboundary-letter (unique) to be added to grade_letters
$table = new xmldb_table('grade_letters');
$index = new xmldb_index('contextid-lowerboundary-letter', XMLDB_INDEX_UNIQUE, array('contextid', 'lowerboundary', 'letter'));
/// Launch add index contextid-lowerboundary-letter
$dbman->add_index($table, $index);
//.........这里部分代码省略.........
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:101,代码来源:upgrade.php
示例3: print_upgrade_part_end
/**
* Default end upgrade callback
* @param string $plugin
* @param bool $installation true if installation, false means upgrade
*/
function print_upgrade_part_end($plugin, $installation, $verbose) {
global $OUTPUT;
upgrade_started();
if ($installation) {
if (empty($plugin) or $plugin == 'moodle') {
upgrade_log(UPGRADE_LOG_NORMAL, $plugin, 'Core installed');
} else {
upgrade_log(UPGRADE_LOG_NORMAL, $plugin, 'Plugin installed');
}
} else {
if (empty($plugin) or $plugin == 'moodle') {
upgrade_log(UPGRADE_LOG_NORMAL, $plugin, 'Core upgraded');
} else {
upgrade_log(UPGRADE_LOG_NORMAL, $plugin, 'Plugin upgraded');
}
}
if ($verbose) {
echo $OUTPUT->notification(get_string('success'), 'notifysuccess');
print_upgrade_separator();
}
}
开发者ID:jtibbetts,项目名称:moodle,代码行数:26,代码来源:upgradelib.php
示例4: page_title
<?php
if (upgrade_ran('4.2.12')) {
page_title('Upgrade 4.2.12 Already Applied');
echo '<p><a href="' . site_prefix() . '/index/upgrade-app">Back</a></p>';
return;
}
page_title('Applying Upgrade 4.2.12');
echo '<p><strong>Applying database updates...</strong></p>';
// database updates
if (upgrade_db(true)) {
echo '<p>Done.</p>';
} else {
echo '<p>Error: ' . db_error() . '</p>';
return;
}
echo '<p><a href="' . site_prefix() . '/index/upgrade-app">Back</a></p>';
upgrade_log();
开发者ID:vojtajina,项目名称:sitellite,代码行数:18,代码来源:index.php
示例5: print_upgrade_part_end
/**
* Default end upgrade callback
* @param string $plugin
* @param bool $installation true if installation, false means upgrade
*/
function print_upgrade_part_end($plugin, $installation, $verbose)
{
global $OUTPUT;
upgrade_started();
if ($installation) {
if (empty($plugin) or $plugin == 'moodle') {
upgrade_log(UPGRADE_LOG_NORMAL, $plugin, 'Core installed');
} else {
upgrade_log(UPGRADE_LOG_NORMAL, $plugin, 'Plugin installed');
}
} else {
if (empty($plugin) or $plugin == 'moodle') {
upgrade_log(UPGRADE_LOG_NORMAL, $plugin, 'Core upgraded');
} else {
upgrade_log(UPGRADE_LOG_NORMAL, $plugin, 'Plugin upgraded');
}
}
if ($verbose) {
$notification = new \core\output\notification(get_string('success'), \core\output\notification::NOTIFY_SUCCESS);
$notification->set_show_closebutton(false);
echo $OUTPUT->render($notification);
print_upgrade_separator();
}
}
开发者ID:dg711,项目名称:moodle,代码行数:29,代码来源:upgradelib.php
示例6: upgrade_migrate_files_course
/**
* Internal function - do not use directly
*/
function upgrade_migrate_files_course($context, $path, $delete)
{
global $CFG, $OUTPUT;
$fullpathname = $CFG->dataroot . '/' . $context->instanceid . $path;
if (!file_exists($fullpathname)) {
return;
}
$items = new DirectoryIterator($fullpathname);
$fs = get_file_storage();
$textlib = textlib_get_instance();
foreach ($items as $item) {
if ($item->isDot()) {
continue;
}
if ($item->isLink()) {
// do not delete symbolic links or its children
$delete_this = false;
} else {
$delete_this = $delete;
}
if (strpos($path, '/backupdata/') === 0) {
$component = 'backup';
$filearea = 'course';
$filepath = substr($path, strlen('/backupdata'));
} else {
$component = 'course';
$filearea = 'legacy';
$filepath = $path;
}
if ($item->isFile()) {
if (!$item->isReadable()) {
$notification = "File not readable, skipping: " . $fullpathname . $item->getFilename();
echo $OUTPUT->notification($notification);
upgrade_log(UPGRADE_LOG_NOTICE, null, $notification);
continue;
}
$filepath = clean_param($filepath, PARAM_PATH);
$filename = clean_param($item->getFilename(), PARAM_FILE);
if ($filename === '') {
//unsupported chars, sorry
continue;
}
if ($textlib->strlen($filepath) > 255) {
// we need something unique and reproducible, sorry no shortening possible
$filepath = '/directory_over_255_chars/' . md5($filepath) . '/';
$oldfile = $fullpathname . $item->getFilename();
$newfile = $filepath . $item->getFilename();
$notification = "File path longer than 255 chars '{$oldfile}', file path truncated to '{$newfile}'";
echo $OUTPUT->notification($notification);
upgrade_log(UPGRADE_LOG_NOTICE, null, $notification);
}
if ($textlib->strlen($filename) > 255) {
//try to shorten, but look for collisions
$oldfile = $fullpathname . $item->getFilename();
$parts = explode('.', $filename);
$ext = array_pop($parts);
$name = implode('.', $parts);
$name = $textlib->substr($name, 0, 254 - $textlib->strlen($ext));
$newfilename = $name . '.' . $ext;
if (file_exists($fullpathname . $newfilename) or $fs->file_exists($context->id, $component, $filearea, '0', $filepath, $newfilename)) {
$filename = 'file_name_over_255_chars' . md5($filename) . $ext;
// bad luck, file with shortened name exists
} else {
$filename = $newfilename;
// shortened name should not cause collisions
}
$notification = "File name longer than 255 chars '{$oldfile}', file name truncated to '{$filename}'";
echo $OUTPUT->notification($notification);
upgrade_log(UPGRADE_LOG_NOTICE, null, $notification);
}
if (!$fs->file_exists($context->id, $component, $filearea, '0', $filepath, $filename)) {
$file_record = array('contextid' => $context->id, 'component' => $component, 'filearea' => $filearea, 'itemid' => 0, 'filepath' => $filepath, 'filename' => $filename, 'timecreated' => $item->getCTime(), 'timemodified' => $item->getMTime());
if ($fs->create_file_from_pathname($file_record, $fullpathname . $item->getFilename())) {
if ($delete_this) {
@unlink($fullpathname . $item->getFilename());
}
}
}
} else {
if ($path == '/' and $item->getFilename() == 'moddata') {
continue;
// modules are responsible
}
$dirname = clean_param($item->getFilename(), PARAM_PATH);
if ($dirname === '') {
//unsupported chars, sorry
continue;
}
$filepath = $filepath . $dirname . '/';
if ($filepath !== '/backupdata/' and $textlib->strlen($filepath) <= 255) {
$fs->create_directory($context->id, $component, $filearea, 0, $filepath);
}
//migrate recursively all subdirectories
upgrade_migrate_files_course($context, $path . $item->getFilename() . '/', $delete_this);
if ($delete_this) {
// delete dir if empty
@rmdir($fullpathname . $item->getFilename());
//.........这里部分代码省略.........
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:101,代码来源:upgradelib.php
示例7: deploy_ingredients
/**
* Adds and upgrades the selected plugins
*
* @param array $ingredients
* @param string $path Path to the ingredient type file system
* @param SimpleXMLElement $xml
* @return array Problems during the ingredients deployment
*/
public function deploy_ingredients($ingredients, $path, SimpleXMLElement $xml)
{
// Using the $ingredients array keys to maintain coherence with the main deployment method
$problems = array();
$pluginman = plugin_manager::instance();
$plugintypespaths = get_plugin_types();
$this->get_flavour_info($xml);
foreach ($ingredients as $selection) {
// [0] => ingredienttype, [1] => ingredientname
$ingredientdata = explode('/', $selection);
$type = $ingredientdata[0];
$ingredient = $ingredientdata[1];
if (empty($this->branches[$type]->branches[$ingredient])) {
$problems[$selection]['pluginnotfound'] = $selection;
continue;
}
$ingredientdata = $this->branches[$type]->branches[$ingredient];
// Adapter to the restrictions array
if (!empty($ingredientdata->restrictions)) {
$problems[$selection] = $ingredientdata->restrictions;
continue;
}
if (empty($xml->{$type}) || empty($xml->{$type}->{$ingredient})) {
$problems[$selection]['pluginnotfound'] = $selection;
continue;
}
// Deploy then
$ingredientpath = $plugintypespaths[$type] . '/' . $ingredient;
// Remove old dir if present
if (file_exists($ingredientpath)) {
// Report if the old plugin directory can't be removed
if (!$this->unlink($ingredientpath)) {
$problems[$selection]['plugincantremove'] = $selection;
continue;
}
}
// Copy the new contents where the flavour says
$tmppath = $path . '/' . $xml->{$type}->{$ingredient}->path;
if (!$this->copy($tmppath, $ingredientpath)) {
debugging('From : ' . $tmppath . ' To: ' . $ingredientpath);
$problems[$selection]['plugincopyerror'] = $selection;
}
}
// Execute the moodle upgrade process
try {
foreach ($plugintypespaths as $type => $location) {
upgrade_plugins($type, 'flavours_print_upgrade_void', 'flavours_print_upgrade_void', false);
}
} catch (Exception $ex) {
abort_all_db_transactions();
$info = get_exception_info($ex);
upgrade_log(UPGRADE_LOG_ERROR, $ex->module, 'Exception: ' . get_class($ex), $info->message, $info->backtrace);
}
return $problems;
}
开发者ID:uofr,项目名称:moodle-local_flavours,代码行数:63,代码来源:flavours_ingredient_plugin.class.php
示例8: print_upgrade_part_end
/**
* Default end upgrade callback
* @param string $plugin
* @param bool $installation true if installation, false menas upgrade
*/
function print_upgrade_part_end($plugin, $installation)
{
upgrade_started();
if ($installation) {
if (empty($plugin) or $plugin == 'moodle') {
upgrade_log(UPGRADE_LOG_NORMAL, $plugin, 'Core installed');
} else {
upgrade_log(UPGRADE_LOG_NORMAL, $plugin, 'Plugin installed');
}
} else {
if (empty($plugin) or $plugin == 'moodle') {
upgrade_log(UPGRADE_LOG_NORMAL, $plugin, 'Core upgraded');
} else {
upgrade_log(UPGRADE_LOG_NORMAL, $plugin, 'Plugin upgraded');
}
}
notify(get_string('success'), 'notifysuccess');
print_upgrade_separator();
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:24,代码来源:upgradelib.php
示例9: xmldb_resource_upgrade
function xmldb_resource_upgrade($oldversion)
{
global $CFG, $DB;
require_once "{$CFG->dirroot}/mod/resource/db/upgradelib.php";
$dbman = $DB->get_manager();
//===== 1.9.0 upgrade line ======//
if ($oldversion < 2009041900) {
resource_20_prepare_migration();
// resource savepoint reached
upgrade_mod_savepoint(true, 2009041900, 'resource');
}
if ($oldversion < 2009042000) {
// Rename field summary on table resource to intro
$table = new xmldb_table('resource');
$field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'reference');
// Launch rename field summary
$dbman->rename_field($table, $field, 'intro');
// resource savepoint reached
upgrade_mod_savepoint(true, 2009042000, 'resource');
}
if ($oldversion < 2009042001) {
// Define field introformat to be added to resource
$table = new xmldb_table('resource');
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
// Launch add field introformat
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// conditionally migrate to html format in intro
if ($CFG->texteditors !== 'textarea') {
$rs = $DB->get_recordset('resource', array('introformat' => FORMAT_MOODLE), '', 'id,intro,introformat');
foreach ($rs as $r) {
$r->intro = text_to_html($r->intro, false, false, true);
$r->introformat = FORMAT_HTML;
$DB->update_record('resource', $r);
upgrade_set_timeout();
}
$rs->close();
}
// resource savepoint reached
upgrade_mod_savepoint(true, 2009042001, 'resource');
}
if ($oldversion < 2009062600) {
$res_count = $DB->count_records('resource');
$old_count = $DB->count_records('resource_old', array('migrated' => 0));
if ($res_count != $old_count) {
//we can not continue, something is very wrong!!
upgrade_log(UPGRADE_LOG_ERROR, null, 'Resource migration failed.');
upgrade_mod_savepoint(false, 2009062600, 'resource');
}
// Drop obsoleted fields from resource table
$table = new xmldb_table('resource');
$fields = array('type', 'reference', 'alltext', 'popup', 'options');
foreach ($fields as $fname) {
$field = new xmldb_field($fname);
$dbman->drop_field($table, $field);
}
// resource savepoint reached
upgrade_mod_savepoint(true, 2009062600, 'resource');
}
if ($oldversion < 2009062601) {
$table = new xmldb_table('resource');
// Define field tobemigrated to be added to resource
$field = new xmldb_field('tobemigrated', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'introformat');
// Conditionally launch add field tobemigrated
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Define field mainfile to be added to resource
$field = new xmldb_field('mainfile', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'tobemigrated');
// Conditionally launch add field mainfile
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Define field legacyfiles to be added to resource
$field = new xmldb_field('legacyfiles', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'mainfile');
// Conditionally launch add field legacyfiles
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Define field legacyfileslast to be added to resource
$field = new xmldb_field('legacyfileslast', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, 'legacyfiles');
// Conditionally launch add field legacyfileslast
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Define field display to be added to resource
$field = new xmldb_field('display', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'legacyfileslast');
// Conditionally launch add field display
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Define field displayoptions to be added to resource
$field = new xmldb_field('displayoptions', XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'display');
// Conditionally launch add field displayoptions
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Define field filterfiles to be added to resource
$field = new xmldb_field('filterfiles', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'displayoptions');
//.........这里部分代码省略.........
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:101,代码来源:upgrade.php
示例10: xmldb_resource_upgrade
/**
* Resource module upgrade code
*
* This file keeps track of upgrades to
* the resource module
*
* Sometimes, changes between versions involve
* alterations to database structures and other
* major things that may break installations.
*
* The upgrade function in this file will attempt
* to perform all the necessary actions to upgrade
* your older installtion to the current version.
*
* If there's something it cannot do itself, it
* will tell you what you need to do.
*
* The commands in here will all be database-neutral,
* using the methods of database_manager class
*
* Please do not forget to use upgrade_set_timeout()
* before any action that may take longer time to finish.
*
* @package mod-resource
* @copyright 2009 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function xmldb_resource_upgrade($oldversion)
{
global $CFG, $DB;
require_once "{$CFG->dirroot}/mod/resource/db/upgradelib.php";
$dbman = $DB->get_manager();
$result = true;
//===== 1.9.0 upgrade line ======//
if ($result && $oldversion < 2009042000) {
// Rename field summary on table resource to intro
$table = new xmldb_table('resource');
$field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'reference');
// Launch rename field summary
$dbman->rename_field($table, $field, 'intro');
// resource savepoint reached
upgrade_mod_savepoint($result, 2009042000, 'resource');
}
if ($result && $oldversion < 2009042001) {
// Define field introformat to be added to resource
$table = new xmldb_table('resource');
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
// Launch add field introformat
$dbman->add_field($table, $field);
// set format to current
$DB->set_field('resource', 'introformat', FORMAT_MOODLE, array());
// resource savepoint reached
upgrade_mod_savepoint($result, 2009042001, 'resource');
}
if ($result && $oldversion < 2009062500) {
// fix log actions
update_log_display_entry('resource', 'view all', 'resource', 'name');
// resource savepoint reached
upgrade_mod_savepoint($result, 2009062500, 'resource');
}
if ($result && $oldversion < 2009062501) {
resource_20_prepare_migration();
// resource savepoint reached
upgrade_mod_savepoint($result, 2009062501, 'resource');
}
if ($result && $oldversion < 2009062600) {
$res_count = $DB->count_records('resource');
$old_count = $DB->count_records('resource_old', array('migrated' => 0));
if ($res_count != $old_count) {
//we can not continue, something is very wrong!!
upgrade_log(UPGRADE_LOG_ERROR, null, 'Resource migration failed.');
upgrade_mod_savepoint(false, 2009062600, 'resource');
}
// Drop obsoleted fields from resource table
$table = new xmldb_table('resource');
$fields = array('type', 'reference', 'alltext', 'popup', 'options');
foreach ($fields as $fname) {
$field = new xmldb_field($fname);
$dbman->drop_field($table, $field);
}
// resource savepoint reached
upgrade_mod_savepoint($result, 2009062600, 'resource');
}
if ($result && $oldversion < 2009062601) {
$table = new xmldb_table('resource');
// Define field tobemigrated to be added to resource
$field = new xmldb_field('tobemigrated', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'introformat');
// Conditionally launch add field tobemigrated
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Define field mainfile to be added to resource
$field = new xmldb_field('mainfile', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'tobemigrated');
// Conditionally launch add field mainfile
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Define field legacyfiles to be added to resource
$field = new xmldb_field('legacyfiles', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'mainfile');
// Conditionally launch add field legacyfiles
//.........这里部分代码省略.........
开发者ID:ajv,项目名称:Offline-Caching,代码行数:101,代码来源:upgrade.php
示例11: xmldb_workshop_upgrade
//.........这里部分代码省略.........
upgrade_mod_savepoint(true, 2009121800, 'workshop');
}
/**
* Add 'evaluation' field into workshop
*/
if ($oldversion < 2010070700) {
$table = new xmldb_table('workshop');
$field = new xmldb_field('evaluation', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, 'strategy');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
upgrade_mod_savepoint(true, 2010070700, 'workshop');
}
/**
* Set the value of the new 'evaluation' field to 'best', there is no alternative at the moment
*/
if ($oldversion < 2010070701) {
$DB->set_field('workshop', 'evaluation', 'best');
upgrade_mod_savepoint(true, 2010070701, 'workshop');
}
/**
* Add 'late' field into workshop_submissions
*/
if ($oldversion < 2010072300) {
$table = new xmldb_table('workshop_submissions');
$field = new xmldb_field('late', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'published');
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
upgrade_mod_savepoint(true, 2010072300, 'workshop');
}
/**
* Create legacy _old tables to sync install.xml and real database
*
* In most cases these tables already exists because they were created during 1.9->2.0 migration
* This step is just for those site that were installed from vanilla 2.0 and these _old tables
* were not created.
* Note that these tables will be dropped again later in 2.x
*/
if ($oldversion < 2010111200) {
foreach (array('workshop', 'workshop_elements', 'workshop_rubrics', 'workshop_submissions', 'workshop_assessments',
'workshop_grades', 'workshop_comments', 'workshop_stockcomments') as $tableorig) {
$tablearchive = $tableorig . '_old';
if (!$dbman->table_exists($tablearchive)) {
$dbman->install_one_table_from_xmldb_file($CFG->dirroot.'/mod/workshop/db/install.xml', $tablearchive);
}
}
upgrade_mod_savepoint(true, 2010111200, 'workshop');
}
/**
* Check the course_module integrity - see MDL-26312 for details
*
* Because of a bug in Workshop upgrade code, multiple workshop course_modules can
* potentially point to a single workshop instance. The chance is pretty low as in most cases,
* the upgrade failed. But under certain circumstances, workshop could be upgraded with
* this data integrity issue. We want to detect it now and let the admin know.
*/
if ($oldversion < 2011021100) {
$sql = "SELECT cm.id, cm.course, cm.instance
FROM {course_modules} cm
WHERE cm.module IN (SELECT id
FROM {modules}
WHERE name = ?)";
$rs = $DB->get_recordset_sql($sql, array('workshop'));
$map = array(); // returned stdClasses by instance id
foreach ($rs as $cm) {
$map[$cm->instance][$cm->id] = $cm;
}
$rs->close();
$problems = array();
foreach ($map as $instanceid => $cms) {
if (count($cms) > 1) {
$problems[] = 'workshop instance ' . $instanceid . ' referenced by course_modules ' . implode(', ', array_keys($cms));
}
}
if ($problems) {
echo $OUTPUT->notification('¡Ay, caramba! Data integrity corruption has been detected in your workshop ' . PHP_EOL .
'module database tables. This might be caused by a bug in workshop upgrade code. ' . PHP_EOL .
'Please report this issue immediately in workshop module support forum at ' . PHP_EOL .
'http://moodle.org so that we can help to fix this problem. Please copy and keep ' . PHP_EOL .
'following information for future reference:');
foreach ($problems as $problem) {
echo $OUTPUT->notification($problem);
upgrade_log(UPGRADE_LOG_NOTICE, 'mod_workshop', 'course_modules integrity problem', $problem);
}
}
unset($problems);
unset($map);
upgrade_mod_savepoint(true, 2011021100, 'workshop');
}
return true;
}
开发者ID:nuckey,项目名称:moodle,代码行数:101,代码来源:upgrade.php
示例12: default_exception_handler
/**
* Default exception handler, uncought exceptions are equivalent to using print_error()
*
* @param Exception $ex
* @param boolean $isupgrade
* @param string $plugin
* Does not return. Terminates execution.
*/
function default_exception_handler($ex, $isupgrade = false, $plugin = null)
{
global $CFG, $DB, $OUTPUT, $SCRIPT;
// detect active db transactions, rollback and log as error
if ($DB && $DB->is_transaction_started()) {
error_log('Database transaction aborted by exception in ' . $CFG->dirroot . $SCRIPT);
try {
// note: transaction blocks should never change current $_SESSION
$DB->rollback_sql();
} catch (Exception $ignored) {
}
}
$backtrace = $ex->getTrace();
$place = array('file' => $ex->getFile(), 'line' => $ex->getLine(), 'exception' => get_class($ex));
array_unshift($backtrace, $place);
if ($ex instanceof moodle_exception) {
$errorcode = $ex->errorcode;
$module = $ex->module;
$a = $ex->a;
$link = $ex->link;
$debuginfo = $ex->debuginfo;
} else {
$errorcode = 'generalexceptionmessage';
$module = 'error';
$a = $ex->getMessage();
$link = '';
$debuginfo = null;
}
list($message, $moreinfourl, $link) = prepare_error_message($errorcode, $module, $link, $a);
if ($isupgrade) {
// First log upgrade error
upgrade_log(UPGRADE_LOG_ERROR, $plugin, 'Exception: ' . get_class($ex), $message, $backtrace);
// Always turn on debugging - admins need to know what is going on
$CFG->debug = DEBUG_DEVELOPER;
}
if (is_stacktrace_during_output_init($backtrace)) {
echo bootstrap_renderer::early_error($message, $moreinfourl, $link, $backtrace, $debuginfo);
} else {
echo $OUTPUT->fatal_error($message, $moreinfourl, $link, $backtrace, $debuginfo);
}
exit(1);
// General error code
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:51,代码来源:setuplib.php
注:本文中的upgrade_log函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论