Fixed PHP 8.1: XF\Repository\Payment#logCallback, strlen()

PaulB

Well-known member
Affected version
2.2.8
Code:
ErrorException: Error logging payment to payment provider: [E_DEPRECATED] strlen(): Passing null to parameter #1 ($string) of type string is deprecated src/XF/Repository/Payment.php:103

Code:
#0 src/XF/Repository/Payment.php(103): XF::handlePhpError(8192, '[E_DEPRECATED] ...', 's...', 103)
#1 src/XF/Payment/AbstractProvider.php(229): XF\Repository\Payment->logCallback(NULL, 'stripe', '...', 'error', 'Event data rece...', Array, '...')
#2 payment_callback.php(70): XF\Payment\AbstractProvider->log(Object(XF\Payment\CallbackState))
#3 {main}

PHP:
	public function logCallback($requestKey /* null */, $providerId, $txnId, $logType, $logMessage, array $logDetails, $subId = null)
	{
		/** @var \XF\Entity\PaymentProviderLog $providerLog */
		$providerLog = $this->em->create('XF:PaymentProviderLog');

		if (strlen($requestKey) > 32)  // $requestKey can be null here
		{
		// ...
 

XF Bug Bot

XenForo bug fixer bot
Staff member
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.9).

Change log:
Improve PHP 8.1 compatibility when logging payment callbacks
There may be a delay before changes are rolled out to the XenForo Community.
 
Top