[wp-trac] [WordPress Trac] #35246: post_exists creates SQL-error

WordPress Trac noreply at wordpress.org
Mon Dec 28 17:43:15 UTC 2015


#35246: post_exists creates SQL-error
------------------------------+-----------------------------
 Reporter:  yetAnotherDaniel  |      Owner:
     Type:  defect (bug)      |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  Administration    |    Version:  4.4
 Severity:  normal            |   Keywords:
  Focuses:                    |
------------------------------+-----------------------------
 Function post_exists is missing a space:
 {{{#!php
 <?php
 'AND post_content = %s' // wrong
 ' AND post_content = %s' // correct
 }}}

 Therefore, it produces an SQL error under the following circumstances:

 Create a post with empty title and content '123'.

 Run at admin:


 {{{#!php
 <?php
 add_action( 'admin_init', function() {
         echo post_exists( '', '123' ); exit;
 });
 }}}


 Produces:
 '...You have an error in your SQL syntax...'

 I attached a proposal.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35246>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list