Changeset 55608 for trunk/src/wp-includes/class-wp-metadata-lazyloader.php
- Timestamp:
- 03/29/2023 10:48:34 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-metadata-lazyloader.php
r54133 r55608 56 56 'term' => array( 57 57 'filter' => 'get_term_metadata', 58 'callback' => array( $this, 'lazyload_ term_meta' ),58 'callback' => array( $this, 'lazyload_meta_callback' ), 59 59 ), 60 60 'comment' => array( 61 61 'filter' => 'get_comment_metadata', 62 'callback' => array( $this, 'lazyload_ comment_meta' ),62 'callback' => array( $this, 'lazyload_meta_callback' ), 63 63 ), 64 64 ); … … 92 92 } 93 93 94 add_filter( $type_settings['filter'], $type_settings['callback'] );94 add_filter( $type_settings['filter'], $type_settings['callback'], 10, 5 ); 95 95 96 96 /** … … 132 132 * 133 133 * @since 4.5.0 134 * @deprecated 6.3.0 Use WP_Metadata_Lazyloader::lazyload_meta_callback() instead. 134 135 * 135 136 * @param mixed $check The `$check` param passed from the 'get_term_metadata' hook. … … 138 139 */ 139 140 public function lazyload_term_meta( $check ) { 140 if ( ! empty( $this->pending_objects['term'] ) ) { 141 update_termmeta_cache( array_keys( $this->pending_objects['term'] ) ); 142 143 // No need to run again for this set of terms. 144 $this->reset_queue( 'term' ); 145 } 146 147 return $check; 141 _deprecated_function( __METHOD__, '6.3.0', 'WP_Metadata_Lazyloader::lazyload_meta_callback' ); 142 return $this->lazyload_meta_callback( $check, 0, '', false, 'term' ); 148 143 } 149 144 … … 155 150 * 156 151 * @since 4.5.0 152 * @deprecated 6.3.0 Use WP_Metadata_Lazyloader::lazyload_meta_callback() instead. 157 153 * 158 154 * @param mixed $check The `$check` param passed from the {@see 'get_comment_metadata'} hook. … … 160 156 */ 161 157 public function lazyload_comment_meta( $check ) { 162 if ( ! empty( $this->pending_objects['comment'] ) ) { 163 update_meta_cache( 'comment', array_keys( $this->pending_objects['comment'] ) ); 158 _deprecated_function( __METHOD__, '6.3.0', 'WP_Metadata_Lazyloader::lazyload_meta_callback' ); 159 return $this->lazyload_meta_callback( $check, 0, '', false, 'comment' ); 160 } 164 161 165 // No need to run again for this set of comments. 166 $this->reset_queue( 'comment' ); 162 /** 163 * Lazy-loads meta for queued objects. 164 * 165 * This method is public so that it can be used as a filter callback. As a rule, there 166 * is no need to invoke it directly. 167 * 168 * @since 6.3.0 169 * 170 * @param mixed $check The `$check` param passed from the 'get_*_metadata' hook. 171 * @param int $object_id ID of the object metadata is for. 172 * @param string $meta_key Unused. 173 * @param bool $single Unused. 174 * @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user', 175 * or any other object type with an associated meta table. 176 * @return mixed In order not to short-circuit `get_metadata()`. Generally, this is `null`, but it could be 177 * another value if filtered by a plugin. 178 */ 179 public function lazyload_meta_callback( $check, $object_id, $meta_key, $single, $meta_type ) { 180 if ( empty( $this->pending_objects[ $meta_type ] ) ) { 181 return $check; 167 182 } 183 184 $object_ids = array_keys( $this->pending_objects[ $meta_type ] ); 185 if ( $object_id && ! in_array( $object_id, $object_ids, true ) ) { 186 $object_ids[] = $object_id; 187 } 188 189 update_meta_cache( $meta_type, $object_ids ); 190 191 // No need to run again for this set of objects. 192 $this->reset_queue( $meta_type ); 168 193 169 194 return $check;
Note: See TracChangeset
for help on using the changeset viewer.