Fixed Function openssl_pkey_free() is deprecated

TnT

Member
Affected version
2.2.4
Code:
ErrorException: [E_DEPRECATED] Function openssl_pkey_free() is deprecated src/vendor/minishlink/web-push/src/Encryption.php:281
Stack trace:
Code:
#0 src/vendor/minishlink/web-push/src/Encryption.php(281): XF::handlePhpError(8192, '[E_DEPRECATED] ...', '/var/www/tfx2/p...', 281)
#1 src/vendor/minishlink/web-push/src/Encryption.php(246): Minishlink\WebPush\Encryption::createLocalKeyObjectUsingOpenSSL()
#2 src/vendor/minishlink/web-push/src/Encryption.php(64): Minishlink\WebPush\Encryption::createLocalKeyObject()
#3 src/vendor/minishlink/web-push/src/WebPush.php(220): Minishlink\WebPush\Encryption::encrypt('{"title":"Neue ...', 'BAeiuK9g/2cZjTb...', 'Hk9JWNPIU54IDgg...', 'aes128gcm')
#4 src/vendor/minishlink/web-push/src/WebPush.php(168): Minishlink\WebPush\WebPush->prepare(Array)
#5 src/XF/Service/PushNotification.php(204): Minishlink\WebPush\WebPush->flush()
#6 src/XF/Service/PushNotification.php(174): XF\Service\PushNotification->handleResults(Object(Generator))
#7 src/XF/Service/PusherTrait.php(194): XF\Service\PushNotification->sendNotifications()
#8 src/XF/Repository/UserAlert.php(163): XF\Service\Alert\Pusher->push()
#9 src/XF/Repository/UserAlert.php(101): XF\Repository\UserAlert->insertAlert(265519, 265519, 'MaschiTec', 'trophy', 1, 'award', Array, Array)
#10 src/XF/Repository/Trophy.php(96): XF\Repository\UserAlert->alertFromUser(Object(XFRM\XF\Entity\User), Object(XFRM\XF\Entity\User), 'trophy', 1, 'award')
#11 src/XF/Repository/Trophy.php(70): XF\Repository\Trophy->awardTrophyToUser(Object(XF\Entity\Trophy), Object(XFRM\XF\Entity\User))
#12 src/XF/Cron/Trophy.php(38): XF\Repository\Trophy->updateTrophiesForUser(Object(XFRM\XF\Entity\User), Array, Object(XF\Mvc\Entity\ArrayCollection))
#13 [internal function]: XF\Cron\Trophy::runTrophyCheck(Object(XF\Entity\CronEntry))
#14 src/XF/Job/Cron.php(34): call_user_func(Array, Object(XF\Entity\CronEntry))
#15 src/XF/Job/Manager.php(258): XF\Job\Cron->run(7.82237)
#16 src/XF/Job/Manager.php(200): XF\Job\Manager->runJobInternal(Array, 7.82237)
#17 src/XF/Job/Manager.php(84): XF\Job\Manager->runJobEntry(Array, 7.82237)
#18 src/XF/Cli/Command/RunJobs.php(59): XF\Job\Manager->runQueue(false, 8)
#19 src/vendor/symfony/console/Command/Command.php(255): XF\Cli\Command\RunJobs->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 src/vendor/symfony/console/Application.php(992): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 src/vendor/symfony/console/Application.php(255): Symfony\Component\Console\Application->doRunCommand(Object(XF\Cli\Command\RunJobs), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 src/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 src/XF/Cli/Runner.php(109): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 cmd.php(15): XF\Cli\Runner->run()
#25 {main}

Seems to come from job runner:
Code:
cmd.php xf:run-jobs --quiet
 
Though, somewhat ironically, it's not a version that we would actually be able to use because of our minimum version requirements being PHP 7.1 for web push. We're using version 5.2.x of the library.

Note that as this is a E_DEPRECATED error - which we consider to be a development error - this should not be logged or thrown in normal operation. This suggests you may be running with debug mode enabled which is not recommended.

In this specific case as this is occurring within a third party library package, this won't have interrupted execution and will have simply been logged for your information. Ideally you wouldn't be running debug mode, but if you have to this particular log can be safely ignored.

We'll leave the bug report open for now as we may be able to patch the file ourselves for the next release.
 
Last edited:
Hi Chris, thank you for your explanations. I had indeed enabled debug mode, but only for cli. Since I myself do not know exactly why, I have deactivated it for now.
 
This is actually fixed starting with XF 2.2.8.

We had to fork the older version of the library to allow PHP 8.1 support so we've also backported the change which avoids this deprecation notice.
 
Top Bottom