Make WordPress Core

Changeset 59923


Ignore:
Timestamp:
03/04/2025 05:53:27 AM (2 months ago)
Author:
audrasjb
Message:

Bookmarks: Update link_updated when a link is created or updated.

This changeset fixes an issue where the link_updated field was not updated in the old Link Manager. When a link was created or updated the link_updated field remained 0000-00-00 00:00:00.

Props lenasterg, audrasjb.
Fixes #56851.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/bookmark.php

    r55705 r59923  
    216216    $link_rel         = ( ! empty( $parsed_args['link_rel'] ) ) ? $parsed_args['link_rel'] : '';
    217217    $link_category    = ( ! empty( $parsed_args['link_category'] ) ) ? $parsed_args['link_category'] : array();
     218    $link_updated     = gmdate( 'Y-m-d H:i:s', current_time( 'timestamp', 0 ) );
    218219
    219220    // Make sure we set a valid category.
     
    223224
    224225    if ( $update ) {
    225         if ( false === $wpdb->update( $wpdb->links, compact( 'link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss' ), compact( 'link_id' ) ) ) {
     226        if ( false === $wpdb->update( $wpdb->links, compact( 'link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss', 'link_updated' ), compact( 'link_id' ) ) ) {
    226227            if ( $wp_error ) {
    227228                return new WP_Error( 'db_update_error', __( 'Could not update link in the database.' ), $wpdb->last_error );
     
    231232        }
    232233    } else {
    233         if ( false === $wpdb->insert( $wpdb->links, compact( 'link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss' ) ) ) {
     234        if ( false === $wpdb->insert( $wpdb->links, compact( 'link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss', 'link_updated' ) ) ) {
    234235            if ( $wp_error ) {
    235236                return new WP_Error( 'db_insert_error', __( 'Could not insert link into the database.' ), $wpdb->last_error );
Note: See TracChangeset for help on using the changeset viewer.