← All changes
|
src/integrations/admin/admin-columns-cache-integration.php
+15
-7
18.2
→
28.5
View file →
| @@ -52,8 +52,10 @@ | ||
| 52 | 52 | * indexables on admin pages. |
| 53 | 53 | * |
| 54 | 54 | * This cache is used in showing the Yoast SEO columns on the posts overview |
| 55 | 55 | * page (e.g. keyword score, incoming link count, etc.) |
| 56 | + * | |
| 57 | + * @return void | |
| 56 | 58 | */ |
| 57 | 59 | public function register_hooks() { |
| 58 | 60 | // Hook into tablenav to calculate links and linked. |
| 59 | 61 | \add_action( 'manage_posts_extra_tablenav', [ $this, 'maybe_fill_cache' ] ); |
| @@ -62,8 +64,10 @@ | ||
| 62 | 64 | /** |
| 63 | 65 | * Makes sure we calculate all values in one query by filling our cache beforehand. |
| 64 | 66 | * |
| 65 | 67 | * @param string $target Extra table navigation location which is triggered. |
| 68 | + * | |
| 69 | + * @return void | |
| 66 | 70 | */ |
| 67 | 71 | public function maybe_fill_cache( $target ) { |
| 68 | 72 | if ( $target === 'top' ) { |
| 69 | 73 | $this->fill_cache(); |
| @@ -71,8 +75,10 @@ | ||
| 71 | 75 | } |
| 72 | 76 | |
| 73 | 77 | /** |
| 74 | 78 | * Fills the cache of indexables for all known post IDs. |
| 79 | + * | |
| 80 | + * @return void | |
| 75 | 81 | */ |
| 76 | 82 | public function fill_cache() { |
| 77 | 83 | global $wp_query; |
| 78 | 84 | |
| @@ -108,9 +114,11 @@ | ||
| 108 | 114 | |
| 109 | 115 | $indexables = $this->indexable_repository->find_by_multiple_ids_and_type( $post_ids, 'post', false ); |
| 110 | 116 | |
| 111 | 117 | foreach ( $indexables as $indexable ) { |
| 112 | - $this->indexable_cache[ $indexable->object_id ] = $indexable; | |
| 118 | + if ( $indexable instanceof Indexable ) { | |
| 119 | + $this->indexable_cache[ $indexable->object_id ] = $indexable; | |
| 120 | + } | |
| 113 | 121 | } |
| 114 | 122 | } |
| 115 | 123 | |
| 116 | 124 | /** |
| @@ -167,9 +175,9 @@ | ||
| 167 | 175 | } |
| 168 | 176 | $pages_map[ $page->ID ] = $page; |
| 169 | 177 | } |
| 170 | 178 | |
| 171 | - $pages = &$top_level_pages; | |
| 179 | + $pages = $top_level_pages; | |
| 172 | 180 | } |
| 173 | 181 | |
| 174 | 182 | $count = 0; |
| 175 | 183 | $start = ( ( $pagenum - 1 ) * $per_page ); |
| @@ -215,9 +223,9 @@ | ||
| 215 | 223 | * Copied over with some changes from WP_Posts_List_Table::_page_rows. |
| 216 | 224 | * |
| 217 | 225 | * @param array $children_pages The full map of child pages. |
| 218 | 226 | * @param int $count The number of pages already processed. |
| 219 | - * @param int $parent The parent that's currently being processed. | |
| 227 | + * @param int $parent_id The id of the parent that's currently being processed. | |
| 220 | 228 | * @param int $start The number at which the current overview starts. |
| 221 | 229 | * @param int $end The number at which the current overview ends. |
| 222 | 230 | * @param int $to_display The page IDs to be shown. |
| 223 | 231 | * @param int $pages_map A map of page ID to an object with ID and post_parent. |
| @@ -223,14 +231,14 @@ | ||
| 223 | 231 | * @param int $pages_map A map of page ID to an object with ID and post_parent. |
| 224 | 232 | * |
| 225 | 233 | * @return void |
| 226 | 234 | */ |
| 227 | - private function get_child_page_ids( &$children_pages, &$count, $parent, $start, $end, &$to_display, &$pages_map ) { | |
| 228 | - if ( ! isset( $children_pages[ $parent ] ) ) { | |
| 235 | + private function get_child_page_ids( &$children_pages, &$count, $parent_id, $start, $end, &$to_display, &$pages_map ) { | |
| 236 | + if ( ! isset( $children_pages[ $parent_id ] ) ) { | |
| 229 | 237 | return; |
| 230 | 238 | } |
| 231 | 239 | |
| 232 | - foreach ( $children_pages[ $parent ] as $page ) { | |
| 240 | + foreach ( $children_pages[ $parent_id ] as $page ) { | |
| 233 | 241 | if ( $count >= $end ) { |
| 234 | 242 | break; |
| 235 | 243 | } |
| 236 | 244 | |
| @@ -265,7 +273,7 @@ | ||
| 265 | 273 | |
| 266 | 274 | $this->get_child_page_ids( $children_pages, $count, $page->ID, $start, $end, $to_display, $pages_map ); |
| 267 | 275 | } |
| 268 | 276 | |
| 269 | - unset( $children_pages[ $parent ] ); // Required in order to keep track of orphans. | |
| 277 | + unset( $children_pages[ $parent_id ] ); // Required in order to keep track of orphans. | |
| 270 | 278 | } |
| 271 | 279 | } |