Changeset 47237
- Timestamp:
- 02/10/2020 05:42:52 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/user.php
r47236 r47237 2940 2940 * 2941 2941 * @since 4.9.6 2942 * @since 5.4.0 Added 'Community Events Location' group to the export data. 2943 * @since 5.4.0 Added 'Session Tokens' group to the export data. 2942 2944 * 2943 2945 * @param string $email_address The users email address. … … 3013 3015 ); 3014 3016 3015 /**3016 * Introduce any Community Events Location data that is available.3017 *3018 * @since 5.4.03019 */3020 3017 if ( isset( $user_meta['community-events-location'] ) ) { 3021 3018 $location = maybe_unserialize( $user_meta['community-events-location'][0] ); … … 3047 3044 'data' => $location_data_to_export, 3048 3045 ); 3046 } 3047 3048 if ( isset( $user_meta['session_tokens'] ) ) { 3049 $session_tokens = maybe_unserialize( $user_meta['session_tokens'][0] ); 3050 3051 $session_tokens_props_to_export = array( 3052 'expiration' => __( 'Expiration' ), 3053 'ip' => __( 'IP' ), 3054 'ua' => __( 'User Agent' ), 3055 'login' => __( 'Last Login' ), 3056 ); 3057 3058 foreach ( $session_tokens as $token_key => $session_token ) { 3059 $session_tokens_data_to_export = array(); 3060 3061 foreach ( $session_tokens_props_to_export as $key => $name ) { 3062 if ( ! empty( $session_token[ $key ] ) ) { 3063 $value = $session_token[ $key ]; 3064 if ( in_array( $key, array( 'expiration', 'login' ) ) ) { 3065 $value = date_i18n( 'F d, Y H:i A', $value ); 3066 } 3067 $session_tokens_data_to_export[] = array( 3068 'name' => $name, 3069 'value' => $value, 3070 ); 3071 } 3072 } 3073 3074 $data_to_export[] = array( 3075 'group_id' => 'session-tokens', 3076 'group_label' => __( 'Session Tokens' ), 3077 'group_description' => __( 'User’s Session Tokens data.' ), 3078 'item_id' => "session-tokens-{$user->ID}-{$token_key}", 3079 'data' => $session_tokens_data_to_export, 3080 ); 3081 } 3049 3082 } 3050 3083 -
trunk/tests/phpunit/tests/user.php
r47236 r47237 1752 1752 1753 1753 } 1754 1755 /** 1756 * Testing the `wp_user_personal_data_exporter()` function 1757 * with Session Tokens data. 1758 * 1759 * @ticket 45889 1760 */ 1761 function test_wp_session_tokens_personal_data_exporter() { 1762 $test_user = new WP_User( self::$contrib_id ); 1763 1764 $session_tokens_data = array( 1765 'yft87y56457687sfd897867545fg76ds78iyuhgjyui7865' => array( 1766 'expiration' => 1580461981, 1767 'ip' => '0.0.0.0', 1768 'ua' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36', 1769 'login' => 1580289181, 1770 ), 1771 ); 1772 update_user_option( $test_user->ID, 'session_tokens', $session_tokens_data, true ); 1773 1774 $actual = wp_user_personal_data_exporter( $test_user->user_email ); 1775 1776 $this->assertTrue( $actual['done'] ); 1777 1778 // Contains Session Tokens. 1779 $this->assertEquals( 'Session Tokens', $actual['data'][1]['group_label'] ); 1780 1781 // Contains Expiration. 1782 $this->assertEquals( 'Expiration', $actual['data'][1]['data'][0]['name'] ); 1783 $this->assertEquals( 'January 31, 2020 09:13 AM', $actual['data'][1]['data'][0]['value'] ); 1784 1785 // Contains IP. 1786 $this->assertEquals( 'IP', $actual['data'][1]['data'][1]['name'] ); 1787 $this->assertEquals( '0.0.0.0', $actual['data'][1]['data'][1]['value'] ); 1788 1789 // Contains IP. 1790 $this->assertEquals( 'User Agent', $actual['data'][1]['data'][2]['name'] ); 1791 $this->assertEquals( 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36', $actual['data'][1]['data'][2]['value'] ); 1792 1793 // Contains IP. 1794 $this->assertEquals( 'Last Login', $actual['data'][1]['data'][3]['name'] ); 1795 $this->assertEquals( 'January 29, 2020 09:13 AM', $actual['data'][1]['data'][3]['value'] ); 1796 } 1754 1797 }
Note: See TracChangeset
for help on using the changeset viewer.