Duplicate \Unexpected Autolink/unfurl failing

Xon

Well-known member
Affected version
2.1.3
When posting https://signatureeditiongames.com/search?type=product&q=frostpunk on a just upgraded site, the URL fails weirdly;

PHP:
ErrorException: [E_NOTICE] Trying to get property 'url' of non-object
src/XF/BbCode/ProcessorAction/AutoLink.php:434

#0 src/XF/BbCode/ProcessorAction/AutoLink.php(434): XF::handlePhpError(8, '[E_NOTICE] Tryi...', '/var/www/html/u...', 434, Array)
#1 src/XF/BbCode/ProcessorAction/AutoLink.php(425): XF\BbCode\ProcessorAction\AutoLink->getUnfurlBbCode('https://signatu...')
#2 src/XF/BbCode/ProcessorAction/AutoLink.php(143): XF\BbCode\ProcessorAction\AutoLink->unfurlLinkUrl('https://signatu...')
#3 [internal function]: XF\BbCode\ProcessorAction\AutoLink->XF\BbCode\ProcessorAction\{closure}(Array)
#4 src/XF/BbCode/ProcessorAction/AutoLink.php(140): preg_replace_callback('#^(?<=[^a-z0-9@...', Object(Closure), 'https://signatu...')
#5 [internal function]: XF\BbCode\ProcessorAction\AutoLink->filterString('https://signatu...', Array, Object(XF\BbCode\Processor))
#6 src/XF/BbCode/Processor.php(375): call_user_func(Array, 'https://signatu...', Array, Object(XF\BbCode\Processor))
#7 src/XF/BbCode/Processor.php(358): XF\BbCode\Processor->filterString('https://signatu...', Array)
#8 src/XF/BbCode/Traverser.php(65): XF\BbCode\Processor->renderString('https://signatu...', Array)
#9 src/XF/BbCode/Traverser.php(37): XF\BbCode\Traverser->renderSubTree(Array, Array)
#10 src/XF/BbCode/Traverser.php(20): XF\BbCode\Traverser->renderAst(Array, Object(SV\AdvancedBbCodesPack\XF\BbCode\RuleSet), Array)
#11 src/XF/Service/Message/Preparer.php(157): XF\BbCode\Traverser->render('https://signatu...', Object(SV\AdvancedBbCodesPack\XF\BbCode\Parser), Object(SV\AdvancedBbCodesPack\XF\BbCode\RuleSet), Array)
#12 src/XF/Service/Message/Preparer.php(122): XF\Service\Message\Preparer->processMessage('https://signatu...')
#13 src/addons/SV/AdvancedBbCodesPack/XF/Service/Message/Preparer.php(29): XF\Service\Message\Preparer->prepare('https://signatu...', true)
#14 src/XF/Service/Post/Preparer.php(98): SV\AdvancedBbCodesPack\XF\Service\Message\Preparer->prepare('https://signatu...', true)
#15 src/XF/Service/Thread/Replier.php(107): XF\Service\Post\Preparer->setMessage('https://signatu...', true, true)
#16 src/XF/Pub/Controller/Thread.php(318): XF\Service\Thread\Replier->setMessage('https://signatu...')
#17 src/addons/SV/Threadmarks/XF/Pub/Controller/Thread.php(155): XF\Pub\Controller\Thread->setupThreadReply(Object(SV\ElasticSearchEssentials\XF\Entity\Thread))
#18 src/XF/Pub/Controller/Thread.php(560): SV\Threadmarks\XF\Pub\Controller\Thread->setupThreadReply(Object(SV\ElasticSearchEssentials\XF\Entity\Thread))
#19 src/XF/Mvc/Dispatcher.php(321): XF\Pub\Controller\Thread->actionReplyPreview(Object(XF\Mvc\ParameterBag))
#20 src/XF/Mvc/Dispatcher.php(244): XF\Mvc\Dispatcher->dispatchClass('XF:Thread', 'ReplyPreview', Object(XF\Mvc\RouteMatch), Object(SV\ElasticSearchEssentials\XF\Pub\Controller\Thread), NULL)
#21 src/XF/Mvc/Dispatcher.php(100): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(SV\ElasticSearchEssentials\XF\Pub\Controller\Thread), NULL)
#22 src/XF/Mvc/Dispatcher.php(50): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#23 src/XF/App.php(2178): XF\Mvc\Dispatcher->run()
#24 src/XF.php(390): XF\App->run()
#25 index.php(20): XF::runApp('XF\\Pub\\App')
#26 {main}

Relevant code (no add-on extends it);
PHP:
protected function getUnfurlBbCode($url)
{
   /** @var \XF\Repository\Unfurl $unfurlRepo */
   $unfurlRepo = $this->app->repository('XF:Unfurl');
   $result = $unfurlRepo->logPendingUnfurl($url);

   return '[URL unfurl="true"]' . $result->url . '[/URL]';
}
There doesn't appear to be any need for $result->url to be used vs $url, and doesn't even need to fetch the entry if it exists

The row;
Code:
select * from xf_unfurl_result where url like '%signatureeditiongames%';
+-----------+-------------------------------------------------------------------+----------------------------------+-------+-------------+-----------+-------------+-------------------+---------+-------------+
| result_id | url                                                               | url_hash                         | title | description | image_url | favicon_url | last_request_date | pending | error_count |
+-----------+-------------------------------------------------------------------+----------------------------------+-------+-------------+-----------+-------------+-------------------+---------+-------------+
|     81644 | https://signatureeditiongames.com/search?type=product&q=frostpunk | 9ad0ba39a1e0308eea3c02b4f839608e | NULL  | NULL        | NULL      | NULL        |                 0 |       1 |           0 |
+-----------+-------------------------------------------------------------------+----------------------------------+-------+-------------+-----------+-------------+-------------------+---------+-------------+

Deleting the row, and then hitting preview and it works, row contents after;
Code:
select * from xf_unfurl_result where url like '%signatureeditiongames%';
+-----------+-------------------------------------------------------------------+----------------------------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+--------------------------------------------------------------------------------------------------------------------------+-------------------+---------+-------------+
| result_id | url                                                               | url_hash                         | title     | description                                                                                                                                                           | image_url | favicon_url                                                                                                              | last_request_date | pending | error_count |
+-----------+-------------------------------------------------------------------+----------------------------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+--------------------------------------------------------------------------------------------------------------------------+-------------------+---------+-------------+
|     81678 | https://signatureeditiongames.com/search?type=product&q=frostpunk | 9ad0ba39a1e0308eea3c02b4f839608e | frostpunk | Collectors' editions of great indie games. Signature Editions contain a region-free version of the game plus a host of additional content that are super collectable. |           | https://cdn.shopify.com/s/files/1/1366/2939/files/Untitled-2_981db483-9ee0-4b27-8e9b-f54ea61556b4_32x32.png?v=1554807140 |        1565704667 |       0 |           0 |
+-----------+-------------------------------------------------------------------+----------------------------------+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+--------------------------------------------------------------------------------------------------------------------------+-------------------+---------+-------------+
 
Actually; This might be the result of the MySQL master/slave setup with the slave being behind. But I wouldn't expect the fetch to be hitting the slave :(
 
The error you got is actually the same as this bug you reported previously (which is still open):

Could this be the same cause?
 
I thought this client was using a master/slave setup; but it looks like they decommissioned the slaves atm so that linked bug sounds like the cause.
 
Top Bottom