Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/22/2022 06:54:08 PM (3 years ago)
Author:
imath
Message:

Clear the notifications user cache when bulk updating/deleting items

This commit also groups PHP Unit tests about notifications cache functions into a specific file.

Props niftythree, oztaser.

See #8637 (trunk)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-notifications/classes/class-bp-notifications-notification.php

    r13184 r13243  
    934934        $conditions[] = "{$field} IN ({$_items})";
    935935
    936         foreach ( $update_args['data'] as $field => $value ) {
    937             $index  = array_search( $field, array_keys( $update_args['data'] ) );
     936        foreach ( $update_args['data'] as $update_field => $value ) {
     937            $index  = array_search( $update_field, array_keys( $update_args['data'] ) );
    938938            $format = $update_args['format'][ $index ];
    939939
    940             $fields[] = "{$field} = {$format}";
     940            $fields[] = "{$update_field} = {$format}";
    941941            $values[] = $value;
    942942        }
    943943
    944         foreach ( $where_args['data'] as $field => $value ) {
    945             $index  = array_search( $field, array_keys( $where_args['data'] ) );
     944        foreach ( $where_args['data'] as $where_field => $value ) {
     945            $index  = array_search( $where_field, array_keys( $where_args['data'] ) );
    946946            $format = $where_args['format'][ $index ];
    947947
    948             $conditions[] = "{$field} = {$format}";
     948            $conditions[] = "{$where_field} = {$format}";
    949949            $values[]     = $value;
    950950        }
     
    952952        $fields     = implode( ', ', $fields );
    953953        $conditions = implode( ' AND ', $conditions );
     954
     955        if ( 'item_id' === $field && isset( $where_args['data']['user_id'] ) ) {
     956            $where_args['item_ids'] = $items;
     957            $where_args['user_id']  = $where_args['data']['user_id'];
     958        } elseif ( 'id' === $field ) {
     959            $where_args['ids'] = $items;
     960        }
    954961
    955962        /** This action is documented in bp-notifications/classes/class-bp-notifications-notification.php */
     
    10221029        $conditions[] = "{$field} IN ({$_items})";
    10231030
    1024         foreach ( $where['data'] as $field => $value ) {
    1025             $index  = array_search( $field, array_keys( $where['data'] ) );
     1031        foreach ( $where['data'] as $where_field => $value ) {
     1032            $index  = array_search( $where_field, array_keys( $where['data'] ) );
    10261033            $format = $where['format'][ $index ];
    10271034
    1028             $conditions[] = "{$field} = {$format}";
     1035            $conditions[] = "{$where_field} = {$format}";
    10291036            $values[]     = $value;
    10301037        }
    10311038
    10321039        $conditions = implode( ' AND ', $conditions );
     1040
     1041        if ( 'id' === $field ) {
     1042            $args['id'] = $items;
     1043        }
    10331044
    10341045        /** This action is documented in bp-notifications/classes/class-bp-notifications-notification.php */
Note: See TracChangeset for help on using the changeset viewer.