Skip to content

Commit

Permalink
MDL-42668 portfolio_boxnet: Do not run upgrade multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Massart committed Nov 7, 2013
1 parent a5a84cc commit def961f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions portfolio/boxnet/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,27 @@ function xmldb_portfolio_boxnet_upgrade($oldversion) {

$dbman = $DB->get_manager();

if ($oldversion < 2013110600) {
if ($oldversion < 2013110602) {
require_once($CFG->libdir . '/portfoliolib.php');
require_once($CFG->dirroot . '/portfolio/boxnet/db/upgradelib.php');

$existing = $DB->get_record('portfolio_instance', array('plugin' => 'boxnet'), '*', IGNORE_MULTIPLE);
if ($existing) {

// Disable Box.net.
// Only disable or message the admins when the portfolio hasn't been set for APIv2.
$instance = portfolio_instance($existing->id, $existing);
$instance->set('visible', 0);
$instance->save();
if ($instance->get_config('clientid') === null && $instance->get_config('clientsecret') === null) {

// Message the admins.
portfolio_boxnet_admin_upgrade_notification();
// Disable Box.net.
$instance->set('visible', 0);
$instance->save();

// Message the admins.
portfolio_boxnet_admin_upgrade_notification();
}
}

upgrade_plugin_savepoint(true, 2013110600, 'portfolio', 'boxnet');
upgrade_plugin_savepoint(true, 2013110602, 'portfolio', 'boxnet');
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion portfolio/boxnet/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2013110600; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2013110602; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'portfolio_boxnet'; // Full name of the plugin (used for diagnostics)
$plugin->cron = 0;

0 comments on commit def961f

Please sign in to comment.