[wp-trac] [WordPress Trac] #32315: $wpdb->insert fails without error msg

WordPress Trac noreply at wordpress.org
Tue Nov 16 03:37:25 UTC 2021


#32315: $wpdb->insert fails without error msg
--------------------------------------+-----------------------------
 Reporter:  dlt101                    |       Owner:  hellofromTonya
     Type:  defect (bug)              |      Status:  reopened
 Priority:  normal                    |   Milestone:  5.9
Component:  Database                  |     Version:  4.2.1
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+-----------------------------

Comment (by hellofromTonya):

 Replying to [comment:86 SergeyBiryukov]:
 > I also think the `function_exists( '__' )` check might be redundant, as
 we already have a similar line a few lines below without the check:
 > {{{
 > $this->last_error = __( 'Unable to retrieve the error message from
 MySQL' );
 > }}}
 >
 > Looking at other `wpdb` methods, it seems that a more common approach to
 make sure the `__()` function is available is to call
 `wp_load_translations_early()`:
 > {{{
 > wp_load_translations_early();
 > _doing_it_wrong(
 >       'wpdb::prepare',
 >       __( 'The query only expected one placeholder, but an array of
 multiple placeholders was sent.' ),
 >       '4.9.0'
 > );
 > }}}
 >
 > Maybe we could do the same here, for consistency and to simplify the
 code a bit?

 @SergeyBiryukov see @johnbillion's comment [here in the committed
 PR](https://github.com/WordPress/wordpress-
 develop/pull/1874#issuecomment-969226836). What do you think? Remove the
 `function_exists( '__' )` guards?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/32315#comment:87>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list