Fixed Undefined variable: option in XF/Repository/Option.php:233

36degrees

Member
Affected version
v2.2.7 PL1
This popped up in our Server Error Log:

Code:
ErrorException: [E_NOTICE] Undefined variable: option src/XF/Repository/Option.php:233

#0 src/XF/Repository/Option.php(233): XF::handlePhpError(8, '[E_NOTICE] Unde...', '/home/bird/publ...', 233, Array)
#1 src/XF/EmailBounce/Processor.php(246): XF\Repository\Option->refreshEmailAccessTokenIfNeeded('emailBounceHand...')
#2 src/XF/SubContainer/Bounce.php(15): XF\EmailBounce\Processor::getDefaultBounceHandlerStorage(Object(XF\Cli\App))
#3 src/XF/Container.php(30): XF\SubContainer\Bounce->XF\SubContainer\{closure}(Object(XF\Container))
#4 src/XF/SubContainer/Bounce.php(43): XF\Container->offsetGet('storage')
#5 src/XF/Job/EmailBounce.php(20): XF\SubContainer\Bounce->storage()
#6 src/XF/Job/Manager.php(260): XF\Job\EmailBounce->run(8)
#7 src/XF/Job/Manager.php(202): XF\Job\Manager->runJobInternal(Array, 8)
#8 src/XF/Job/Manager.php(86): XF\Job\Manager->runJobEntry(Array, 8)
#9 src/XF/Cli/Command/RunJobs.php(59): XF\Job\Manager->runQueue(false, 8)
#10 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))
#11 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))
#12 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))
#13 src/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 src/XF/Cli/Runner.php(111): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 cmd.php(15): XF\Cli\Runner->run()
#16 {main}

A second error recorded at the same time from the same file and line:

Code:
ErrorException: [E_NOTICE] Trying to get property 'option_id' of non-object src/XF/Repository/Option.php:233

This appears to be a reference to $option from inside the catch block if refreshing an OAuth access token fails:

PHP:
\XF::logException($e, false, "Failed to refresh OAuth access token for {$option->option_id}: ");

From looking at the code for the method, I can't see $option defined anywhere.
 
It looks like the exception does get logged, but without an option id:

Code:
GuzzleHttp\Exception\ConnectException: Failed to refresh OAuth access token for : cURL error 28: Resolving timed out after 15000 milliseconds (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) 

#0 src/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(149): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array)
#1 src/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(102): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))
#2 src/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php(43): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))
#3 src/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php(28): GuzzleHttp\Handler\CurlHandler->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#4 src/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php(51): GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#5 src/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php(66): GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler\{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#6 src/vendor/guzzlehttp/guzzle/src/Middleware.php(30): GuzzleHttp\PrepareBodyMiddleware->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#7 src/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php(70): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#8 src/vendor/guzzlehttp/guzzle/src/Middleware.php(58): GuzzleHttp\RedirectMiddleware->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#9 src/vendor/guzzlehttp/guzzle/src/HandlerStack.php(67): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Request), Array)
#10 src/vendor/guzzlehttp/guzzle/src/Client.php(277): GuzzleHttp\HandlerStack->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#11 src/vendor/guzzlehttp/guzzle/src/Client.php(125): GuzzleHttp\Client->transfer(Object(GuzzleHttp\Psr7\Request), Array)
#12 src/vendor/guzzlehttp/guzzle/src/Client.php(131): GuzzleHttp\Client->requestAsync('POST', Object(GuzzleHttp\Psr7\Uri), Array)
#13 src/XF/ConnectedAccount/Http/Client.php(53): GuzzleHttp\Client->request('POST', 'https://account...', Array)
#14 src/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/AbstractService.php(224): XF\ConnectedAccount\Http\Client->retrieveResponse(Object(OAuth\Common\Http\Uri\Uri), Array, Array)
#15 src/XF/Repository/Option.php(229): OAuth\OAuth2\Service\AbstractService->refreshAccessToken(Object(OAuth\OAuth2\Token\StdOAuth2Token))
#16 src/XF/EmailBounce/Processor.php(246): XF\Repository\Option->refreshEmailAccessTokenIfNeeded('emailBounceHand...')
#17 src/XF/SubContainer/Bounce.php(15): XF\EmailBounce\Processor::getDefaultBounceHandlerStorage(Object(XF\Cli\App))
#18 src/XF/Container.php(30): XF\SubContainer\Bounce->XF\SubContainer\{closure}(Object(XF\Container))
#19 src/XF/SubContainer/Bounce.php(43): XF\Container->offsetGet('storage')
#20 src/XF/Job/EmailBounce.php(20): XF\SubContainer\Bounce->storage()
#21 src/XF/Job/Manager.php(260): XF\Job\EmailBounce->run(8)
#22 src/XF/Job/Manager.php(202): XF\Job\Manager->runJobInternal(Array, 8)
#23 src/XF/Job/Manager.php(86): XF\Job\Manager->runJobEntry(Array, 8)
#24 src/XF/Cli/Command/RunJobs.php(59): XF\Job\Manager->runQueue(false, 8)
#25 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))
#26 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))
#27 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))
#28 src/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#29 src/XF/Cli/Runner.php(111): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#30 cmd.php(15): XF\Cli\Runner->run()
#31 {main}

I think we had some sort of network blip, as there were a number of other connection errors logged around the same time.
 
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.8).

Change log:
Fix undefined variable $option when failing to refresh an OAuth email access token.
There may be a delay before changes are rolled out to the XenForo Community.
 
Thanks. This was a simple fix of replacing $option->option_id with just $optionId which is a parameter passed into the method already.

It does, however, as per your second post, indicate a genuine failure with failing to refresh the OAuth access token so you may still want to troubleshoot that.
 
Back
Top Bottom