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.


Built from https://develop.svn.wordpress.org/trunk@59923


git-svn-id: http://core.svn.wordpress.org/trunk@59265 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
audrasjb
2025-03-04 05:55:23 +00:00
parent 0afbfec0fd
commit 56456e0a1c
2 changed files with 4 additions and 3 deletions

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 {

View File

@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.8-alpha-59922';
$wp_version = '6.8-alpha-59923';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.