Ticket #7067: 7067.01.patch
| File 7067.01.patch, 5.8 KB (added by , 10 years ago) |
|---|
-
src/bp-notifications/bp-notifications-functions.php
701 701 702 702 add_filter( 'query', 'bp_filter_metaid_column_name' ); 703 703 foreach ( $keys as $key ) { 704 $retval = delete_metadata( 'notification s', $notification_id, $key, $meta_value, $delete_all );704 $retval = delete_metadata( 'notification', $notification_id, $key, $meta_value, $delete_all ); 705 705 } 706 706 remove_filter( 'query', 'bp_filter_metaid_column_name' ); 707 707 … … 726 726 */ 727 727 function bp_notifications_get_meta( $notification_id = 0, $meta_key = '', $single = true ) { 728 728 add_filter( 'query', 'bp_filter_metaid_column_name' ); 729 $retval = get_metadata( 'notification s', $notification_id, $meta_key, $single );729 $retval = get_metadata( 'notification', $notification_id, $meta_key, $single ); 730 730 remove_filter( 'query', 'bp_filter_metaid_column_name' ); 731 731 732 732 /** … … 761 761 */ 762 762 function bp_notifications_update_meta( $notification_id, $meta_key, $meta_value, $prev_value = '' ) { 763 763 add_filter( 'query', 'bp_filter_metaid_column_name' ); 764 $retval = update_metadata( 'notification s', $notification_id, $meta_key, $meta_value, $prev_value );764 $retval = update_metadata( 'notification', $notification_id, $meta_key, $meta_value, $prev_value ); 765 765 remove_filter( 'query', 'bp_filter_metaid_column_name' ); 766 766 767 767 return $retval; … … 782 782 */ 783 783 function bp_notifications_add_meta( $notification_id, $meta_key, $meta_value, $unique = false ) { 784 784 add_filter( 'query', 'bp_filter_metaid_column_name' ); 785 $retval = add_metadata( 'notification s', $notification_id, $meta_key, $meta_value, $unique );785 $retval = add_metadata( 'notification', $notification_id, $meta_key, $meta_value, $unique ); 786 786 remove_filter( 'query', 'bp_filter_metaid_column_name' ); 787 787 788 788 return $retval; -
src/bp-notifications/classes/class-bp-notifications-component.php
82 82 'table_name_meta' => $bp->table_prefix . 'bp_notifications_meta', 83 83 ); 84 84 85 // Metadata tables for notifications component. 86 $meta_tables = array( 87 'notification' => $bp->table_prefix . 'bp_notifications_meta', 88 ); 89 85 90 // All globals for the notifications component. 86 91 // Note that global_tables is included in this array. 87 92 $args = array( … … 89 94 'has_directory' => false, 90 95 'search_string' => __( 'Search Notifications...', 'buddypress' ), 91 96 'global_tables' => $global_tables, 97 'meta_tables' => $meta_tables 92 98 ); 93 99 94 100 parent::setup_globals( $args ); -
src/bp-notifications/classes/class-bp-notifications-notification.php
629 629 * false (no pagination - all items). 630 630 * @type int $per_page Number of items to show per page. Default: 631 631 * false (no pagination - all items). 632 * @type array $meta_query Array of meta_query conditions. See WP_Meta_Query::queries. 633 * @type array $date_query Array of date_query conditions. See first parameter of 634 * WP_Date_Query::__construct(). 635 * @type bool $update_meta_cache Whether to update meta cache. Default: true. 632 636 * } 633 637 * @return array Located notifications. 634 638 */ … … 681 685 // Concatenate query parts. 682 686 $sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} {$order_sql} {$pag_sql}"; 683 687 684 return $wpdb->get_results( $sql ); 688 $results = $wpdb->get_results( $sql ); 689 690 // Update meta cache. 691 if ( true === $r['update_meta_cache'] ) { 692 bp_notifications_update_meta_cache( wp_list_pluck( $results, 'id' ) ); 693 } 694 695 return $results; 685 696 } 686 697 687 698 /** -
tests/phpunit/testcases/notifications/functions.php
124 124 } 125 125 126 126 /** 127 * @group bp_notifications_update_meta_cache 128 */ 129 public function test_bp_notifications_update_meta_cache() { 130 $u = $this->factory->user->create(); 131 132 $n1 = $this->factory->notification->create( array( 133 'component_name' => 'messages', 134 'user_id' => $u 135 ) ); 136 137 $n2 = $this->factory->notification->create( array( 138 'component_name' => 'groups', 139 'user_id' => $u 140 ) ); 141 142 // Add cache for each notification. 143 bp_notifications_update_meta( $n1, 'meta', 'data' ); 144 bp_notifications_update_meta( $n1, 'data', 'meta' ); 145 bp_notifications_update_meta( $n2, 'meta', 'human' ); 146 147 // Prime cache. 148 bp_notifications_get_meta( $n1, 'meta' ); 149 150 // Ensure an empty cache for second notification. 151 wp_cache_delete( $n2, 'notification_meta' ); 152 153 // Update notification meta cache. 154 bp_notifications_update_meta_cache( array( $n1, $n2 ) ); 155 156 $expected = array( 157 $n1 => array( 158 'meta' => array( 159 'data', 160 ), 161 'data' => array( 162 'meta', 163 ), 164 ), 165 $n2 => array( 166 'meta' => array( 167 'human', 168 ), 169 ), 170 ); 171 172 $found = array( 173 $n1 => wp_cache_get( $n1, 'notification_meta' ), 174 $n2 => wp_cache_get( $n2, 'notification_meta' ), 175 ); 176 177 $this->assertEquals( $expected, $found ); 178 } 179 180 /** 127 181 * @group bp_notifications_add_notification 128 182 */ 129 183 public function test_bp_notifications_add_notification_no_dupes() {
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)