[wp-trac] [WordPress Trac] #9422: Make WP transaction safe
WordPress Trac
wp-trac at lists.automattic.com
Tue Mar 31 17:54:40 GMT 2009
#9422: Make WP transaction safe
-------------------------------+--------------------------------------------
Reporter: Denis-de-Bernardy | Owner: anonymous
Type: enhancement | Status: new
Priority: normal | Milestone: Unassigned
Component: Optimization | Version: 2.7.1
Severity: normal | Keywords:
-------------------------------+--------------------------------------------
It would be sweet if WP were to become 100% transaction safe. I wondered
if it was, while developing a plugin that required InnoDB tables and
transactions for its own tables, as well as InnoDB on the users and posts
table in order to enforce foreign key constraints.
Things like:
{{{
do_action('delete_user', $id);
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID = %d",
$id) );
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id =
%d", $id) );
}}}
Should really be:
{{{
do_action('delete_user', $id);
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id =
%d", $id) );
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID = %d",
$id) );
}}}
That way, if one enforces the relevant foreign key and deletes a user as
part of a transaction, the database won't complain. Along the same lines,
the delete post procedure is particularly ugly...
--
Ticket URL: <http://core.trac.wordpress.org/ticket/9422>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list