diff --git a/.upgradenotes/MDL-80962-2024071606563987.yml b/.upgradenotes/MDL-80962-2024071606563987.yml new file mode 100644 index 0000000000000..1246236588682 --- /dev/null +++ b/.upgradenotes/MDL-80962-2024071606563987.yml @@ -0,0 +1,9 @@ +issueNumber: MDL-80962 +notes: + core: + - message: > + The following classes are deprecated as they are handled by core_sms API and smsgateway_aws plugin: + - admin_settings_aws_region (lib/classes/aws/admin_settings_aws_region.php) + - aws_helper (lib/classes/aws/aws_helper.php) + - client_factory (lib/classes/aws/client_factory.php) + type: deprecated diff --git a/.upgradenotes/MDL-80962-2024071606591847.yml b/.upgradenotes/MDL-80962-2024071606591847.yml new file mode 100644 index 0000000000000..06a15b914cb83 --- /dev/null +++ b/.upgradenotes/MDL-80962-2024071606591847.yml @@ -0,0 +1,8 @@ +issueNumber: MDL-80962 +notes: + core: + - message: > + The following test classes are removed as their base classes are deprecated: + - admin_settings_aws_region_test (lib/tests/aws/admin_settings_aws_region_test.php) + - aws_helper_test (lib/tests/aws/aws_helper_test.php) + type: removed diff --git a/lib/classes/aws/admin_settings_aws_region.php b/lib/classes/aws/admin_settings_aws_region.php index 4ff65cb8af833..388a597352cb7 100644 --- a/lib/classes/aws/admin_settings_aws_region.php +++ b/lib/classes/aws/admin_settings_aws_region.php @@ -14,15 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Admin setting for AWS regions. - * - * @package core - * @author Dmitrii Metelkin - * @copyright 2020 Catalyst IT - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - namespace core\aws; defined('MOODLE_INTERNAL') || die(); @@ -35,6 +26,8 @@ * @package core * @copyright 2020 Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @deprecated Since Moodle 4.5 + * @todo MDL-82459 Final deprecation in Moodle 5.0. */ class admin_settings_aws_region extends \admin_setting_configtext { @@ -44,8 +37,15 @@ class admin_settings_aws_region extends \admin_setting_configtext { * @param mixed $data array or string depending on setting * @param string $query * @return string + * @deprecated Since Moodle 4.5 */ + #[\core\attribute\deprecated( + 'admin_settings_aws_region::output_html()', + since: '4.5', + mdl: 'MDL-80962', + )] public function output_html($data, $query='') { + \core\deprecation::emit_deprecation_if_present([$this, __FUNCTION__]); global $CFG, $OUTPUT; $default = $this->get_defaultsetting(); diff --git a/lib/classes/aws/aws_helper.php b/lib/classes/aws/aws_helper.php index a9b1a5e317d1f..ce77bb6c5f8ae 100644 --- a/lib/classes/aws/aws_helper.php +++ b/lib/classes/aws/aws_helper.php @@ -14,15 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * AWS helper class. Contains useful functions when interacting with the SDK. - * - * @package core - * @author Peter Burnett - * @copyright 2020 Catalyst IT - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - namespace core\aws; use Aws\CommandInterface; @@ -34,6 +25,8 @@ * * @copyright 2020 Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @deprecated Since Moodle 4.5 + * @todo MDL-82459 Final deprecation in Moodle 5.0. */ class aws_helper { @@ -41,8 +34,15 @@ class aws_helper { * This creates a proxy string suitable for use with the AWS SDK. * * @return string the string to use for proxy settings. + * @deprecated Since Moodle 4.5 */ + #[\core\attribute\deprecated( + 'aws_helper::get_proxy_string()', + since: '4.5', + mdl: 'MDL-80962', + )] public static function get_proxy_string(): string { + \core\deprecation::emit_deprecation_if_present(__FUNCTION__); global $CFG; $proxy = ''; if (empty($CFG->proxytype)) { @@ -71,8 +71,15 @@ public static function get_proxy_string(): string { * * @param AwsClient $client * @return AwsClient + * @deprecated Since Moodle 4.5 */ + #[\core\attribute\deprecated( + 'aws_helper::configure_client_proxy()', + since: '4.5', + mdl: 'MDL-80962', + )] public static function configure_client_proxy(AwsClient $client): AwsClient { + \core\deprecation::emit_deprecation_if_present(__FUNCTION__); $client->getHandlerList()->appendBuild(self::add_proxy_when_required(), 'proxy_bypass'); return $client; } @@ -81,8 +88,15 @@ public static function configure_client_proxy(AwsClient $client): AwsClient { * Generate a middleware higher order function to wrap the handler and append proxy configuration based on target. * * @return callable Middleware high order callable. + * @deprecated Since Moodle 4.5 */ + #[\core\attribute\deprecated( + 'aws_helper::add_proxy_when_required()', + since: '4.5', + mdl: 'MDL-80962', + )] protected static function add_proxy_when_required(): callable { + \core\deprecation::emit_deprecation_if_present(__FUNCTION__); return function (callable $fn) { return function (CommandInterface $command, ?RequestInterface $request = null) use ($fn) { if (isset($request)) { diff --git a/lib/classes/aws/client_factory.php b/lib/classes/aws/client_factory.php index 2b46a0dbd1f6f..206ad4654fc9f 100644 --- a/lib/classes/aws/client_factory.php +++ b/lib/classes/aws/client_factory.php @@ -14,15 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * AWS Client factory. Retrieves a client with moodle specific HTTP configuration. - * - * @package core - * @author Peter Burnett - * @copyright 2022 Catalyst IT - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - namespace core\aws; use Aws\AwsClient; @@ -32,6 +23,8 @@ * @copyright 2022 Catalyst IT * @author Peter Burnett * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @deprecated Since Moodle 4.5 + * @todo MDL-82459 Final deprecation in Moodle 5.0. */ class client_factory { /** @@ -40,8 +33,15 @@ class client_factory { * @param string $class Fully qualified AWS classname e.g. \Aws\S3\S3Client * @param array $opts array of constructor options for AWS Client. * @return AwsClient + * @deprecated Since Moodle 4.5 */ + #[\core\attribute\deprecated( + 'client_factory::get_client()', + since: '4.5', + mdl: 'MDL-80962', + )] public static function get_client(string $class, array $opts): AwsClient { + \core\deprecation::emit_deprecation_if_present(__FUNCTION__); // Modify the opts to add HTTP timeouts. if (empty($opts['http'])) { $opts['http'] = ['connect_timeout' => HOURSECS]; diff --git a/lib/tests/aws/admin_settings_aws_region_test.php b/lib/tests/aws/admin_settings_aws_region_test.php deleted file mode 100644 index 4fc203e2be841..0000000000000 --- a/lib/tests/aws/admin_settings_aws_region_test.php +++ /dev/null @@ -1,65 +0,0 @@ -. - -/** - * factor_sms unit tests. - * - * @package core - * @author Mikhail Golenkov - * @copyright 2020 Catalyst IT - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace core\aws; - -/** - * Testcase for the list of AWS regions admin setting. - * - * @package core - * @author Mikhail Golenkov - * @copyright 2020 Catalyst IT - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @covers \core\aws\admin_settings_aws_region - */ -class admin_settings_aws_region_test extends \advanced_testcase { - - /** - * Cleanup after all tests are executed. - * - * @return void - */ - public function tearDown(): void { - $admin = admin_get_root(); - $admin->purge_children(true); - parent::tearDown(); - } - /** - * Test that output_html() method works and returns HTML string with expected content. - */ - public function test_output_html(): void { - $this->resetAfterTest(); - $setting = new admin_settings_aws_region('test_aws_region', - 'Test visible name', 'Test description', 'Test default setting'); - $html = $setting->output_html(''); - $this->assertTrue(str_contains($html, 'Test visible name')); - $this->assertTrue(str_contains($html, 'Test description')); - $this->assertTrue(str_contains($html, 'Default: Test default setting')); - $this->assertTrue(str_contains($html, - 'assertTrue(str_contains($html, '')); - $this->assertTrue(str_contains($html, '