Changeset 50394
- Timestamp:
- 02/20/2021 12:09:45 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/cron.php
r50175 r50394 399 399 * @param bool $wp_error Whether to return a WP_Error on failure. 400 400 */ 401 $pre = apply_filters( 'pre_reschedule_event', null, $event );401 $pre = apply_filters( 'pre_reschedule_event', null, $event, $wp_error ); 402 402 403 403 if ( null !== $pre ) { -
trunk/tests/phpunit/tests/cron.php
r50143 r50394 776 776 */ 777 777 public function test_schedule_short_circuit_with_error_returns_false_when_wp_error_is_set_to_false() { 778 $return_error = function() { 778 $return_error = function( $pre, $event, $wp_error ) { 779 $this->assertFalse( $wp_error ); 780 779 781 return new WP_Error( 780 782 'my_error', … … 784 786 785 787 // Add filters which return a WP_Error: 786 add_filter( 'pre_schedule_event', $return_error );787 add_filter( 'pre_reschedule_event', $return_error );788 add_filter( 'pre_schedule_event', $return_error, 10, 3 ); 789 add_filter( 'pre_reschedule_event', $return_error, 10, 3 ); 788 790 789 791 // Schedule events without the `$wp_error` parameter: … … 802 804 */ 803 805 public function test_schedule_short_circuit_with_error_returns_error_when_wp_error_is_set_to_true() { 804 $return_error = function() { 806 $return_error = function( $pre, $event, $wp_error ) { 807 $this->assertTrue( $wp_error ); 808 805 809 return new WP_Error( 806 810 'my_error', … … 810 814 811 815 // Add filters which return a WP_Error: 812 add_filter( 'pre_schedule_event', $return_error );813 add_filter( 'pre_reschedule_event', $return_error );816 add_filter( 'pre_schedule_event', $return_error, 10, 3 ); 817 add_filter( 'pre_reschedule_event', $return_error, 10, 3 ); 814 818 815 819 // Schedule events with the `$wp_error` parameter: … … 877 881 */ 878 882 public function test_deprecated_argument_usage_of_wp_clear_scheduled_hook() { 879 add_filter( 880 'pre_clear_scheduled_hook', 881 function( $pre, $hook, $args, $wp_error ) { 882 $this->assertSame( array( 1, 2, 3 ), $args ); 883 $this->assertFalse( $wp_error ); 884 885 return $pre; 886 }, 887 10, 888 4 889 ); 883 $return_pre = function( $pre, $hook, $args, $wp_error ) { 884 $this->assertSame( array( 1, 2, 3 ), $args ); 885 $this->assertFalse( $wp_error ); 886 887 return $pre; 888 }; 889 890 add_filter( 'pre_clear_scheduled_hook', $return_pre, 10, 4 ); 890 891 891 892 $cleared = wp_clear_scheduled_hook( 'hook', 1, 2, 3 ); … … 919 920 */ 920 921 public function test_clear_scheduled_hook_returns_custom_pre_filter_error_when_wp_error_is_set_to_true() { 921 add_filter( 922 'pre_unschedule_event', 923 function( $pre ) { 924 return new WP_Error( 'error_code', 'error message' ); 925 } 926 ); 922 $return_error = function( $pre, $timestamp, $hook, $args, $wp_error ) { 923 $this->assertTrue( $wp_error ); 924 925 return new WP_Error( 'error_code', 'error message' ); 926 }; 927 928 add_filter( 'pre_unschedule_event', $return_error, 10, 5 ); 927 929 928 930 wp_schedule_single_event( strtotime( '+1 hour' ), 'test_hook' ); … … 951 953 */ 952 954 public function test_unschedule_short_circuit_with_error_returns_false_when_wp_error_is_set_to_false() { 953 $return_error = function() { 955 $return_error = function( $pre, $hook, $wp_error ) { 956 $this->assertFalse( $wp_error ); 957 954 958 return new WP_Error( 955 959 'my_error', … … 959 963 960 964 // Add a filter which returns a WP_Error: 961 add_filter( 'pre_unschedule_hook', $return_error );965 add_filter( 'pre_unschedule_hook', $return_error, 10, 3 ); 962 966 963 967 // Unschedule a hook without the `$wp_error` parameter: … … 972 976 */ 973 977 public function test_unschedule_short_circuit_with_error_returns_error_when_wp_error_is_set_to_true() { 974 $return_error = function() { 978 $return_error = function( $pre, $hook, $wp_error ) { 979 $this->assertTrue( $wp_error ); 980 975 981 return new WP_Error( 976 982 'my_error', … … 980 986 981 987 // Add a filter which returns a WP_Error: 982 add_filter( 'pre_unschedule_hook', $return_error );988 add_filter( 'pre_unschedule_hook', $return_error, 10, 3 ); 983 989 984 990 // Unschedule a hook with the `$wp_error` parameter:
Note: See TracChangeset
for help on using the changeset viewer.