Skip Navigation

[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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 9 replies, has 3 voices.

Last updated by Waqar 10 months, 3 weeks ago.

Assisted by: Waqar.

Author
Posts
#2674537

PHP Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /wp-includes/formatting.php on line 1608

PHP 19. toolset_get_related_posts($query_by_elements = 19, $relationship = 'refi-title-fees', $args_or_query_by_role = 'parent', $legacy_limit = 9223372036854775807, $legacy_offset = 0, $legacy_args = ['meta_key' => 'toolset-post-sortorder'], $legacy_return = 'post_id', $legacy_role_name_to_return = 'other', $legacy_orderby = 'meta_value_num', $legacy_order = *uninitialized*, $legacy_need_found_rows = *uninitialized*, $legacy_found_rows = *uninitialized*) /wp-content/plugins/tk-calc-closing-costs/src/Calc/Abstract_Calc.php:995
PHP 20. OTGS\Toolset\Common\Interop\Commands\RelatedPosts->get_results() /wp-content/plugins/types/vendor/toolset/toolset-common/inc/public_api/m2m.php:111
PHP 21. OTGS\Toolset\Common\Relationships\DatabaseLayer\Version2\AssociationQuery\Query->get_results() /wp-content/plugins/types/vendor/toolset/toolset-common/inc/autoloaded/interop/commands/RelatedPosts.php:585
PHP 22. OTGS\Toolset\Common\Relationships\DatabaseLayer\Version2\AssociationQuery\Query->get_post_type_constraints($root_condition = class OTGS\Toolset\Common\Relationships\GenericQuery\Condition\AndOperator..........

#2674741

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

I don't see the full details of the stack trace in your message to know how the line which triggers the warning is called.

If you have the full stack trace that would be helpful.

Also, can you share the exact code you are using, where you utilise tooset_get_related_posts?

Thanks.

#2675817

$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'
);

#2676085

Hi,

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.

regards,
Waqar

#2676272

Thank you for sharing these details.

I tried to login to the admin area, but it is showing the message 'reCAPTCHA verification failed'.

There is also this warning on the page about the incorrect site key for the reCAPTCHA:


ERROR for site owner:
Invalid domain for site key

Can you please deactivate this reCAPTCHA/security plugin?

#2676320

fixed, try again please

#2676392

The reCAPTCHA key issue is fixed, thank you.

But now the login page is asking me to verify through the bio-metric or through hardware USB key.
( screenshot: hidden link )

Can you please temporarily disabled this layer of security or share a way to by-pass that?

#2676439

please try again now

#2676833

The access details worked, thank you.

Just wanted to let you know that I'm still working on this and will share the findings, as soon as this troubleshooting completes.

Thank you for your patience.

#2677146

Thank you for waiting.

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;
	}

#2677426

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