Skip to content

Commit

Permalink
MDL-72347 filter: Remove censor filter
Browse files Browse the repository at this point in the history
Word censorship filter is not widely used these days so it has been
removed from Moodle core.
  • Loading branch information
sarjona committed Oct 4, 2021
1 parent 1a9bee6 commit 3257693
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 229 deletions.
17 changes: 0 additions & 17 deletions filter/censor/README.txt

This file was deleted.

46 changes: 0 additions & 46 deletions filter/censor/classes/privacy/provider.php

This file was deleted.

86 changes: 0 additions & 86 deletions filter/censor/filter.php

This file was deleted.

28 changes: 0 additions & 28 deletions filter/censor/lang/en/filter_censor.php

This file was deleted.

9 changes: 0 additions & 9 deletions filter/censor/settings.php

This file was deleted.

30 changes: 0 additions & 30 deletions filter/censor/version.php

This file was deleted.

5 changes: 5 additions & 0 deletions filter/upgrade.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
This file describes API changes in core filter API and plugins,
information provided here is intended especially for developers.

=== 4.0 ===

* The Word censorship (filter_censor) filter has been completely removed from core. It has been moved to the plugins database
repository, so it can still be installed as a third-party plugin.

=== 3.9 ===

* The following functions, previously used (exclusively) by upgrade steps are not available anymore because of the upgrade cleanup performed for this version. See MDL-65809 for more info:
Expand Down
5 changes: 3 additions & 2 deletions lib/classes/plugin_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1725,8 +1725,9 @@ public static function is_deleted_standard_plugin($type, $name) {
'block' => array('course_overview', 'messages', 'community', 'participants'),
'cachestore' => array('memcache'),
'enrol' => array('authorize'),
'portfolio' => array('picasa'),
'filter' => array('censor'),
'media' => array('swf'),
'portfolio' => array('picasa'),
'qformat' => array('webct'),
'message' => array('jabber'),
'quizaccess' => array('safebrowser'),
Expand Down Expand Up @@ -1861,7 +1862,7 @@ public static function standard_plugins_list($type) {
),

'filter' => array(
'activitynames', 'algebra', 'censor', 'emailprotect',
'activitynames', 'algebra', 'emailprotect',
'emoticon', 'displayh5p', 'mathjaxloader', 'mediaplugin', 'multilang', 'tex', 'tidy',
'urltolink', 'data', 'glossary'
),
Expand Down
10 changes: 10 additions & 0 deletions lib/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2862,5 +2862,15 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2021092400.03);
}

if ($oldversion < 2021100300.01) {
// Remove filter_censor (unless it has manually been added back).
if (!file_exists($CFG->dirroot . '/filter/censor/filter.php')) {
unset_all_config_for_plugin('filter_censor');
}

// Main savepoint reached.
upgrade_main_savepoint(true, 2021100300.01);
}

return true;
}
19 changes: 9 additions & 10 deletions lib/tests/weblib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ public function test_format_string_static_caching_with_filters() {
$generator = $this->getDataGenerator();
$course = $generator->create_course();
$user = $generator->create_user();
$rawstring = 'Shortname <a href="#">link</a> curseword';
$expectednofilter = strip_links($rawstring);
$expectedfilter = 'Shortname link \*\**';
$rawstring = '<span lang="en" class="multilang">English</span><span lang="ca" class="multilang">Catalan</span>';
$expectednofilter = strip_tags($rawstring);
$expectedfilter = 'English';
$striplinks = true;
$context = context_course::instance($course->id);
$options = [
Expand All @@ -94,22 +94,21 @@ public function test_format_string_static_caching_with_filters() {
$nofilterresult = format_string($rawstring, $striplinks, $options);
$this->assertEquals($expectednofilter, $nofilterresult);

// Add the censor filter. Make sure it's enabled globally.
// Add the multilang filter. Make sure it's enabled globally.
$CFG->filterall = true;
$CFG->stringfilters = 'censor';
$CFG->filter_censor_badwords = 'curseword';
filter_set_global_state('censor', TEXTFILTER_ON);
filter_set_local_state('censor', $context->id, TEXTFILTER_ON);
$CFG->stringfilters = 'multilang';
filter_set_global_state('multilang', TEXTFILTER_ON);
filter_set_local_state('multilang', $context->id, TEXTFILTER_ON);
// This time we want to apply the filters.
$options['filter'] = true;
$filterresult = format_string($rawstring, $striplinks, $options);
$this->assertMatchesRegularExpression("/$expectedfilter/", $filterresult);

filter_set_local_state('censor', $context->id, TEXTFILTER_OFF);
filter_set_local_state('multilang', $context->id, TEXTFILTER_OFF);

// Confirm that we get back the cached string. The result should be
// the same as the filtered text above even though we've disabled the
// censor filter in between.
// multilang filter in between.
$cachedresult = format_string($rawstring, $striplinks, $options);
$this->assertMatchesRegularExpression("/$expectedfilter/", $cachedresult);
}
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

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

$version = 2021100300.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2021100300.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '4.0dev (Build: 20211003)'; // Human-friendly version name
Expand Down

0 comments on commit 3257693

Please sign in to comment.