[wp-trac] [WordPress Trac] #55811: OrderBy rand in get_posts stopped working after updating to WordPress 6.0
WordPress Trac
noreply at wordpress.org
Wed May 25 02:19:11 UTC 2022
#55811: OrderBy rand in get_posts stopped working after updating to WordPress 6.0
-------------------------------------------+---------------------
Reporter: itsabhineet | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.0.1
Component: Posts, Post Types | Version: 6.0
Severity: major | Resolution:
Keywords: needs-patch reporter-feedback | Focuses:
-------------------------------------------+---------------------
Comment (by itsabhineet):
- Full stack trace-
{{{PHP Fatal error: Uncaught Error: Object of class stdClass could not be
converted to string in .../wp-content/object-cache.php:1132\nStack
trace:\n#0 .../wp-content/object-cache.php(1132): array_combine()\n#1
.../wp-content/object-cache.php(52): WP_Object_Cache->add_multiple()\n#2
.../wp-includes/post.php(7362): wp_cache_add_multiple()\n#3 .../wp-
includes/post.php(7442): update_post_cache()\n#4 .../wp-
includes/post.php(7856): update_post_caches()\n#5 .../wp-includes/class-
wp-query.php(3134): _prime_post_caches()\n#6 .../wp-includes/class-wp-
query.php(3586): WP_Query->get_posts()\n#7 .../wp-includes/post.php(2410):
WP_Query->query()\n#8 .../wp-content/plugins/...my_plugin_file_01.php:
get_posts()\n#9 .../wp-includes/template.php(772): require('...')\n#10
.../wp-includes/template.php(716): load_template()\n#11 .../wp-includes
/general-template.php(204): locate_template()\n#12 .../wp-
content/plugins/...my_plugin_file_02.php: get_template_part()\n#13 .../wp-
content/plugins/...my_plugin_file_02.php:
My_Plugin_Class->function_01()\n#14 .../wp-includes/rest-api/class-wp-
rest-server.php(1143): My_Plugin_Class->function_02()\n#15 .../wp-includes
/rest-api/class-wp-rest-server.php(990):
WP_REST_Server->respond_to_request()\n#16 .../wp-includes/rest-api/class-
wp-rest-server.php(414): WP_REST_Server->dispatch()\n#17 .../wp-includes
/rest-api.php(394): WP_REST_Server->serve_request()\n#18 .../wp-includes
/class-wp-hook.php(307): rest_api_loaded()\n#19 .../wp-includes/class-wp-
hook.php(331): WP_Hook->apply_filters()\n#20 .../wp-
includes/plugin.php(524): WP_Hook->do_action()\n#21 .../wp-includes/class-
wp.php(398): do_action_ref_array()\n#22 .../wp-includes/class-wp.php(770):
WP->parse_request()\n#23 .../wp-includes/functions.php(1330):
WP->main()\n#24 .../wp-blog-header.php(16): wp()\n#25 .../index.php(17):
require('...')\n#26 {main}\n thrown in .../wp-content/object-cache.php on
line 1132}}}
- The code block-
{{{
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 30,
'ignore_sticky_posts' => true,
'meta_key' => 'some_key',
'meta_compare' => 'EXISTS',
'orderby' => 'rand'
);
$posts = get_posts( $args );
}}}
- I am using only one plugin- **Redis Cache**. I cleared the cache, but it
is still throwing the error.
- I also rebooted my server, but the problem persists.
Replying to [comment:3 costdev]:
> Milestoning for `6.0.1` for visibility.
>
> @itsabhineet, can you provide any other details, such as:
>
> - All remaining information provided in the error message/stacktrace.
> - The code block (wrap this in `{{{ code here }}}`) used for
`get_posts()`.
> - Caching plugins that you're using.
> - Whether you can clear the cache and, if so, whether the issue
persists/changes/disappears after clearing the cache.
>
> Thanks!
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55811#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list