Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List table $post is null in exports #1068

Open
justinmaurerdotdev opened this issue Oct 24, 2024 · 0 comments · May be fixed by #1069
Open

List table $post is null in exports #1068

justinmaurerdotdev opened this issue Oct 24, 2024 · 0 comments · May be fixed by #1069

Comments

@justinmaurerdotdev
Copy link

There are some (I believe, legitimate) cases where the Co-Authors column is failing to generate the correct values. One such example is the exports created in the Admin Columns plugin. I believe their plugin renders the list tables using WP_Query, but not actually doing a Loop. They, I suppose, rely on the manage_{$post->post_type}_posts_custom_column hook being used as advertised, where the post ID is taken from the callback's arguments. In the current Co-Authors code, the ID is taken from the global $post;, which, in these use cases, is not set.

The result is the "warning" below, which is accompanied by in an empty Co-Authors column in the export.

PHP Warning:  Attempt to read property "ID" on null in /var/www/html/wp-content/plugins/co-authors-plus/php/class-coauthors-plus.php on line 580
PHP Stack trace:
PHP   1. {main}() /var/www/html/wp-admin/edit.php:0
PHP   2. WP_Posts_List_Table->prepare_items() /var/www/html/wp-admin/edit.php:235
PHP   3. wp_edit_posts_query($q = *uninitialized*) /var/www/html/wp-admin/includes/class-wp-posts-list-table.php:165
PHP   4. wp($query_vars = ['post_type' => 'post', 'post_status' => '', 'perm' => '', 'order' => 'desc', 'orderby' => '15b2a971b5c28f', 'posts_per_page' => 200]) /var/www/html/wp-admin/includes/post.php:1306
PHP   5. WP->main($query_args = ['post_type' => 'post', 'post_status' => '', 'perm' => '', 'order' => 'desc', 'orderby' => '15b2a971b5c28f', 'posts_per_page' => 200]) /var/www/html/wp-includes/functions.php:1336
PHP   6. WP->query_posts() /var/www/html/wp-includes/class-wp.php:816
PHP   7. WP_Query->query($query = ['order' => 'desc', 'orderby' => '15b2a971b5c28f', 'author_name' => '[REDACTED]', 'post_type' => 'post', 'posts_per_page' => 200, 'post_status' => '', 'perm' => '']) /var/www/html/wp-includes/class-wp.php:696
PHP   8. WP_Query->get_posts() /var/www/html/wp-includes/class-wp-query.php:3852
PHP   9. apply_filters_ref_array($hook_name = 'the_posts', $args = [0 => [0 => class WP_Post { ... }, 1 => class WP_Post { ... }, 2 => class WP_Post { ... }, 3 => class WP_Post { ... },...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant