[wp-trac] [WordPress Trac] #28155: mysqli flush issues

WordPress Trac noreply at wordpress.org
Sun Oct 12 11:04:22 UTC 2014


#28155: mysqli flush issues
------------------------------------+------------------------------
 Reporter:  soulseekah              |       Owner:
     Type:  defect (bug)            |      Status:  new
 Priority:  normal                  |   Milestone:  Awaiting Review
Component:  Database                |     Version:  3.9
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:
------------------------------------+------------------------------
Changes (by soulseekah):

 * keywords:  has-patch needs-unit-tests dev-feedback => has-patch dev-
     feedback


Comment:

 {{{is_resource}}} issues apart, since those are evident, here are some
 further thoughts on {{{mysqli_free_result}}}.

 {{{MYSQLI_STORE_RESULT}}} is the default mode when using
 {{{mysqli_query}}} without the {{{resultmode}}} set. This is currently the
 way it's being done in WordPress.

 {{{mysqli_free_result}}} must be called when {{{resultmode}}} is
 {{{MYSQLI_USE_RESULT}}}, but judging by the source code for the mysqlnd
 freeing a stored result is not useless. So we can call
 {{{mysqli_free_result}}} either way on the current result.

 Moving on to calling procedures using {{{mysqli_query}}} (which is what
 WordPress will gladly do.

 > For non-DML queries (not INSERT, UPDATE or DELETE), this function is
 similar to calling mysqli_real_query() followed by either
 mysqli_use_result() or mysqli_store_result().

 http://ru2.php.net/manual/en/mysqli.query.php

 Do a search for "stored procedure" to read more comments.

 https://bugs.php.net/bug.php?id=35203
 https://bugs.php.net/bug.php?id=32882

 Since procedures can return more than one resultset (and in many cases do,
 especially the additional 'OK' or 'ERR' resultset) it is strongly
 recommended to use {{{mysqli_multi_query}}}.

 So as it stands, in order to properly call a procedure we can't use the
 WordPress Database API (not without the suggested hacks of iterating over
 the resultsets). So this is partially a misuse of mysqli by {{{$wpdb}}} on
 at least CALL procedure queries. This is not critical, since multiple
 resultsets can still be fetched using {{{next_result}}} and
 {{{use/store_result}}} without any apparent issues.

 However, since the WordPress Database API does not currently expose the
 aforementioned functions it is impossible to retrieve multiple resultsets
 by using it. This is, however, a separate issue that I have created a new
 ticket for: #29938

 Note that {{{more_results}} will only return true inside of
 {{{$wpdb->flush}}} if there are indeed more resultsets waiting to be used
 or stored, resulting in sync errors unless looped over.

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


More information about the wp-trac mailing list