Partial fix Template error: number_format()

AT8500

Member
Affected version
2.0
Hi,
Sorry if I am posting this in wrong subforum but today I got server this server error message:

ErrorException: Template error: number_format() expects parameter 1 to be float, string given src/XF/Language.php:881


Code:
#0 [internal function]: XF\Template\Templater->handleTemplateError(2, 'number_format()...', '/home/admin/web...', 881, Array)
#1 src/XF/Language.php(881): number_format('', 0, '.', ',')
#2 src/XF/Template/Templater.php(3404): XF\Language->fileSizeFormat('')
#3 [internal function]: XF\Template\Templater->filterFileSize(Object(XF\Template\Templater), '', true)
#4 src/XF/Template/Templater.php(829): call_user_func_array(Array, Array)
#5 internal_data/code_cache/templates/l2/s1/public/attachment_macros.php(38): XF\Template\Templater->filter('', Array, true)
#6 src/XF/Template/Templater.php(643): XF\Template\Templater->{closure}(Object(XF\Template\Templater), Array, Array)
#7 internal_data/code_cache/templates/l2/s1/public/message_macros.php(224): XF\Template\Templater->callMacro('attachment_macr...', 'attachment_list...', Array, Array)
#8 src/XF/Template/Templater.php(643): XF\Template\Templater->{closure}(Object(XF\Template\Templater), Array, Array)
#9 internal_data/code_cache/templates/l2/s1/public/post_macros.php(149): XF\Template\Templater->callMacro('message_macros', 'attachments', Array, Array)
#10 src/XF/Template/Templater.php(643): XF\Template\Templater->{closure}(Object(XF\Template\Templater), Array, Array)
#11 internal_data/code_cache/templates/l2/s1/public/thread_view.php(516): XF\Template\Templater->callMacro('post_macros', 'post', Array, Array)
#12 src/XF/Template/Templater.php(1230): XF\Template\Templater->{closure}(Object(XF\Template\Templater), Array)
#13 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('thread_view', Array)
#14 src/XF/Mvc/Renderer/Html.php(48): XF\Template\Template->render()
#15 src/XF/Mvc/Dispatcher.php(332): XF\Mvc\Renderer\Html->renderView('XF:Thread\\View', 'public:thread_v...', Array)
#16 src/XF/Mvc/Dispatcher.php(303): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#17 src/XF/Mvc/Dispatcher.php(44): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#18 src/XF/App.php(1879): XF\Mvc\Dispatcher->run()
#19 src/XF.php(328): XF\App->run()
#20 index.php(13): XF::runApp('XF\\Pub\\App')
#21 {main}
 
Same here...
  • ErrorException: Template error: number_format() expects parameter 1 to be float, string given
  • src/XF/Language.php:881
 
I can fix this error, though the problem ultimately appears to be an attachment that is orphaned. Other issues may come from this. We have that attachment record but not the data record. There's no reason for this to happen aside from an add-on. You can run this query to identify the attachments:
Code:
SELECT a.*
FROM xf_attachment AS a
LEFT JOIN xf_attachment_data AS d ON (a.data_id = d.data_id)
WHERE d.data_id IS NULL;
You will likely need to identify the specific content they're associated with (via content_type/content_id) and remove the attachments manually from that content (such as by editing the post).

If you have ever used an add-on that does things with attachments (such as converting things to attachments), that is quite likely the cause. You may want to notify the author.
 
That wouldn't be a related issue and it wouldn't cause the particular problem that triggered this. This is specifically where attachment data is missing. (That's also a very specific bug that is actually more about the conversation not being removed.)
 
Top Bottom