diff --git a/filter/tidy/classes/privacy/provider.php b/filter/tidy/classes/privacy/provider.php deleted file mode 100644 index 7ae9e969915..00000000000 --- a/filter/tidy/classes/privacy/provider.php +++ /dev/null @@ -1,46 +0,0 @@ -. - -/** - * Privacy Subsystem implementation for filter_tidy. - * - * @package filter_tidy - * @copyright 2018 Andrew Nicols - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace filter_tidy\privacy; - -defined('MOODLE_INTERNAL') || die(); - -/** - * Privacy Subsystem for filter_tidy implementing null_provider. - * - * @copyright 2018 Andrew Nicols - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class provider implements \core_privacy\local\metadata\null_provider { - - /** - * Get the language string identifier with the component's language - * file to explain why this plugin stores no data. - * - * @return string - */ - public static function get_reason(): string { - return 'privacy:metadata'; - } -} diff --git a/filter/tidy/classes/text_filter.php b/filter/tidy/classes/text_filter.php deleted file mode 100644 index 93ac723d15d..00000000000 --- a/filter/tidy/classes/text_filter.php +++ /dev/null @@ -1,70 +0,0 @@ -. - -namespace filter_tidy; - -/** - * HTML tidy text filter. - * - * This class looks for text including markup and - * applies tidy's repair function to it. - * Tidy is a HTML clean and - * repair utility, which is currently available for PHP 4.3.x and PHP 5 as a - * PECL extension from http://pecl.php.net/package/tidy, in PHP 5 you need only - * to compile using the --with-tidy option. - * If you don't have the tidy extension installed or don't know, you can enable - * or disable this filter, it just won't have any effect. - * If you want to know what you can set in $tidyoptions and what their default - * values are, see http://php.net/manual/en/function.tidy-get-config.php. - * - * @package filter_tidy - * @subpackage tiny - * @copyright 2004 Hannes Gassert - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class text_filter extends \core_filters\text_filter { - #[\Override] - public function filter($text, array $options = []) { - // Configuration for tidy. - // See https://api.html-tidy.org/tidy/quickref_5.0.0.html for details. - $tidyoptions = [ - 'output-xhtml' => true, - 'show-body-only' => true, - 'tidy-mark' => false, - 'drop-proprietary-attributes' => true, - 'drop-empty-paras' => true, - 'indent' => true, - 'quiet' => true, - ]; - - // Do a quick check using strpos to avoid unnecessary work. - if (strpos($text, '<') === false) { - return $text; - } - - // If enabled: run tidy over the entire string. - if (extension_loaded('tidy')) { - $currentlocale = \core\locale::get_locale(); - try { - $text = (new \tidy())->repairString($text, $tidyoptions, 'utf8'); - } finally { - \core\locale::set_locale(LC_ALL, $currentlocale); - } - } - - return $text; - } -} diff --git a/filter/tidy/db/renamedclasses.php b/filter/tidy/db/renamedclasses.php deleted file mode 100644 index 1e0947263ba..00000000000 --- a/filter/tidy/db/renamedclasses.php +++ /dev/null @@ -1,29 +0,0 @@ -. - -/** - * Renamed classes for the filter_tidy plugin. - * - * @package filter_tidy - * @copyright Jun Pataleta - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die; - -$renamedclasses = [ - 'filter_tidy' => \filter_tidy\text_filter::class, -]; diff --git a/filter/tidy/environment.xml b/filter/tidy/environment.xml deleted file mode 100644 index 7eb9ba656e6..00000000000 --- a/filter/tidy/environment.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/filter/tidy/filter.php b/filter/tidy/filter.php deleted file mode 100644 index f4cfd134963..00000000000 --- a/filter/tidy/filter.php +++ /dev/null @@ -1,28 +0,0 @@ -. - -/** - * File only retained to prevent fatal errors in code that tries to require/include this. - * - * @todo MDL-82708 delete this file as part of Moodle 6.0 development. - * @deprecated This file is no longer required in Moodle 4.5+. - * @package filter_tidy - * @copyright Hannes Gassert - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -defined('MOODLE_INTERNAL') || die(); - -debugging('This file is no longer required in Moodle 4.5+. Please do not include/require it.', DEBUG_DEVELOPER); diff --git a/filter/tidy/lang/en/filter_tidy.php b/filter/tidy/lang/en/filter_tidy.php deleted file mode 100644 index eebc11eb891..00000000000 --- a/filter/tidy/lang/en/filter_tidy.php +++ /dev/null @@ -1,28 +0,0 @@ -. - -/** - * Strings for component 'filter_tidy', language 'en', branch 'MOODLE_20_STABLE' - * - * @package filter_tidy - * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -$string['filtername'] = 'HTML tidy'; -$string['privacy:metadata'] = 'The HTML tidy plugin does not store any personal data.'; -$string['tidyextensionrequired'] = 'To use this filter, the \'tidy\' PHP extension must be installed.'; diff --git a/filter/tidy/tests/text_filter_test.php b/filter/tidy/tests/text_filter_test.php deleted file mode 100644 index ed9d6206c2e..00000000000 --- a/filter/tidy/tests/text_filter_test.php +++ /dev/null @@ -1,105 +0,0 @@ -. - -namespace filter_tidy; - -/** - * Tests for HTML tidy. - * - * @package filter_tidy - * @category test - * @copyright 2024 Andrew Lyons - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @covers \filter_tidy\text_filter - */ -final class text_filter_test extends \advanced_testcase { - /** @var string Locale */ - protected string $locale; - - #[\Override] - public function setUp(): void { - parent::setUp(); - $this->locale = \core\locale::get_locale(); - } - - #[\Override] - public function tearDown(): void { - parent::tearDown(); - \core\locale::set_locale(LC_ALL, $this->locale); - } - - /** - * Test the filter method. - * - * @requires extension tidy - * @dataProvider filter_provider - * @param string $text The text to filter. - * @param string $expected The expected value - */ - public function test_filter( - string $text, - string $expected, - ): void { - $filter = new text_filter(\core\context\system::instance(), []); - $this->assertEquals($expected, $filter->filter($text)); - $this->assertEquals( - \core\locale::standardise_locale($this->locale), - \core\locale::standardise_locale(\core\locale::get_locale()), - ); - } - - /** - * Data provider for the filter test. - * - * @return array - */ - public static function filter_provider(): array { - return [ - // No HTML tags. - [ - 'The cat is in the hat', - 'The cat is in the hat', - ], - // Partial HTML. - [ - '

The cat is in the hat', - << - The cat is in the hat -

- EOF, - ], - // Return only the body, repairing the closing tag. - [ - << - - test - - -

error - - - EOF, - << - error -

- EOF, - ], - ]; - } -} diff --git a/filter/tidy/version.php b/filter/tidy/version.php deleted file mode 100644 index a801c656b72..00000000000 --- a/filter/tidy/version.php +++ /dev/null @@ -1,30 +0,0 @@ -. - -/** - * Version details - * - * @package filter - * @subpackage tidy - * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -$plugin->version = 2024042200; // The current plugin version (Date: YYYYMMDDXX). -$plugin->requires = 2024041600; // Requires this Moodle version. -$plugin->component = 'filter_tidy'; // Full name of the plugin (used for diagnostics) diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index d9c353f5066..770333172c1 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -1240,5 +1240,15 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2024080500.00); } + if ($oldversion < 2024082000.00) { + // If filter_tidy is no longer present, remove it. + if (!file_exists($CFG->dirroot . '/filter/tidy/version.php')) { + // Clean config. + unset_all_config_for_plugin('filter_tidy'); + } + + upgrade_main_savepoint(true, 2024082000.00); + } + return true; } diff --git a/lib/plugins.json b/lib/plugins.json index 94c5402ac29..9d66c44b6b5 100644 --- a/lib/plugins.json +++ b/lib/plugins.json @@ -230,7 +230,6 @@ "mediaplugin", "multilang", "tex", - "tidy", "urltolink" ], "format": [ @@ -593,7 +592,8 @@ "authorize" ], "filter": [ - "censor" + "censor", + "tidy" ], "h5plib": [ "v124" diff --git a/lib/tests/filterlib_test.php b/lib/tests/filterlib_test.php index 84232e27434..eb1b5c36972 100644 --- a/lib/tests/filterlib_test.php +++ b/lib/tests/filterlib_test.php @@ -725,24 +725,24 @@ class filterlib_test extends \advanced_testcase { $this->resetAfterTest(); $this->assertFileExists("$CFG->dirroot/filter/emailprotect"); // Any standard filter. - $this->assertFileExists("$CFG->dirroot/filter/tidy"); // Any standard filter. + $this->assertFileExists("$CFG->dirroot/filter/glossary"); // Any standard filter. $this->assertFileDoesNotExist("$CFG->dirroot/filter/grgrggr"); // Any non-existent filter. // Setup fixture. set_config('filterall', 0); set_config('stringfilters', ''); // Exercise SUT. - filter_set_applies_to_strings('tidy', true); + filter_set_applies_to_strings('glossary', true); // Validate. - $this->assertEquals('tidy', $CFG->stringfilters); + $this->assertEquals('glossary', $CFG->stringfilters); $this->assertEquals(1, $CFG->filterall); filter_set_applies_to_strings('grgrggr', true); - $this->assertEquals('tidy', $CFG->stringfilters); + $this->assertEquals('glossary', $CFG->stringfilters); $this->assertEquals(1, $CFG->filterall); filter_set_applies_to_strings('emailprotect', true); - $this->assertEquals('tidy,emailprotect', $CFG->stringfilters); + $this->assertEquals('glossary,emailprotect', $CFG->stringfilters); $this->assertEquals(1, $CFG->filterall); } @@ -750,13 +750,13 @@ class filterlib_test extends \advanced_testcase { global $CFG; $this->resetAfterTest(); - $this->assertFileExists("$CFG->dirroot/filter/tidy"); // Any standard filter. + $this->assertFileExists("$CFG->dirroot/filter/glossary"); // Any standard filter. // Setup fixture. set_config('filterall', 1); - set_config('stringfilters', 'tidy'); + set_config('stringfilters', 'glossary'); // Exercise SUT. - filter_set_applies_to_strings('tidy', false); + filter_set_applies_to_strings('glossary', false); // Validate. $this->assertEquals('', $CFG->stringfilters); $this->assertEquals('', $CFG->filterall); @@ -767,14 +767,14 @@ class filterlib_test extends \advanced_testcase { $this->resetAfterTest(); $this->assertFileExists("$CFG->dirroot/filter/emailprotect"); // Any standard filter. - $this->assertFileExists("$CFG->dirroot/filter/tidy"); // Any standard filter. + $this->assertFileExists("$CFG->dirroot/filter/glossary"); // Any standard filter. $this->assertFileExists("$CFG->dirroot/filter/multilang"); // Any standard filter. // Setup fixture. set_config('filterall', 1); - set_config('stringfilters', 'emailprotect,tidy,multilang'); + set_config('stringfilters', 'emailprotect,glossary,multilang'); // Exercise SUT. - filter_set_applies_to_strings('tidy', false); + filter_set_applies_to_strings('glossary', false); // Validate. $this->assertEquals('emailprotect,multilang', $CFG->stringfilters); $this->assertEquals(1, $CFG->filterall); diff --git a/version.php b/version.php index 01c711e36c8..c725da37c9d 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2024081600.00; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2024082000.00; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes. $release = '4.5dev+ (Build: 20240816)'; // Human-friendly version name