mirror of
https://github.com/moodle/moodle.git
synced 2025-08-03 16:13:28 +02:00
MDL-42973 fix multiple addon update issues
This commit is contained in:
parent
c36a2401ab
commit
fc28111316
5 changed files with 151 additions and 137 deletions
108
admin/index.php
108
admin/index.php
|
@ -47,7 +47,9 @@ if (!function_exists('iconv')) {
|
||||||
|
|
||||||
define('NO_OUTPUT_BUFFERING', true);
|
define('NO_OUTPUT_BUFFERING', true);
|
||||||
|
|
||||||
if (empty($_GET['cache']) and empty($_POST['cache']) and empty($_GET['sesskey']) and empty($_POST['sesskey'])) {
|
if ((isset($_GET['cache']) and $_GET['cache'] === '0')
|
||||||
|
or (isset($_POST['cache']) and $_POST['cache'] === '0')
|
||||||
|
or (!isset($_POST['cache']) and !isset($_GET['cache']) and empty($_GET['sesskey']) and empty($_POST['sesskey']))) {
|
||||||
// Prevent caching at all cost when visiting this page directly,
|
// Prevent caching at all cost when visiting this page directly,
|
||||||
// we redirect to self once we known no upgrades are necessary.
|
// we redirect to self once we known no upgrades are necessary.
|
||||||
// Note: $_GET and $_POST are used here intentionally because our param cleaning is not loaded yet.
|
// Note: $_GET and $_POST are used here intentionally because our param cleaning is not loaded yet.
|
||||||
|
@ -90,9 +92,7 @@ $newaddonreq = optional_param('installaddonrequest', null, PARAM_RAW);
|
||||||
|
|
||||||
// Set up PAGE.
|
// Set up PAGE.
|
||||||
$url = new moodle_url('/admin/index.php');
|
$url = new moodle_url('/admin/index.php');
|
||||||
if ($cache) {
|
$url->param('cache', $cache);
|
||||||
$url->param('cache', 1);
|
|
||||||
}
|
|
||||||
$PAGE->set_url($url);
|
$PAGE->set_url($url);
|
||||||
unset($url);
|
unset($url);
|
||||||
|
|
||||||
|
@ -267,12 +267,13 @@ if (!$cache and $version > $CFG->version) { // upgrade
|
||||||
$PAGE->set_pagelayout('maintenance');
|
$PAGE->set_pagelayout('maintenance');
|
||||||
$PAGE->set_popup_notification_allowed(false);
|
$PAGE->set_popup_notification_allowed(false);
|
||||||
|
|
||||||
|
/** @var core_admin_renderer $output */
|
||||||
|
$output = $PAGE->get_renderer('core', 'admin');
|
||||||
|
|
||||||
if (upgrade_stale_php_files_present()) {
|
if (upgrade_stale_php_files_present()) {
|
||||||
$PAGE->set_title($stradministration);
|
$PAGE->set_title($stradministration);
|
||||||
$PAGE->set_cacheable(false);
|
$PAGE->set_cacheable(false);
|
||||||
|
|
||||||
/** @var core_admin_renderer $output */
|
|
||||||
$output = $PAGE->get_renderer('core', 'admin');
|
|
||||||
echo $output->upgrade_stale_php_files_page();
|
echo $output->upgrade_stale_php_files_page();
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
@ -287,8 +288,6 @@ if (!$cache and $version > $CFG->version) { // upgrade
|
||||||
$PAGE->set_heading($strdatabasechecking);
|
$PAGE->set_heading($strdatabasechecking);
|
||||||
$PAGE->set_cacheable(false);
|
$PAGE->set_cacheable(false);
|
||||||
|
|
||||||
/** @var core_admin_renderer $output */
|
|
||||||
$output = $PAGE->get_renderer('core', 'admin');
|
|
||||||
echo $output->upgrade_confirm_page($a->newversion, $maturity, $testsite);
|
echo $output->upgrade_confirm_page($a->newversion, $maturity, $testsite);
|
||||||
die();
|
die();
|
||||||
|
|
||||||
|
@ -302,8 +301,6 @@ if (!$cache and $version > $CFG->version) { // upgrade
|
||||||
$PAGE->set_heading($strcurrentrelease);
|
$PAGE->set_heading($strcurrentrelease);
|
||||||
$PAGE->set_cacheable(false);
|
$PAGE->set_cacheable(false);
|
||||||
|
|
||||||
/** @var core_admin_renderer $output */
|
|
||||||
$output = $PAGE->get_renderer('core', 'admin');
|
|
||||||
echo $output->upgrade_environment_page($release, $envstatus, $environment_results);
|
echo $output->upgrade_environment_page($release, $envstatus, $environment_results);
|
||||||
die();
|
die();
|
||||||
|
|
||||||
|
@ -315,23 +312,13 @@ if (!$cache and $version > $CFG->version) { // upgrade
|
||||||
$PAGE->set_heading($strplugincheck);
|
$PAGE->set_heading($strplugincheck);
|
||||||
$PAGE->set_cacheable(false);
|
$PAGE->set_cacheable(false);
|
||||||
|
|
||||||
$reloadurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1));
|
$reloadurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1, 'cache' => 0));
|
||||||
|
|
||||||
/** @var core_admin_renderer $output */
|
|
||||||
$output = $PAGE->get_renderer('core', 'admin');
|
|
||||||
|
|
||||||
// check plugin dependencies first
|
|
||||||
$failed = array();
|
|
||||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
|
||||||
echo $output->unsatisfied_dependencies_page($version, $failed, $reloadurl);
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
unset($failed);
|
|
||||||
|
|
||||||
if ($fetchupdates) {
|
if ($fetchupdates) {
|
||||||
// no sesskey support guaranteed here
|
// No sesskey support guaranteed here, because sessions might not work yet.
|
||||||
if (empty($CFG->disableupdatenotifications)) {
|
$updateschecker = \core\update\checker::instance();
|
||||||
\core\update\checker::instance()->fetch();
|
if ($updateschecker->enabled()) {
|
||||||
|
$updateschecker->fetch();
|
||||||
}
|
}
|
||||||
redirect($reloadurl);
|
redirect($reloadurl);
|
||||||
}
|
}
|
||||||
|
@ -342,6 +329,7 @@ if (!$cache and $version > $CFG->version) { // upgrade
|
||||||
|
|
||||||
$deploydata = $deployer->submitted_data();
|
$deploydata = $deployer->submitted_data();
|
||||||
if (!empty($deploydata)) {
|
if (!empty($deploydata)) {
|
||||||
|
// No sesskey support guaranteed here, because sessions might not work yet.
|
||||||
echo $output->upgrade_plugin_confirm_deploy_page($deployer, $deploydata);
|
echo $output->upgrade_plugin_confirm_deploy_page($deployer, $deploydata);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
@ -349,11 +337,22 @@ if (!$cache and $version > $CFG->version) { // upgrade
|
||||||
|
|
||||||
echo $output->upgrade_plugin_check_page(core_plugin_manager::instance(), \core\update\checker::instance(),
|
echo $output->upgrade_plugin_check_page(core_plugin_manager::instance(), \core\update\checker::instance(),
|
||||||
$version, $showallplugins, $reloadurl,
|
$version, $showallplugins, $reloadurl,
|
||||||
new moodle_url('/admin/index.php', array('confirmupgrade'=>1, 'confirmrelease'=>1, 'confirmplugincheck'=>1)));
|
new moodle_url('/admin/index.php', array('confirmupgrade'=>1, 'confirmrelease'=>1, 'confirmplugincheck'=>1, 'cache'=>0)));
|
||||||
die();
|
die();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Launch main upgrade
|
// Always verify plugin dependencies!
|
||||||
|
$failed = array();
|
||||||
|
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||||
|
$PAGE->set_pagelayout('maintenance');
|
||||||
|
$PAGE->set_popup_notification_allowed(false);
|
||||||
|
$reloadurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1, 'cache' => 0));
|
||||||
|
echo $output->unsatisfied_dependencies_page($version, $failed, $reloadurl);
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
unset($failed);
|
||||||
|
|
||||||
|
// Launch main upgrade.
|
||||||
upgrade_core($version, true);
|
upgrade_core($version, true);
|
||||||
}
|
}
|
||||||
} else if ($version < $CFG->version) {
|
} else if ($version < $CFG->version) {
|
||||||
|
@ -373,6 +372,10 @@ if (!$cache and $branch <> $CFG->branch) { // Update the branch
|
||||||
if (!$cache and moodle_needs_upgrading()) {
|
if (!$cache and moodle_needs_upgrading()) {
|
||||||
if (!$PAGE->headerprinted) {
|
if (!$PAGE->headerprinted) {
|
||||||
// means core upgrade or installation was not already done
|
// means core upgrade or installation was not already done
|
||||||
|
|
||||||
|
/** @var core_admin_renderer $output */
|
||||||
|
$output = $PAGE->get_renderer('core', 'admin');
|
||||||
|
|
||||||
if (!$confirmplugins) {
|
if (!$confirmplugins) {
|
||||||
$strplugincheck = get_string('plugincheck');
|
$strplugincheck = get_string('plugincheck');
|
||||||
|
|
||||||
|
@ -384,40 +387,46 @@ if (!$cache and moodle_needs_upgrading()) {
|
||||||
$PAGE->set_cacheable(false);
|
$PAGE->set_cacheable(false);
|
||||||
|
|
||||||
if ($fetchupdates) {
|
if ($fetchupdates) {
|
||||||
// no sesskey support guaranteed here
|
require_sesskey();
|
||||||
\core\update\checker::instance()->fetch();
|
$updateschecker = \core\update\checker::instance();
|
||||||
|
if ($updateschecker->enabled()) {
|
||||||
|
$updateschecker->fetch();
|
||||||
|
}
|
||||||
redirect($PAGE->url);
|
redirect($PAGE->url);
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = $PAGE->get_renderer('core', 'admin');
|
|
||||||
|
|
||||||
$deployer = \core\update\deployer::instance();
|
$deployer = \core\update\deployer::instance();
|
||||||
if ($deployer->enabled()) {
|
if ($deployer->enabled()) {
|
||||||
$deployer->initialize($PAGE->url, $PAGE->url);
|
$deployer->initialize($PAGE->url, $PAGE->url);
|
||||||
|
|
||||||
$deploydata = $deployer->submitted_data();
|
$deploydata = $deployer->submitted_data();
|
||||||
if (!empty($deploydata)) {
|
if (!empty($deploydata)) {
|
||||||
|
require_sesskey();
|
||||||
echo $output->upgrade_plugin_confirm_deploy_page($deployer, $deploydata);
|
echo $output->upgrade_plugin_confirm_deploy_page($deployer, $deploydata);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check plugin dependencies first
|
// Show plugins info.
|
||||||
$failed = array();
|
|
||||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
|
||||||
echo $output->unsatisfied_dependencies_page($version, $failed, $PAGE->url);
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
unset($failed);
|
|
||||||
|
|
||||||
// dependencies check passed, let's rock!
|
|
||||||
echo $output->upgrade_plugin_check_page(core_plugin_manager::instance(), \core\update\checker::instance(),
|
echo $output->upgrade_plugin_check_page(core_plugin_manager::instance(), \core\update\checker::instance(),
|
||||||
$version, $showallplugins,
|
$version, $showallplugins,
|
||||||
new moodle_url($PAGE->url),
|
new moodle_url($PAGE->url),
|
||||||
new moodle_url('/admin/index.php', array('confirmplugincheck'=>1)));
|
new moodle_url('/admin/index.php', array('confirmplugincheck'=>1, 'cache'=>0)));
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure plugin dependencies are always checked.
|
||||||
|
$failed = array();
|
||||||
|
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||||
|
$PAGE->set_pagelayout('maintenance');
|
||||||
|
$PAGE->set_popup_notification_allowed(false);
|
||||||
|
$reloadurl = new moodle_url('/admin/index.php', array('cache' => 0));
|
||||||
|
echo $output->unsatisfied_dependencies_page($version, $failed, $reloadurl);
|
||||||
|
die();
|
||||||
}
|
}
|
||||||
|
unset($failed);
|
||||||
|
}
|
||||||
|
|
||||||
// install/upgrade all plugins and other parts
|
// install/upgrade all plugins and other parts
|
||||||
upgrade_noncore(true);
|
upgrade_noncore(true);
|
||||||
}
|
}
|
||||||
|
@ -477,6 +486,17 @@ if (during_initial_install()) {
|
||||||
upgrade_finished('upgradesettings.php');
|
upgrade_finished('upgradesettings.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (has_capability('moodle/site:config', context_system::instance())) {
|
||||||
|
if ($fetchupdates) {
|
||||||
|
require_sesskey();
|
||||||
|
$updateschecker = \core\update\checker::instance();
|
||||||
|
if ($updateschecker->enabled()) {
|
||||||
|
$updateschecker->fetch();
|
||||||
|
}
|
||||||
|
redirect(new moodle_url('/admin/index.php', array('cache' => 0)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Now we can be sure everything was upgraded and caches work fine,
|
// Now we can be sure everything was upgraded and caches work fine,
|
||||||
// redirect if necessary to make sure caching is enabled.
|
// redirect if necessary to make sure caching is enabled.
|
||||||
if (!$cache) {
|
if (!$cache) {
|
||||||
|
@ -564,12 +584,6 @@ $registered = $DB->count_records('registration_hubs', array('huburl' => HUB_MOOD
|
||||||
|
|
||||||
admin_externalpage_setup('adminnotifications');
|
admin_externalpage_setup('adminnotifications');
|
||||||
|
|
||||||
if ($fetchupdates) {
|
|
||||||
require_sesskey();
|
|
||||||
$updateschecker->fetch();
|
|
||||||
redirect(new moodle_url('/admin/index.php'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$output = $PAGE->get_renderer('core', 'admin');
|
$output = $PAGE->get_renderer('core', 'admin');
|
||||||
echo $output->admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
|
echo $output->admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
|
||||||
$cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch, $buggyiconvnomb,
|
$cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch, $buggyiconvnomb,
|
||||||
|
|
|
@ -140,7 +140,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||||
public function upgrade_confirm_page($strnewversion, $maturity, $testsite) {
|
public function upgrade_confirm_page($strnewversion, $maturity, $testsite) {
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
$continueurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1));
|
$continueurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'cache' => 0));
|
||||||
$continue = new single_button($continueurl, get_string('continue'), 'get');
|
$continue = new single_button($continueurl, get_string('continue'), 'get');
|
||||||
$cancelurl = new moodle_url('/admin/index.php');
|
$cancelurl = new moodle_url('/admin/index.php');
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||||
$output .= $this->environment_check_table($envstatus, $environment_results);
|
$output .= $this->environment_check_table($envstatus, $environment_results);
|
||||||
|
|
||||||
if (!$envstatus) {
|
if (!$envstatus) {
|
||||||
$output .= $this->upgrade_reload(new moodle_url('/admin/index.php'), array('confirmupgrade' => 1));
|
$output .= $this->upgrade_reload(new moodle_url('/admin/index.php'), array('confirmupgrade' => 1, 'cache' => 0));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess');
|
$output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess');
|
||||||
|
@ -179,7 +179,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||||
$output .= $this->box(get_string('langpackwillbeupdated', 'admin'), 'generalbox', 'notice');
|
$output .= $this->box(get_string('langpackwillbeupdated', 'admin'), 'generalbox', 'notice');
|
||||||
}
|
}
|
||||||
|
|
||||||
$output .= $this->continue_button(new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1)));
|
$output .= $this->continue_button(new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1, 'cache' => 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$output .= $this->footer();
|
$output .= $this->footer();
|
||||||
|
@ -711,7 +711,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||||
}
|
}
|
||||||
|
|
||||||
$updateinfo .= $this->container_start('checkforupdates');
|
$updateinfo .= $this->container_start('checkforupdates');
|
||||||
$fetchurl = new moodle_url('/admin/index.php', array('fetchupdates' => 1, 'sesskey' => sesskey(), 'cache' => 1));
|
$fetchurl = new moodle_url('/admin/index.php', array('fetchupdates' => 1, 'sesskey' => sesskey(), 'cache' => 0));
|
||||||
$updateinfo .= $this->single_button($fetchurl, get_string('checkforupdates', 'core_plugin'));
|
$updateinfo .= $this->single_button($fetchurl, get_string('checkforupdates', 'core_plugin'));
|
||||||
if ($fetch) {
|
if ($fetch) {
|
||||||
$updateinfo .= $this->container(get_string('checkforupdateslast', 'core_plugin',
|
$updateinfo .= $this->container(get_string('checkforupdateslast', 'core_plugin',
|
||||||
|
@ -962,7 +962,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||||
$out .= $this->output->heading(get_string('nonehighlighted', 'core_plugin'));
|
$out .= $this->output->heading(get_string('nonehighlighted', 'core_plugin'));
|
||||||
if (empty($options['full'])) {
|
if (empty($options['full'])) {
|
||||||
$out .= html_writer::link(new moodle_url('/admin/index.php',
|
$out .= html_writer::link(new moodle_url('/admin/index.php',
|
||||||
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1)),
|
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1, 'cache' => 0)),
|
||||||
get_string('nonehighlightedinfo', 'core_plugin'));
|
get_string('nonehighlightedinfo', 'core_plugin'));
|
||||||
}
|
}
|
||||||
$out .= $this->output->container_end();
|
$out .= $this->output->container_end();
|
||||||
|
@ -972,11 +972,11 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||||
$out .= $this->output->heading(get_string('somehighlighted', 'core_plugin', $sumofhighlighted));
|
$out .= $this->output->heading(get_string('somehighlighted', 'core_plugin', $sumofhighlighted));
|
||||||
if (empty($options['full'])) {
|
if (empty($options['full'])) {
|
||||||
$out .= html_writer::link(new moodle_url('/admin/index.php',
|
$out .= html_writer::link(new moodle_url('/admin/index.php',
|
||||||
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1)),
|
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1, 'cache' => 0)),
|
||||||
get_string('somehighlightedinfo', 'core_plugin'));
|
get_string('somehighlightedinfo', 'core_plugin'));
|
||||||
} else {
|
} else {
|
||||||
$out .= html_writer::link(new moodle_url('/admin/index.php',
|
$out .= html_writer::link(new moodle_url('/admin/index.php',
|
||||||
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 0)),
|
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 0, 'cache' => 0)),
|
||||||
get_string('somehighlightedonly', 'core_plugin'));
|
get_string('somehighlightedonly', 'core_plugin'));
|
||||||
}
|
}
|
||||||
$out .= $this->output->container_end();
|
$out .= $this->output->container_end();
|
||||||
|
|
|
@ -81,6 +81,18 @@ class checker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is automatic deployment enabled?
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function enabled() {
|
||||||
|
global $CFG;
|
||||||
|
|
||||||
|
// The feature can be prohibited via config.php.
|
||||||
|
return empty($CFG->disableupdateautodeploy);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the timestamp of the last execution of {@link fetch()}
|
* Returns the timestamp of the last execution of {@link fetch()}
|
||||||
*
|
*
|
||||||
|
|
|
@ -32,9 +32,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||||
*/
|
*/
|
||||||
class deployer {
|
class deployer {
|
||||||
|
|
||||||
const HTTP_PARAM_PREFIX = 'updteautodpldata_'; // Hey, even Google has not heard of such a prefix! So it MUST be safe :-p.
|
|
||||||
const HTTP_PARAM_CHECKER = 'datapackagesize'; // Name of the parameter that holds the number of items in the received data items.
|
|
||||||
|
|
||||||
/** @var \core\update\deployer holds the singleton instance */
|
/** @var \core\update\deployer holds the singleton instance */
|
||||||
protected static $singletoninstance;
|
protected static $singletoninstance;
|
||||||
/** @var moodle_url URL of a page that includes the deployer UI */
|
/** @var moodle_url URL of a page that includes the deployer UI */
|
||||||
|
@ -207,9 +204,19 @@ class deployer {
|
||||||
throw new coding_exception('Illegal method call - deployer not initialized.');
|
throw new coding_exception('Illegal method call - deployer not initialized.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$params = $this->data_to_params(array(
|
$params = array(
|
||||||
'updateinfo' => (array)$info, // See http://www.php.net/manual/en/language.types.array.php#language.types.array.casting .
|
'updateaddon' => $info->component,
|
||||||
));
|
'version' =>$info->version,
|
||||||
|
'sesskey' => sesskey(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Append some our own data.
|
||||||
|
if (!empty($this->callerurl)) {
|
||||||
|
$params['callerurl'] = $this->callerurl->out(false);
|
||||||
|
}
|
||||||
|
if (!empty($this->returnurl)) {
|
||||||
|
$params['returnurl'] = $this->returnurl->out(false);
|
||||||
|
}
|
||||||
|
|
||||||
$widget = new \single_button(
|
$widget = new \single_button(
|
||||||
new moodle_url($this->callerurl, $params),
|
new moodle_url($this->callerurl, $params),
|
||||||
|
@ -301,25 +308,46 @@ class deployer {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function submitted_data() {
|
public function submitted_data() {
|
||||||
|
$component = optional_param('updateaddon', '', PARAM_COMPONENT);
|
||||||
$data = $this->params_to_data($_POST);
|
$version = optional_param('version', '', PARAM_RAW);
|
||||||
|
if (!$component or !$version) {
|
||||||
if (empty($data) or empty($data[self::HTTP_PARAM_CHECKER])) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['updateinfo']) and is_object($data['updateinfo'])) {
|
$plugininfo = \core_plugin_manager::instance()->get_plugin_info($component);
|
||||||
$updateinfo = $data['updateinfo'];
|
if (!$plugininfo) {
|
||||||
if (!empty($updateinfo->component) and !empty($updateinfo->version)) {
|
return false;
|
||||||
$data['updateinfo'] = new info($updateinfo->component, (array)$updateinfo);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['callerurl'])) {
|
if ($plugininfo->is_standard()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$updates = $plugininfo->available_updates()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$info = null;
|
||||||
|
foreach ($updates as $update) {
|
||||||
|
if ($update->version == $version) {
|
||||||
|
$info = $update;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$info) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = array(
|
||||||
|
'updateaddon' => $component,
|
||||||
|
'updateinfo' => $info,
|
||||||
|
'callerurl' => optional_param('callerurl', null, PARAM_URL),
|
||||||
|
'returnurl' => optional_param('returnurl', null, PARAM_URL),
|
||||||
|
);
|
||||||
|
if ($data['callerurl']) {
|
||||||
$data['callerurl'] = new moodle_url($data['callerurl']);
|
$data['callerurl'] = new moodle_url($data['callerurl']);
|
||||||
}
|
}
|
||||||
|
if ($data['callerurl']) {
|
||||||
if (!empty($data['returnurl'])) {
|
|
||||||
$data['returnurl'] = new moodle_url($data['returnurl']);
|
$data['returnurl'] = new moodle_url($data['returnurl']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,60 +449,6 @@ class deployer {
|
||||||
|
|
||||||
/* === End of external API === */
|
/* === End of external API === */
|
||||||
|
|
||||||
/**
|
|
||||||
* Prepares an array of HTTP parameters that can be passed to another page.
|
|
||||||
*
|
|
||||||
* @param array|object $data associative array or an object holding the data, data JSON-able
|
|
||||||
* @return array suitable as a param for moodle_url
|
|
||||||
*/
|
|
||||||
protected function data_to_params($data) {
|
|
||||||
|
|
||||||
// Append some our own data.
|
|
||||||
if (!empty($this->callerurl)) {
|
|
||||||
$data['callerurl'] = $this->callerurl->out(false);
|
|
||||||
}
|
|
||||||
if (!empty($this->returnurl)) {
|
|
||||||
$data['returnurl'] = $this->returnurl->out(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally append the count of items in the package.
|
|
||||||
$data[self::HTTP_PARAM_CHECKER] = count($data);
|
|
||||||
|
|
||||||
// Generate params.
|
|
||||||
$params = array();
|
|
||||||
foreach ($data as $name => $value) {
|
|
||||||
$transname = self::HTTP_PARAM_PREFIX.$name;
|
|
||||||
$transvalue = json_encode($value);
|
|
||||||
$params[$transname] = $transvalue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $params;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts HTTP parameters passed to the script into native PHP data
|
|
||||||
*
|
|
||||||
* @param array $params such as $_REQUEST or $_POST
|
|
||||||
* @return array data passed for this class
|
|
||||||
*/
|
|
||||||
protected function params_to_data(array $params) {
|
|
||||||
|
|
||||||
if (empty($params)) {
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = array();
|
|
||||||
foreach ($params as $name => $value) {
|
|
||||||
if (strpos($name, self::HTTP_PARAM_PREFIX) === 0) {
|
|
||||||
$realname = substr($name, strlen(self::HTTP_PARAM_PREFIX));
|
|
||||||
$realvalue = json_decode($value);
|
|
||||||
$data[$realname] = $realvalue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a random string to be used as a filename of the password storage.
|
* Returns a random string to be used as a filename of the password storage.
|
||||||
*
|
*
|
||||||
|
@ -511,8 +485,14 @@ class deployer {
|
||||||
$directory = core_component::get_plugin_directory($plugintype, $pluginname);
|
$directory = core_component::get_plugin_directory($plugintype, $pluginname);
|
||||||
|
|
||||||
if (is_null($directory)) {
|
if (is_null($directory)) {
|
||||||
|
// Plugin unknown, most probably deleted or missing during upgrade,
|
||||||
|
// look at the parent directory instead because they might want to install it.
|
||||||
|
$plugintypes = core_component::get_plugin_types();
|
||||||
|
if (!isset($plugintypes[$plugintype])) {
|
||||||
throw new coding_exception('Unknown component location', $component);
|
throw new coding_exception('Unknown component location', $component);
|
||||||
}
|
}
|
||||||
|
$directory = $plugintypes[$plugintype];
|
||||||
|
}
|
||||||
|
|
||||||
return $this->directory_writable($directory);
|
return $this->directory_writable($directory);
|
||||||
}
|
}
|
||||||
|
|
|
@ -780,6 +780,7 @@ class worker extends singleton_pattern {
|
||||||
$this->log('Current plugin code location: '.$sourcelocation);
|
$this->log('Current plugin code location: '.$sourcelocation);
|
||||||
$this->log('Moving the current code into archive: '.$backuplocation);
|
$this->log('Moving the current code into archive: '.$backuplocation);
|
||||||
|
|
||||||
|
if (file_exists($sourcelocation)) {
|
||||||
// We don't want to touch files unless we are pretty sure it would be all ok.
|
// We don't want to touch files unless we are pretty sure it would be all ok.
|
||||||
if (!$this->move_directory_source_precheck($sourcelocation)) {
|
if (!$this->move_directory_source_precheck($sourcelocation)) {
|
||||||
throw new backup_folder_exception('Unable to backup the current version of the plugin (source precheck failed)');
|
throw new backup_folder_exception('Unable to backup the current version of the plugin (source precheck failed)');
|
||||||
|
@ -793,6 +794,13 @@ class worker extends singleton_pattern {
|
||||||
throw new backup_folder_exception('Unable to backup the current version of the plugin (moving failed)');
|
throw new backup_folder_exception('Unable to backup the current version of the plugin (moving failed)');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Upgrading missing plugin - this happens often during upgrades.
|
||||||
|
if (!$this->create_directory_precheck($sourcelocation)) {
|
||||||
|
throw new filesystem_exception('Unable to prepare the plugin location (cannot create new directory)');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Unzip the plugin package file into the target location.
|
// Unzip the plugin package file into the target location.
|
||||||
$this->unzip_plugin($target, $plugintyperoot, $sourcelocation, $backuplocation);
|
$this->unzip_plugin($target, $plugintyperoot, $sourcelocation, $backuplocation);
|
||||||
$this->log('Package successfully extracted');
|
$this->log('Package successfully extracted');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue