[Resolved] toolset_get_related_posts() throws LOTS of LONG debug notices with PHP 8.1
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
$repeater_item_ids = toolset_get_related_posts(
Common::get_company_id(),
$this->get_quote_type_item_value( 'title_fees_group_slug' ), // must be 20 characters or fewer
'parent',
PHP_INT_MAX, // `-1` for unlimited does not work
0,
[ 'meta_key' => Toolset_Post::SORTORDER_META_KEY ], // phpcs:ignore
'post_id',
'other',
'meta_value_num'
);
Thank you for sharing this code snippet, but it doesn't provide the full context.
Can you please share temporary admin login details of the website where this code/custom plugin is in use? If its a localhost website, you can either put in on an online server or share its duplicator package.
( ref: https://toolset.com/faq/provide-supporters-copy-site/ )
Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.
During troubleshooting, I noticed that warnings and errors are generated when the company ID to get the related posts from, doesn't exists.
You can update the 'get_title_fees_item_ids' function in your plugin to include an empty check, before getting the related posts:
( file: /wp-content/plugins/tk-calc-closing-costs/src/Calc/Abstract_Calc.php )
private function get_title_fees_item_ids(): array {
if ( ! function_exists( 'toolset_get_related_posts' ) ) {
return [];
}
$company_id = Common::get_company_id();
if ( empty($company_id) ) {
return [];
}
$repeater_item_ids = toolset_get_related_posts(
$company_id,
$this->get_quote_type_item_value( 'title_fees_group_slug' ), // must be 20 characters or fewer
'parent',
PHP_INT_MAX, // `-1` for unlimited does not work
0,
[ 'meta_key' => Toolset_Post::SORTORDER_META_KEY ], // phpcs:ignore
'post_id',
'other',
'meta_value_num'
);
// Protect against boolean from an error.
if ( ! is_array( $repeater_item_ids ) ) {
$repeater_item_ids = [];
}
return $repeater_item_ids;
}
tyvm for your efforts tracking this down! I have noted it for the future once all my other plugins are ready for PHP 8.1
Clifford confirmed that the issue was resolved on 2024-01-06 23:46:55.
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.