WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/23/2020 03:12:49 AM (6 months ago)
Author:
jorbin
Message:

General: Update code for readability and inclusion

There are two pieces in here:

1) The update to change blacklist to blocklist is moved to disallowed_list. "Block" has a meaning in our code, and there could be ambiguity between this code and code related to blocks.

2) This improves backwards compatibility for code that was accessing the now deprecated code.

Previously: [48477], [48405], [48400], [48121], [48122], [48124], [48142], [48566]

Props: desrosj, SergeyBiryukov, johnjamesjacoby
Fixes: #50413

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/comment/wpBlacklistCheck.php

    r48121 r48575  
    66class Tests_WP_Blocklist_Check extends WP_UnitTestCase {
    77
    8     public function test_should_return_true_when_content_matches_blocklist_keys() {
     8    public function test_should_return_true_when_content_matches_disallowed_keys() {
    99        $author       = 'Sting';
    1010        $author_email = 'sting@example.com';
     
    1414        $user_agent   = '';
    1515
    16         update_option( 'blocklist_keys', "well\nfoo" );
     16        update_option( 'disallowed_keys', "well\nfoo" );
    1717
    18         $result = wp_blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
     18        $result = wp_check_comment_disallowed_list( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
    1919
    2020        $this->assertTrue( $result );
     
    2424     * @ticket 37208
    2525     */
    26     public function test_should_return_true_when_content_with_html_matches_blocklist_keys() {
     26    public function test_should_return_true_when_content_with_html_matches_disallowed_keys() {
    2727        $author       = 'Sting';
    2828        $author_email = 'sting@example.com';
     
    3232        $user_agent   = '';
    3333
    34         update_option( 'blocklist_keys', "halfway\nfoo" );
     34        update_option( 'disallowed_keys', "halfway\nfoo" );
    3535
    36         $result = wp_blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
     36        $result = wp_check_comment_disallowed_list( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
    3737
    3838        $this->assertTrue( $result );
    3939    }
    4040
    41     public function test_should_return_true_when_author_matches_blocklist_keys() {
     41    public function test_should_return_true_when_author_matches_disallowed_keys() {
    4242        $author       = 'Sideshow Mel';
    4343        $author_email = 'mel@example.com';
     
    4747        $user_agent   = '';
    4848
    49         update_option( 'blocklist_keys', "sideshow\nfoo" );
     49        update_option( 'disallowed_keys', "sideshow\nfoo" );
    5050
    51         $result = wp_blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
     51        $result = wp_check_comment_disallowed_list( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
    5252
    5353        $this->assertTrue( $result );
    5454    }
    5555
    56     public function test_should_return_true_when_url_matches_blocklist_keys() {
     56    public function test_should_return_true_when_url_matches_disallowed_keys() {
    5757        $author       = 'Rainier Wolfcastle';
    5858        $author_email = 'rainier@wolfcastle.com';
     
    6262        $user_agent   = '';
    6363
    64         update_option( 'blocklist_keys', "example\nfoo" );
     64        update_option( 'disallowed_keys', "example\nfoo" );
    6565
    66         $result = wp_blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
     66        $result = wp_check_comment_disallowed_list( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
    6767
    6868        $this->assertTrue( $result );
     
    7272     * @ticket 37208
    7373     */
    74     public function test_should_return_true_when_link_matches_blocklist_keys() {
     74    public function test_should_return_true_when_link_matches_disallowed_keys() {
    7575        $author       = 'Rainier Wolfcastle';
    7676        $author_email = 'rainier@wolfcastle.com';
     
    8080        $user_agent   = '';
    8181
    82         update_option( 'blocklist_keys', '/spam/' );
     82        update_option( 'disallowed_keys', '/spam/' );
    8383
    84         $result = wp_blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
     84        $result = wp_check_comment_disallowed_list( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
    8585
    8686        $this->assertTrue( $result );
     
    9595        $user_agent   = '';
    9696
    97         update_option( 'blocklist_keys', "sideshow\nfoobar" );
     97        update_option( 'disallowed_keys', "sideshow\nfoobar" );
    9898
    99         $result = wp_blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
     99        $result = wp_check_comment_disallowed_list( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
    100100
    101101        $this->assertFalse( $result );
Note: See TracChangeset for help on using the changeset viewer.