[Resuelto] toolset_get_related_posts() throws LOTS of LONG debug notices with PHP 8.1
This support ticket is created hace 11 meses, 2 semanas. There's a good chance that you are reading advice that it now obsolete.
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.
Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.
$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;
}