Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/23/2021 11:31:33 PM (6 years ago)
Author:
dcavins
Message:

BP_Invitation: Increment date_modified on key actions.

When an invitation is sent or accepted, the date_modified
should be updated. However, if a date_modified has been
specified in the invitation or request creation function
(as we do in our unit test functions), the date_modified
should be set to that, even if notices are sent (now) as
part of the creation process.

Ensure that BP_Invitation::get_query_clauses() handles specified date_modified data updates.

Fixes #8444.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-invitation.php

    r12867 r12873  
    639639                                $where_clauses['format'][] = '%d';
    640640                        }
     641                }
     642
     643                // date_modified
     644                if ( ! empty( $args['date_modified'] ) ) {
     645                        $where_clauses['data']['date_modified'] = $args['date_modified'];
     646                        $where_clauses['format'][] = '%s';
    641647                }
    642648
    … …  
    988994         * @since 5.0.0
    989995         *
    990          * @param int $id The ID of the invitation to mark as sent.
    991          */
    992         public static function mark_sent( $id = 0 ) {
     996         * @param int   $id   The ID of the invitation to mark as sent.
     997         * @param array $args {
     998         *     Optional. Invitation characteristics used
     999         *     to override certain sending behaviors.
     1000         *
     1001         *     @type string $date_modified Modified time in 'Y-m-d h:i:s' format, GMT.
     1002         *                                 Defaults to current time if not specified.
     1003         * }
     1004         * @return int|bool The number of rows updated, or false on error.
     1005         */
     1006        public static function mark_sent( $id = 0, $args = array() ) {
    9931007
    9941008                if ( ! $id ) {
    … …  
    9981012                // Values to be updated.
    9991013                $update_args = array(
    1000                         'invite_sent' => 'sent',
     1014                        'invite_sent'   => 'sent',
     1015                        'date_modified' => bp_core_current_time(),
    10011016                );
     1017                // Respect a specified `date-modified`.
     1018                if ( ! empty( $args['date_modified'] ) ) {
     1019                        $update_args['date_modified'] = $args['date_modified'];
     1020                }
    10021021
    10031022                // WHERE clauses.
    … …  
    10151034         * @since 5.0.0
    10161035         *
    1017          * @param array $args See BP_Invitation::update().
     1036         * @param array $args See BP_Invitation::update().
     1037         * @return int|bool The number of rows updated, or false on error.
    10181038         */
    10191039        public static function mark_sent_by_data( $args ) {
    … …  
    10211041                // Values to be updated.
    10221042                $update_args = array(
    1023                         'invite_sent' => 'sent',
     1043                        'invite_sent'   => 'sent',
     1044                        'date_modified' => bp_core_current_time(),
    10241045                );
     1046                // Respect a specified `date-modified`.
     1047                if ( ! empty( $args['date_modified'] ) ) {
     1048                        $update_args['date_modified'] = $args['date_modified'];
     1049                }
    10251050
    10261051                return self::update( $update_args, $args );
    … …  
    10341059         * @since 5.0.0
    10351060         *
    1036          * @param int $id The ID of the invitation to mark as sent.
    1037          */
    1038         public static function mark_accepted( $id = 0 ) {
     1061         * @param int   $id   The ID of the invitation to mark as sent.
     1062         * @param array $args {
     1063         *     Optional. Invitation characteristics used
     1064         *     to override certain sending behaviors.
     1065         *
     1066         *     @type string $date_modified Modified time in 'Y-m-d h:i:s' format, GMT.
     1067         *                                 Defaults to current time if not specified.
     1068         * }
     1069         * @return int|bool The number of rows updated, or false on error.
     1070         */
     1071        public static function mark_accepted( $id = 0, $args = array() ) {
    10391072
    10401073                if ( ! $id ) {
    … …  
    10441077                // Values to be updated.
    10451078                $update_args = array(
    1046                         'accepted' => 'accepted',
     1079                        'accepted'      => 'accepted',
     1080                        'date_modified' => bp_core_current_time(),
    10471081                );
     1082                // Respect a specified `date-modified`.
     1083                if ( ! empty( $args['date_modified'] ) ) {
     1084                        $update_args['date_modified'] = $args['date_modified'];
     1085                }
    10481086
    10491087                // WHERE clauses.
    … …  
    10611099         * @since 5.0.0
    10621100         *
    1063          * @param array $args See BP_Invitation::update().
     1101         * @param array $args See BP_Invitation::update().
     1102         * @return int|bool The number of rows updated, or false on error.
    10641103         */
    10651104        public static function mark_accepted_by_data( $args ) {
    … …  
    10671106                // Values to be updated.
    10681107                $update_args = array(
    1069                         'accepted' => 'accepted',
     1108                        'accepted'      => 'accepted',
     1109                        'date_modified' => bp_core_current_time(),
    10701110                );
     1111                // Respect a specified `date-modified`.
     1112                if ( ! empty( $args['date_modified'] ) ) {
     1113                        $update_args['date_modified'] = $args['date_modified'];
     1114                }
    10711115
    10721116                return self::update( $update_args, $args );
Note: See TracChangeset for help on using the changeset viewer.