Skip to content

Commit

Permalink
MDL-76053 admin: Remove various warnings related to MNet
Browse files Browse the repository at this point in the history
This partially reverts MDL-73270, where some useful environmental
checks and notifications in the admin UI were added to inform
about different parts of Moodle relying on the "unsupported"
php-xmlrpc extension.

Since then, some changes have happened in core, only available
for Moodle 4.1 and up (see the MDL-70889 mini-epic). Namely:

  - MNet (SSO, roaming, auth, enrol and Mahara portfolio) are not
    using the php-xmlrpc extension anymore, but a pure php library.
  - The xmlrpc webservices protocol, has been move from core to
    the plugins directory, although it continues using the php-xmlrpc
    extension.

Because of that here we are removing all the checks and notifications
related with MNet (not using the extension anymore), but keeping the
webservice plugin ones (still using the extension). Surely if some day the
protocol stops using the extension, we'll be able to remove the
corresponding checks too. But that's future.

Note the associated lang strings have been also removed (not deprecated)
because they were highly specific and hardly reusable:
  - xmlrpcmaharaenabled
  - xmlrpcmnetauthenticationenabled
  - xmlrpcmnetenabled

And very same applies, because MNet doesn't contain anything deprecated
or not supported anymore, hence, straight deletion, to the function:
  - mnet_get_deprecation_notice()

Also, related tests using any of the removed stuff above have been deleted.

In the other side, the "check_xmlrpc_usage" continues existing and
being used both by environment checks and admin notifications but,
as commented above, now it only looks for the xmlrpc webservice
protocol now.
  • Loading branch information
stronk7 committed Nov 8, 2022
1 parent 5877ae3 commit 621d75d
Show file tree
Hide file tree
Showing 14 changed files with 1 addition and 125 deletions.
1 change: 0 additions & 1 deletion admin/mnet/access_control.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@
}

echo $OUTPUT->header();
echo $OUTPUT->render(mnet_get_deprecation_notice());

// Explain
echo $OUTPUT->box(get_string('ssoacldescr','mnet'));
Expand Down
1 change: 0 additions & 1 deletion admin/mnet/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
$hosts = $DB->get_records_select('mnet_host', "id <> ? AND deleted = 0", array($CFG->mnet_localhost_id), 'wwwroot ASC');

echo $OUTPUT->header();
echo $OUTPUT->render(mnet_get_deprecation_notice());
?>
<form method="post" action="index.php">
<table align="center" width="635" class="generaltable" border="0" cellpadding="5" cellspacing="0">
Expand Down
5 changes: 0 additions & 5 deletions admin/mnet/peers.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@
$PAGE->set_url('/admin/mnet/peers.php');
admin_externalpage_setup($adminsection);

$deprecatenotify = mnet_get_deprecation_notice();

if (!extension_loaded('openssl')) {
throw new \moodle_exception('requiresopenssl', 'mnet');
}
Expand Down Expand Up @@ -88,7 +86,6 @@
$formdata->oldpublickey = $mnet_peer->public_key; // set this so we can confirm on form post without having to recreate the mnet_peer object
$reviewform->set_data($mnet_peer);
echo $OUTPUT->header();
echo $OUTPUT->render($deprecatenotify);
echo $OUTPUT->box_start();
$reviewform->display();
echo $OUTPUT->box_end();
Expand Down Expand Up @@ -176,7 +173,6 @@
}
} else if ($reviewform->is_submitted()) { // submitted, but errors
echo $OUTPUT->header();
echo $OUTPUT->render($deprecatenotify);
echo $OUTPUT->box_start();
$reviewform->display();
echo $OUTPUT->box_end();
Expand All @@ -187,7 +183,6 @@

// normal flow - just display all hosts with links
echo $OUTPUT->header();
echo $OUTPUT->render($deprecatenotify);
$hosts = mnet_get_hosts(true);

// print the table to display the register all hosts setting
Expand Down
1 change: 0 additions & 1 deletion admin/mnet/tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,4 @@
} else {
$tabs[] = new tabobject('mnetdetails', '#', $strmnetedithost, $strmnetedithost, false);
}
echo $OUTPUT->render(mnet_get_deprecation_notice());
print_tabs(array($tabs), $currenttab);
1 change: 0 additions & 1 deletion admin/mnet/trustedhosts.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
echo $OUTPUT->header();
echo $OUTPUT->render(mnet_get_deprecation_notice());
?>
<div id="trustedhosts"><!-- See theme/standard/styles_layout.css #trustedhosts .generaltable for rules -->
<table cellspacing="0" cellpadding="5" class="generaltable generalbox" >
Expand Down
2 changes: 0 additions & 2 deletions admin/settings/mnet.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
if (isset($CFG->mnet_dispatcher_mode) and $CFG->mnet_dispatcher_mode !== 'off') {
$profilefields = new admin_settingpage('mnetprofilefields', new lang_string('profilefields', 'mnet'),
'moodle/site:config');
$profilefields->add(new admin_setting_heading('mnetprofilefields/xmlrpcmnet', '',
$OUTPUT->render(mnet_get_deprecation_notice())));
$ADMIN->add('mnet', $profilefields);

$fields = mnet_profile_field_options();
Expand Down
5 changes: 0 additions & 5 deletions auth/mnet/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@
if ($ADMIN->fulltree) {
require_once($CFG->dirroot.'/lib/outputlib.php');

$notify = new \core\output\notification(get_string('xmlrpcmnetauthenticationenabled', 'admin'),
\core\output\notification::NOTIFY_WARNING);
$settings->add(new admin_setting_heading('auth_mnet/xmlrpcmnet', '',
$OUTPUT->render($notify)));

// Introductory explanation.
$settings->add(new admin_setting_heading('auth_mnet/pluginname', '',
new lang_string('auth_mnetdescription', 'auth_mnet')));
Expand Down
3 changes: 0 additions & 3 deletions lang/en/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1544,9 +1544,6 @@
$string['webproxy'] = 'Web proxy';
$string['webproxyinfo'] = 'Fill in the following options if your Moodle server cannot access the internet directly. Internet access is required for the download of environment data, language packs, RSS feeds, timezones, etc.<br /><em>The PHP cURL extension is highly recommended.</em>';
$string['xmlrpcrecommended'] = 'The XMLRPC extension is useful for web services and Moodle networking.';
$string['xmlrpcmaharaenabled'] = 'It has been detected that the Mahara ePortfolio is enabled on your site. This feature relies on the PHP XML-RPC extension which is no longer maintained by PHP.';
$string['xmlrpcmnetauthenticationenabled'] = 'It has been detected that the MNet authentication is enabled on your site. This feature relies on the PHP XML-RPC extension which is no longer maintained by PHP.';
$string['xmlrpcmnetenabled'] = 'It has been detected that the Moodle Networking is enabled on your site. This feature relies on the PHP XML-RPC extension which is no longer maintained by PHP.';
$string['xmlrpcwebserviceenabled'] = 'It has been detected that the XML-RPC Web Service protocol is enabled on your site. This feature relies on the PHP XML-RPC extension which is no longer maintained by PHP.';
$string['yuicomboloading'] = 'YUI combo loading';
$string['ziprequired'] = 'The Zip PHP extension is now required by Moodle, info-ZIP binaries or PclZip library are not used anymore.';
Expand Down
5 changes: 0 additions & 5 deletions lib/adminlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -7140,11 +7140,6 @@ public function output_html($data, $query='') {
}

$return = $OUTPUT->heading(get_string('actauthhdr', 'auth'), 3, 'main');
if (in_array('mnet', $authsenabled)) {
$notify = new \core\output\notification(get_string('xmlrpcmnetauthenticationenabled', 'admin'),
\core\output\notification::NOTIFY_WARNING);
$return .= $OUTPUT->render($notify);
}
$return .= $OUTPUT->box_start('generalbox authsui');

$table = new html_table();
Expand Down
58 changes: 0 additions & 58 deletions lib/tests/upgradelib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1354,64 +1354,6 @@ public function test_check_xmlrpc_webservice_is_set(): void {
$this->assertFalse($result->getStatus());
}

/**
* Test the check_xmlrpc_usage check when the MNet is turned on but no host was set up.
*
* @return void
*/
public function test_check_xmlrpc_mnet_host_is_not_set(): void {
global $CFG;

$this->resetAfterTest();
$CFG->mnet_dispatcher_mode = 'strict';

$result = new environment_results('custom_checks');
$this->assertNull(check_xmlrpc_usage($result));
}

/**
* Test the check_xmlrpc_usage check when the MNet is turned on and the host was set up.
*
* @return void
*/
public function test_check_xmlrpc_mnet_host_is_set(): void {
global $CFG, $DB;

$this->resetAfterTest();
$CFG->mnet_dispatcher_mode = 'strict';

// Add a mnet host.
$mnethost = new stdClass();
$mnethost->name = 'A mnet host';
$mnethost->public_key = 'A random public key!';
$mnethost->id = $DB->insert_record('mnet_host', $mnethost);

$result = new environment_results('custom_checks');
$this->assertInstanceOf(environment_results::class, check_xmlrpc_usage($result));
$this->assertEquals('xmlrpc_mnet_usage', $result->getInfo());
$this->assertFalse($result->getStatus());
}

/**
* Test the check_xmlrpc_usage check when the MNet is turned on and the Mahara portfolios was set up.
*
* @return void
*/
public function test_check_xmlrpc_mahara_portfolios_is_set(): void {
global $CFG;

$this->resetAfterTest();
$CFG->mnet_dispatcher_mode = 'strict';

// Enable the Mahara portfolios.
\core\plugininfo\portfolio::enable_plugin('mahara', 1);

$result = new environment_results('custom_checks');
$this->assertInstanceOf(environment_results::class, check_xmlrpc_usage($result));
$this->assertEquals('xmlrpc_mahara_usage', $result->getInfo());
$this->assertFalse($result->getStatus());
}

/**
* Data provider of usermenu items.
*
Expand Down
26 changes: 0 additions & 26 deletions lib/upgradelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2782,31 +2782,5 @@ function check_xmlrpc_usage(environment_results $result): ?environment_results {
}
}

if (isset($CFG->mnet_dispatcher_mode) && $CFG->mnet_dispatcher_mode == 'strict') {
// Checking Mnet hosts.
$mnethosts = mnet_get_hosts();
if ($mnethosts) {
$actualhost = 0;
foreach ($mnethosts as $mnethost) {
if ($mnethost->id != $CFG->mnet_all_hosts_id) {
$actualhost++;
}
}
if ($actualhost > 0) {
$result->setInfo('xmlrpc_mnet_usage');
$result->setFeedbackStr('xmlrpcmnetenabled');
return $result;
}
}

// Checking Mahara.
$portfolios = \core\plugininfo\portfolio::get_enabled_plugins();
if (array_key_exists('mahara', $portfolios)) {
$result->setInfo('xmlrpc_mahara_usage');
$result->setFeedbackStr('xmlrpcmaharaenabled');
return $result;
}
}

return null;
}
5 changes: 1 addition & 4 deletions mnet/environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,7 @@ function replace_keys() {
set_config('openssl', implode('@@@@@@@@', $this->keypair), 'mnet');

$DB->update_record('mnet_host', $this);
if (!PHPUNIT_TEST) {
// We don't want to output this log for PHPUnit since it will make the test to fail as risky.
error_log('New public key has been generated. It expires ' . date('Y/m/d h:i:s', $this->public_key_expires));
}
error_log('New public key has been generated. It expires ' . date('Y/m/d h:i:s', $this->public_key_expires));
}

function get_private_key() {
Expand Down
12 changes: 0 additions & 12 deletions mnet/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -935,15 +935,3 @@ function mnet_strip_user($user, $fields) {
}
return $user;
}

/**
* Return the deprecation notice of the Mnet.
*
* @return \core\output\notification
*/
function mnet_get_deprecation_notice(): \core\output\notification {
$notice = new \core\output\notification(get_string('xmlrpcmnetenabled', 'admin'),
\core\output\notification::NOTIFY_WARNING);

return $notice;
}
1 change: 0 additions & 1 deletion mnet/service/enrol/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
$service = mnetservice_enrol::get_instance();

echo $OUTPUT->header();
echo $OUTPUT->render(mnet_get_deprecation_notice());
echo $OUTPUT->heading_with_help(get_string('clientname', 'mnetservice_enrol'), 'clientname', 'mnetservice_enrol');

if (!$service->is_available()) {
Expand Down

0 comments on commit 621d75d

Please sign in to comment.