[wp-trac] [WordPress Trac] #28425: get_permalink passes only post ID to called functions instead of post object

WordPress Trac noreply at wordpress.org
Fri Jun 20 18:22:20 UTC 2014


#28425: get_permalink passes only post ID to called functions instead of post
object
-------------------------------+--------------------------
 Reporter:  arnee              |       Owner:
     Type:  enhancement        |      Status:  new
 Priority:  normal             |   Milestone:  4.0
Component:  Posts, Post Types  |     Version:  trunk
 Severity:  normal             |  Resolution:
 Keywords:  has-patch          |     Focuses:  performance
-------------------------------+--------------------------

Comment (by arnee):

 @kovshenin, as I wrote before any time you query a page directly with wpdb
 and try to get the permalink then.


 {{{
 $posts = $wpdb->get_results("SELECT * FROM wp_posts WHERE ID=21278");
 $p = $posts[0];
 $permalink = get_permalink($p);
 var_dump($wpdb->queries);
 }}}

 wpdb->queries:
 {{{
   [7]=>
   array(3) {
     [0]=>
     string(37) "SELECT * FROM wp_posts WHERE ID=21278"
     [1]=>
     float(0.00099992752075195)
     [2]=>
     string(0) ""
   }
   [8]=>
   array(3) {
     [0]=>
     string(47) "SELECT * FROM wp_posts WHERE ID = 21278 LIMIT 1"
     [1]=>
     float(0)
     [2]=>
     string(61) "get_permalink, get_page_link, get_post,
 WP_Post::get_instance"
   }
 }}}

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


More information about the wp-trac mailing list