XF 2.2 help with error: Argument #1 ($url) must be of type string, null given, called in

Mr Lucky

Well-known member
Please can someone tell me what this error means?
Code:
TypeError: XF\Util\Url::urlToUtf8(): Argument #1 ($url) must be of type string, null given, called in /home/caf/public_html/xf2.cafesaxophone.com/src/XF/BbCode/ProcessorAction/AutoLink.php on line 430 in src/XF/Util/Url.php at line 50
[LIST=1]
[*]XF\Util\Url::urlToUtf8() in src/XF/BbCode/ProcessorAction/AutoLink.php at line 430
[*]XF\BbCode\ProcessorAction\AutoLink->unfurlLinkUrl() insrc/XF/BbCode/ProcessorAction/AutoLink.php at line 149
[*]XF\BbCode\ProcessorAction\AutoLink->XF\BbCode\ProcessorAction\{closure}()
[*]preg_replace_callback() in src/XF/BbCode/ProcessorAction/AutoLink.php at line 146
[*]XF\BbCode\ProcessorAction\AutoLink->filterString() in src/XF/BbCode/Processor.php at line 377
[*]XF\BbCode\Processor->filterString() in src/XF/BbCode/Processor.php at line 360
[*]XF\BbCode\Processor->renderString() in src/XF/BbCode/Traverser.php at line 67
[*]XF\BbCode\Traverser->renderSubTree() in src/XF/BbCode/Traverser.php at line 39
[*]XF\BbCode\Traverser->renderAst() in src/XF/BbCode/Traverser.php at line 22
[*]XF\BbCode\Traverser->render() in src/XF/Service/Message/Preparer.php at line 164
[*]XF\Service\Message\Preparer->processMessage() in src/XF/Service/Message/Preparer.php at line 129
[*]XF\Service\Message\Preparer->prepare() in src/XF/Service/Post/Preparer.php at line 98
[*]XF\Service\Post\Preparer->setMessage() in src/XF/Service/Thread/Replier.php at line 114
[*]XF\Service\Thread\Replier->setMessage() in src/XF/Pub/Controller/Thread.php at line 441
[*]XF\Pub\Controller\Thread->setupThreadReply() in src/XF/Pub/Controller/Thread.php at line 590
[*]XF\Pub\Controller\Thread->actionAddReply() in src/XF/Mvc/Dispatcher.php at line 352
[*]XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 259
[*]XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 115
[*]XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 57
[*]XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2487
[*]XF\App->run() in src/XF.php at line 524
[*]XF::runApp() in index.php at line 20
[/LIST]

EDIT: sorry I pasted the wrong one, I meant paste the error as it appears when no addons are enabled

It was caused by trying to publish a post with a specific link to another thread.

While troubleshooting I disabled addons, tried default style.

I found however that it was fine to post the same link in other threads.

This was the link https://cafesaxophone.com/threads/student-choosing-the-teacher%E2%80%99s-method.34810/ and I found if I removed the apostrophe %E2%80%99 then the link was fine but did not unfurl, however I believe that the apostrophe in a thread title link should not cause an error.

Just tested again today and it posted fine, with the apostrophe and also unfurled.

So I am puzzled as to why this happened, seemingly random.

Can anyone shed any light on this, thanks./
 
Last edited:
You have at least one add-on listed in that stack trace UserMentionsImprovements. Try updating it to the latest version and see if the issue remains. If so, then disable that add-on and see if the issue presents itself. If not, then contact the developer in either his add-on thread or directly.
 
Please can someone tell me what this error means?
Code:
TypeError: XF\Util\Url::urlToUtf8(): Argument #1 ($url) must be of type string, null given, called in /home/caf/public_html/src/XF/BbCode/ProcessorAction/AutoLink.php on line 430 src/XF/Util/Url.php:50
Generated by: Pete Thomas Jul 8, 2023 at 9:43 AM
Stack trace
#0 src/XF/BbCode/ProcessorAction/AutoLink.php(430): XF\Util\Url::urlToUtf8(NULL, false)
#1 src/XF/BbCode/ProcessorAction/AutoLink.php(149): XF\BbCode\ProcessorAction\AutoLink->unfurlLinkUrl('https://cafesax...')
#2 [internal function]: XF\BbCode\ProcessorAction\AutoLink->XF\BbCode\ProcessorAction\{closure}(Array)
#3 src/XF/BbCode/ProcessorAction/AutoLink.php(146): preg_replace_callback('#^(?<=[^a-z0-9@...', Object(Closure), '

As this seems...')
#4 src/XF/BbCode/Processor.php(377): XF\BbCode\ProcessorAction\AutoLink->filterString('

As this seems...', Array, Object(XF\BbCode\Processor))
#5 src/XF/BbCode/Processor.php(360): XF\BbCode\Processor->filterString('

As this seems...', Array)
#6 src/XF/BbCode/Traverser.php(67): XF\BbCode\Processor->renderString('

As this seems...', Array)
#7 src/XF/BbCode/Traverser.php(39): XF\BbCode\Traverser->renderSubTree(Array, Array)
#8 src/XF/BbCode/Traverser.php(22): XF\BbCode\Traverser->renderAst(Array, Object(SV\UserMentionsImprovements\XF\BbCode\RuleSet), Array)
#9 src/XF/Service/Message/Preparer.php(164): XF\BbCode\Traverser->render('[QUOTE="eb424, ...', Object(XF\BbCode\Parser), Object(SV\UserMentionsImprovements\XF\BbCode\RuleSet), Array)
#10 src/XF/Service/Message/Preparer.php(129): XF\Service\Message\Preparer->processMessage('[QUOTE="eb424, ...')
#11 src/addons/SV/UserMentionsImprovements/XF/Service/Message/Preparer.php(37): XF\Service\Message\Preparer->prepare('[QUOTE="eb424, ...', true)
#12 src/XF/Service/Post/Preparer.php(98): SV\UserMentionsImprovements\XF\Service\Message\Preparer->prepare('[QUOTE="eb424, ...', true)
#13 src/addons/SV/UserMentionsImprovements/XF/Service/Post/Preparer.php(26): XF\Service\Post\Preparer->setMessage('[QUOTE="eb424, ...', true, true)
#14 src/XF/Service/Thread/Replier.php(114): SV\UserMentionsImprovements\XF\Service\Post\Preparer->setMessage('[QUOTE="eb424, ...', true, true)
#15 src/XF/Pub/Controller/Thread.php(441): XF\Service\Thread\Replier->setMessage('[QUOTE="eb424, ...')
#16 src/XF/Pub/Controller/Thread.php(590): XF\Pub\Controller\Thread->setupThreadReply(Object(SV\SearchImprovements\XF\Entity\ThreadCollab))
#17 src/XF/Mvc/Dispatcher.php(352): XF\Pub\Controller\Thread->actionAddReply(Object(XF\Mvc\ParameterBag))
#18 src/XF/Mvc/Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('XF:Thread', 'AddReply', Object(XF\Mvc\RouteMatch), Object(SV\UserEssentials\XF\Pub\Controller\Thread), NULL)
#19 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(SV\UserEssentials\XF\Pub\Controller\Thread), NULL)
#20 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#21 src/XF/App.php(2487): XF\Mvc\Dispatcher->run()
#22 src/XF.php(524): XF\App->run()
#23 index.php(20): XF::runApp('XF\\Pub\\App')
#24 {main}
Request state
array(4) {
  ["url"] => string(47) "/threads/like-lefty-always-late.34800/add-reply"
  ["referrer"] => string(69) "https://cafesaxophone.com/threads/like-lefty-always-late.34800/page-2"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(10) {
    ["_xfToken"] => string(8) "********"
    ["message"] => string(309) "[QUOTE="eb424, post: 514678, member: 6243"]
If I'm paying for their time surely I should take my agenda out of the lessons.
[/QUOTE]

As this seems a possibly very interesting topic I started a new thread to discuss here:

https://cafesaxophone.com/threads/student-choosing-the-teacher’s-method.34810/"
    ["attachment_hash"] => string(32) "687d4439ef6fc8bd1a990f74bfe14211"
    ["attachment_hash_combined"] => string(87) "{"type":"post","context":{"thread_id":34800},"hash":"687d4439ef6fc8bd1a990f74bfe14211"}"
    ["last_date"] => string(10) "1688802977"
    ["last_known_date"] => string(10) "1688802977"
    ["load_extra"] => string(1) "1"
    ["_xfRequestUri"] => string(44) "/threads/like-lefty-always-late.34800/page-2"
    ["_xfWithData"] => string(1) "1"
    ["_xfResponseType"] => string(4) "json"
  }
}

Well actually it was caused by trying to publish a post with a specific link to another thread.

While troubleshooting I disabled addons, tried default style.

I found however that it was fine to post the same link in other threads.

This was the link https://cafesaxophone.com/threads/student-choosing-the-teacher%E2%80%99s-method.34810/ and I found if I raved the apostrophe %E2%80%99 then the link was fine but did not unfurl, however I believe that the apostrophe in a thread title link should not cause an error.

Just tested again today and it posted fine, with the apostrophe and also unfurled.

So I am puzzled as to why this happened, seemingly random.

Can anyone shed any light on this, thanks./

Try applying the patch files provided here.
 

Try applying the patch files provided here.
Many thanks!

Unfortunately I can't tell if it's fixed as the error is not always reproducible.
 
Many thanks!

Unfortunately I can't tell if it's fixed as the error is not always reproducible.
If you have updated to the latest version it is "supposed" to be fixed.. if you continue to have the same type errors, then I'd suggest updating the "bug report" post or starting a new one.
As mentioned earlier.. there is an add-on that is included in that stack trace...so that developer needs to be brought into the discussion.
 
Back
Top Bottom