Changeset 43468 for branches/4.9
- Timestamp:
- 07/17/2018 09:03:33 AM (6 years ago)
- Location:
- branches/4.9
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.9
-
branches/4.9/src/wp-includes/comment.php
r43270 r43468 3325 3325 ); 3326 3326 3327 /* translators: Name of a comment's author after being anonymized. */ 3327 3328 $anon_author = __( 'Anonymous' ); 3328 3329 $messages = array(); … … 3332 3333 $anonymized_comment['comment_agent'] = ''; 3333 3334 $anonymized_comment['comment_author'] = $anon_author; 3334 $anonymized_comment['comment_author_email'] = wp_privacy_anonymize_data( 'email', $comment->comment_author_email );3335 $anonymized_comment['comment_author_email'] = ''; 3335 3336 $anonymized_comment['comment_author_IP'] = wp_privacy_anonymize_data( 'ip', $comment->comment_author_IP ); 3336 $anonymized_comment['comment_author_url'] = wp_privacy_anonymize_data( 'url', $comment->comment_author_url );3337 $anonymized_comment['comment_author_url'] = ''; 3337 3338 $anonymized_comment['user_id'] = 0; 3338 3339 -
branches/4.9/tests/phpunit/tests/comment.php
r43372 r43468 704 704 * The `wp_comments_personal_data_eraser()` function should erase user's comments. 705 705 * 706 * @group privacy 706 707 * @ticket 43442 707 708 */ … … 745 746 'user_id' => '0', // Anonymized. 746 747 'comment_author' => 'Anonymous', // Anonymized. 747 'comment_author_email' => ' deleted@site.invalid', // Anonymized.748 'comment_author_url' => ' https://site.invalid', // Anonymized.748 'comment_author_email' => '', // Anonymized. 749 'comment_author_url' => '', // Anonymized. 749 750 'comment_author_IP' => '192.168.0.0', // Anonymized. 750 751 'comment_date' => '2018-04-14 17:20:00', … … 760 761 * Testing the `wp_comments_personal_data_eraser()` function's output on an empty first page. 761 762 * 763 * @group privacy 762 764 * @ticket 43442 763 765 */ … … 778 780 * Testing the `wp_comments_personal_data_eraser()` function's output, for the non-empty first page. 779 781 * 782 * @group privacy 780 783 * @ticket 43442 781 784 */ … … 809 812 * Testing the `wp_comments_personal_data_eraser()` function's output, for an empty second page. 810 813 * 814 * @group privacy 811 815 * @ticket 43442 812 816 */ … … 840 844 * Testing the `wp_anonymize_comment` filter, to prevent comment anonymization. 841 845 * 846 * @group privacy 842 847 * @ticket 43442 843 848 */ … … 876 881 * Testing the `wp_anonymize_comment` filter, to prevent comment anonymization, with a custom message. 877 882 * 883 * @group privacy 878 884 * @ticket 43442 879 885 */ -
branches/4.9/tests/phpunit/tests/functions/anonymization.php
r43082 r43468 3 3 * Test anonymization functions. 4 4 * 5 * @package WordPress 6 * 7 * @since 5.0.05 * @package WordPress\UnitTests 6 * 7 * @since 4.9.6 8 8 */ 9 9 … … 14 14 * @group privacy 15 15 * 16 * @since 5.0.016 * @since 4.9.6 17 17 */ 18 18 class Tests_Functions_Anonymization extends WP_UnitTestCase { … … 43 43 * Provide test cases for `test_wp_privacy_anonymize_ip()`. 44 44 * 45 * @since 5.0.0Moved from `Test_WP_Community_Events::data_get_unsafe_client_ip_anonymization()`.45 * @since 4.9.6 Moved from `Test_WP_Community_Events::data_get_unsafe_client_ip_anonymization()`. 46 46 * 47 47 * @return array { … … 213 213 */ 214 214 public function test_anonymize_email() { 215 $this->assert Equals( 'deleted@site.invalid', wp_privacy_anonymize_data( 'email', 'bar@example.com' ) );215 $this->assertSame( '', wp_privacy_anonymize_data( 'email', 'bar@example.com' ) ); 216 216 } 217 217 … … 220 220 */ 221 221 public function test_anonymize_url() { 222 $this->assert Equals( 'https://site.invalid', wp_privacy_anonymize_data( 'url', 'https://example.com/author/username' ) );222 $this->assertSame( '', wp_privacy_anonymize_data( 'url', 'https://example.com/author/username' ) ); 223 223 } 224 224 … … 245 245 $this->assertEquals( 'This content was deleted by the author.', wp_privacy_anonymize_data( 'longtext', $text ) ); 246 246 } 247 248 /** 249 * Test text anonymization when a filter is added. 250 * 251 * @ticket 44141 252 */ 253 public function test_anonymize_with_filter() { 254 add_filter( 'wp_privacy_anonymize_data', array( $this, 'filter_wp_privacy_anonymize_data' ), 10, 3 ); 255 $actual_url = wp_privacy_anonymize_data( 'url', 'https://example.com/author/username' ); 256 remove_filter( 'wp_privacy_anonymize_data', array( $this, 'filter_wp_privacy_anonymize_data' ), 10 ); 257 258 $this->assertSame( 'http://local.host/why-this-was-removed', $actual_url ); 259 } 260 261 /** 262 * Change the anonymized value for URLs. 263 * 264 * @since 4.9.8 265 * 266 * @param string $anonymous Anonymized data. 267 * @param string $type Type of the data. 268 * @param string $data Original data. 269 * @return string $anonymous Anonymized data. 270 */ 271 public function filter_wp_privacy_anonymize_data( $anonymous, $type, $data ) { 272 if ( 'url' === $type && 'example.com' === parse_url( $data, PHP_URL_HOST ) ) { 273 return 'http://local.host/why-this-was-removed'; 274 } 275 return $anonymous; 276 } 277 247 278 }
Note: See TracChangeset
for help on using the changeset viewer.