Opened 12 years ago
Closed 12 years ago
#21800 closed enhancement (fixed)
Include error reporting on failed DB INSERT in term_relationships
Reported by: | jndetlefsen | Owned by: | ryan |
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | normal | Version: | 2.5 |
Component: | Database | Keywords: | has-patch 2nd-opinion |
Focuses: | Cc: |
Description
We have noticed that there is no error reporting when the database operation fail that inserts data into term_relationships. See attached file for suggested patch.
Attachments (2)
Change History (9)
#1
@
12 years ago
- Component changed from Database to Taxonomy
- Keywords has-patch added
- Version changed from trunk to 2.5
#2
@
12 years ago
- Keywords 2nd-opinion added
Actually, WP doesn't check anywhere if INSERT and UPDATE queries fail.
This has all sorts of interesting side-effects:
You can make the database read-only and WP will function normally, except for not saving any of your changes.
Then, if you add a persistent object cache on top, the changes will be saved in the cache but not in the database. And you'll scratch your head trying to figure out why your DB doesn't seem to be read-only anymore. :)
#4
follow-up:
↓ 5
@
12 years ago
There are already cases where a failed INSERTS causes a WP_Error, for example in line 2088 in the same file, taxonomy.php. Or am i missing something?
if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
https://core.trac.wordpress.org/browser/trunk/wp-includes/taxonomy.php
Our situation is that we have to update blogposts on >1000 blogs on a multisite and in some cases the taxonomy relationships don't get written to the database. We want to wrap those updates into mysql transaction but as of now we have no way to know when inserts have failed so that we can rollback those transactions to avoid to have blogposts with no tags.
#5
in reply to:
↑ 4
@
12 years ago
Replying to jndetlefsen:
There are already cases where a failed INSERTS causes a WP_Error, for example in line 2088 in the same file, taxonomy.php.
Yeah, then I guess we're just inconsistent. The idea is that we should fix this everywhere, not just when dealing with term relationships.
A good start would be adding checks for all the functions inside taxonomy.php. Then we can move on to post.php etc.
Related: [6851] (for #5857).