Activity::prefetch()
Description #
Prefetch question, answer, comment and user data.
Firstly it group ids and then fetch data by ids in single query and then cache each of them. Using this method reduces mysql queries and also speed up site.
Source #
File: includes/class/class-activity.php
private function prefetch() { foreach ( (array) $this->objects as $key => $activity ) { // Add question and answer id. if ( ! empty( $activity->q_id ) ) { $this->add_prefetch_id( 'post', $activity->q_id ); $this->add_prefetch_id( 'post', $activity->a_id ); } // Add comment ID. if ( ! empty( $activity->c_id ) ) { $this->add_prefetch_id( 'comment', $activity->c_id ); } // Add user ID. if ( ! empty( $activity->user_id ) ) { $this->add_prefetch_id( 'user', $activity->user_id ); } } $this->prefetch_posts(); $this->prefetch_actors(); $this->prefetch_comments(); }
Expand full source code Collapse full source code View on GitHub: includes/class/class-activity.php:192
Add your comment