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.



git-svn-id: https://develop.svn.wordpress.org/trunk@59923 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jb Audras 2025-03-04 05:53:27 +00:00
parent b1cfb19629
commit 1439cc5f40

View File

@ -215,6 +215,7 @@ function wp_insert_link( $linkdata, $wp_error = false ) {
$link_rss = ( ! empty( $parsed_args['link_rss'] ) ) ? $parsed_args['link_rss'] : '';
$link_rel = ( ! empty( $parsed_args['link_rel'] ) ) ? $parsed_args['link_rel'] : '';
$link_category = ( ! empty( $parsed_args['link_category'] ) ) ? $parsed_args['link_category'] : array();
$link_updated = gmdate( 'Y-m-d H:i:s', current_time( 'timestamp', 0 ) );
// Make sure we set a valid category.
if ( ! is_array( $link_category ) || 0 === count( $link_category ) ) {
@ -222,7 +223,7 @@ function wp_insert_link( $linkdata, $wp_error = false ) {
}
if ( $update ) {
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' ) ) ) {
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' ) ) ) {
if ( $wp_error ) {
return new WP_Error( 'db_update_error', __( 'Could not update link in the database.' ), $wpdb->last_error );
} else {
@ -230,7 +231,7 @@ function wp_insert_link( $linkdata, $wp_error = false ) {
}
}
} else {
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' ) ) ) {
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' ) ) ) {
if ( $wp_error ) {
return new WP_Error( 'db_insert_error', __( 'Could not insert link into the database.' ), $wpdb->last_error );
} else {