[wp-trac] [WordPress Trac] #18266: WordPress does not signal DB errors when adding/updating post

WordPress Trac noreply at wordpress.org
Mon Aug 26 16:24:56 UTC 2013


#18266: WordPress does not signal DB errors when adding/updating post
-------------------------+------------------------------
 Reporter:  sirzooro     |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  General      |     Version:  3.2.1
 Severity:  normal       |  Resolution:
 Keywords:               |
-------------------------+------------------------------
Changes (by sirzooro):

 * keywords:  reporter-feedback =>


Comment:

 The main issue is that WP does not check if `wp_insert_post_data` hook
 returned error, and stop operation (see #18692). Because of this I looked
 for some way to force this using some other method, and found that I
 should be able to do this by triggering SQL error. While playing with (I
 had to check how to mask this error from user) I found that real (not
 artificially introduced) SQL error may not be shown, so I logged this
 ticked.

 Here is my code:

 {{{
 function kill_sql_query( $query ) {
         if ( preg_match( '/^\s*(insert|update:?)\s/i', $query ) ) {
                 return 'xxx';
         } else {
                 return $query;
         }
 }

 function my_wp_insert_post_data( $data, $post_arr )
 {
         if ( post_is_invalid( $data ) )
         {
                 // Do not want to execute any extra SQL queries - just
 proceeded to INSERT/UPDATE query for current post
                 remove_all_actions( 'pre_post_update' );

                 // Now we can add the filter
                 add_filter( 'query', 'kill_sql_query' );
         }
         return $data;
 }

 add_filter( 'wp_insert_post_data', 'my_wp_insert_post_data', 100, 2 );
 }}}

--
Ticket URL: <http://core.trac.wordpress.org/ticket/18266#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list