Attachment Improvements By Xon

Attachment Improvements By Xon 2.6.1

No permission to download
hash should be an alpha-numeric string, not a json array.

This likely shouldn't be causing an LogicException from mal-formed user input.


There is definitely a buggy add-on involved, tempHash has a value in that stack trace but that exception is triggering in the _preSave
PHP:
	public function insertTemporaryAttachment(
		\XF\Attachment\AbstractHandler $handler,
		\XF\Entity\AttachmentData $data,
		$tempHash,
		\XF\FileWrapper $file
	)
	{
		/** @var \XF\Entity\Attachment $attachment */
		$attachment = $this->app->em()->create('XF:Attachment');

		$attachment->data_id = $data->data_id;
		$attachment->content_type = $handler->getContentType();
		$attachment->temp_hash = $tempHash;
		$attachment->save();

		$handler->onNewAttachment($attachment, $file);

		return $attachment;
	}
 
Last edited:
Just wondering if this error is connected to this addon???

Code:
Server error log

    LogicException: Temp hash must be specified if no content is specified. src/XF/Entity/Attachment.php:270

    Generated by: DavidUK Feb 3, 2021 at 12:01 PM

Stack trace

#0 src/XF/Mvc/Entity/Entity.php(1355): XF\Entity\Attachment->_preSave()
#1 src/XF/Mvc/Entity/Entity.php(1208): XF\Mvc\Entity\Entity->preSave()
#2 src/XF/Service/Attachment/Preparer.php(267): XF\Mvc\Entity\Entity->save()
#3 src/XF/Service/Attachment/Preparer.php(29): XF\Service\Attachment\Preparer->insertTemporaryAttachment(Object(SV\AttachmentImprovements\XF\Attachment\Post), Object(SV\AttachmentImprovements\XF\Entity\AttachmentData), '[{"id":"458869-...', Object(XF\FileWrapper))
#4 src/XF/Attachment/Manipulator.php(170): XF\Service\Attachment\Preparer->insertAttachment(Object(SV\AttachmentImprovements\XF\Attachment\Post), Object(XF\FileWrapper), Object(SV\ConversationEssentials\XF\Entity\User), '[{"id":"458869-...')
#5 src/XF/Pub/Controller/Attachment.php(89): XF\Attachment\Manipulator->insertAttachmentFromUpload(Object(XF\Http\Upload), NULL)
#6 src/XF/Mvc/Dispatcher.php(350): XF\Pub\Controller\Attachment->actionUpload(Object(XF\Mvc\ParameterBag))
#7 src/XF/Mvc/Dispatcher.php(257): XF\Mvc\Dispatcher->dispatchClass('XF:Attachment', 'Upload', Object(XF\Mvc\RouteMatch), Object(SV\AttachmentImprovements\XF\Pub\Controller\Attachment), NULL)
#8 src/XF/Mvc/Dispatcher.php(113): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(SV\AttachmentImprovements\XF\Pub\Controller\Attachment), NULL)
#9 src/XF/Mvc/Dispatcher.php(55): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#10 src/XF/App.php(2326): XF\Mvc\Dispatcher->run()
#11 src/XF.php(488): XF\App->run()
#12 index.php(20): XF::runApp('XF\\Pub\\App')
#13 {main}

Request state

array(4) {
  ["url"] => string(131) "/attachments/upload?type=post&context[thread_id]=31023&hash=%5B%7B%22id%22%3A%22458869-0%22%7D%2C%7B%22id%22%3A%22458889-0%22%7D%5D"
  ["referrer"] => string(62) "https://cafesaxophone.com/threads/todays-buy-what-is-it.31023/"
  ["_GET"] => array(3) {
    ["type"] => string(4) "post"
    ["context"] => array(1) {
      ["thread_id"] => string(5) "31023"
    }
    ["hash"] => string(37) "[{"id":"458869-0"},{"id":"458889-0"}]"
  }
  ["_POST"] => array(3) {
    ["_xfToken"] => string(8) "********"
    ["_xfResponseType"] => string(4) "json"
    ["_xfWithData"] => string(1) "1"
  }
I got several of this error logged also.
But I don't have Xons addon installed.

Do you have the addon "Convert Image" from @AndyB installed?
 
Do you have the addon "Convert Image" from @AndyB installed?
No. Probably best not to clog up[ up Xon's dicussion if this is not related to it.

See here, which I think is more relevant: (and check for any unassociated attachments that occurred at the same time)

 
No. Probably best not to clog up[ up Xon's dicussion if this is not related to it.

See here, which I think is more relevant: (and check for any unassociated attachments that occurred at the same time)

What other add-ons do you have installed? I just noticed what appears to be the same server error.
 
Any idea which one it could be, or at what kind of add-on could cause such a conflict?
Do you have any of AndyB's attachment handling add-on's especially ones which auto-attach linked images? I don't have access to those, so I can't easily check them for compatibility issues.
 
Do you have any of AndyB's attachment handling add-on's especially ones which auto-attach linked images? I don't have access to those, so I can't easily check them for compatibility issues.
No. I've been trying to think of which add-on is likely causing the problem, but it's difficult. Especially since the issue can't be reproduced consistently. That particular error only occurred a few times, yet the issue with attachments remaining unassociated is still happening.
 
The server error occurred a few more times when a member who had previously experienced the issue ran into it again.
Code:
LogicException: Temp hash must be specified if no content is specified. src/XF/Entity/Attachment.php:270
Generated by: [member] Feb 10, 2021 at 10:04 AM
Stack trace
#0 src/XF/Mvc/Entity/Entity.php(1355): XF\Entity\Attachment->_preSave()
#1 src/XF/Mvc/Entity/Entity.php(1208): XF\Mvc\Entity\Entity->preSave()
#2 src/XF/Service/Attachment/Preparer.php(267): XF\Mvc\Entity\Entity->save()
#3 src/XF/Service/Attachment/Preparer.php(29): XF\Service\Attachment\Preparer->insertTemporaryAttachment(Object(SV\AttachmentImprovements\XF\Attachment\Post), Object(SV\AttachmentImprovements\XF\Entity\AttachmentData), '[{"id":"2398089...', Object(XF\FileWrapper))
#4 src/XF/Attachment/Manipulator.php(170): XF\Service\Attachment\Preparer->insertAttachment(Object(SV\AttachmentImprovements\XF\Attachment\Post), Object(XF\FileWrapper), Object(SV\BookmarkEssentials\XF\Entity\User), '[{"id":"2398089...')
#5 src/XF/Pub/Controller/Attachment.php(89): XF\Attachment\Manipulator->insertAttachmentFromUpload(Object(XF\Http\Upload), NULL)
#6 src/XF/Mvc/Dispatcher.php(350): XF\Pub\Controller\Attachment->actionUpload(Object(XF\Mvc\ParameterBag))
#7 src/XF/Mvc/Dispatcher.php(257): XF\Mvc\Dispatcher->dispatchClass('XF:Attachment', 'Upload', Object(XF\Mvc\RouteMatch), Object(SV\AttachmentImprovements\XF\Pub\Controller\Attachment), NULL)
#8 src/XF/Mvc/Dispatcher.php(113): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(SV\AttachmentImprovements\XF\Pub\Controller\Attachment), NULL)
#9 src/XF/Mvc/Dispatcher.php(55): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#10 src/XF/App.php(2326): XF\Mvc\Dispatcher->run()
#11 src/XF.php(488): XF\App->run()
#12 index.php(20): XF::runApp('XF\\Pub\\App')
#13 {main}
Request state
array(4) {
  ["url"] => string(137) "/attachments/upload?type=post&context[thread_id]=1443508&hash=%5B%7B%22id%22%3A%2223980893-0%22%7D%2C%7B%22id%22%3A%2223983010-0%22%7D%5D"
  ["referrer"] => string(80) "https://www.[forum].com/threads/issues-uploading-photos.1443508/page-51"
  ["_GET"] => array(4) {
    ["/attachments/upload"] => string(0) ""
    ["type"] => string(4) "post"
    ["context"] => array(1) {
      ["thread_id"] => string(7) "1443508"
    }
    ["hash"] => string(41) "[{"id":"23980893-0"},{"id":"23983010-0"}]"
  }
  ["_POST"] => array(11) {
    ["_xfToken"] => string(8) "********"
    ["_xfResponseType"] => string(4) "json"
    ["_xfWithData"] => string(1) "1"
    ["flowChunkNumber"] => string(1) "1"
    ["flowChunkSize"] => string(10) "4294967296"
    ["flowCurrentChunkSize"] => string(7) "3224103"
    ["flowTotalSize"] => string(7) "3224103"
    ["flowIdentifier"] => string(48) "3224103-80D739B9-2B6A-4D23-B47C-809FDCFEFF1Cjpeg"
    ["flowFilename"] => string(41) "80D739B9-2B6A-4D23-B47C-809FDCFEFF1C.jpeg"
    ["flowRelativePath"] => string(41) "80D739B9-2B6A-4D23-B47C-809FDCFEFF1C.jpeg"
    ["flowTotalChunks"] => string(1) "1"
  }
}
The more recent errors weren't triggered by the same member who last triggered them, but both ran into the issue with attachments failing to associate when the errors were triggered.
 
Can you PM me a list of add-ons? Nothing this add-on does should be causing the hash value to be json!
 
Can you PM me a list of add-ons? Nothing this add-on does should be causing the hash value to be json!
I have listed the addons I'm using in the other thread which is specifically about this error and unassociated attachments, see here


Do you have any of AndyB's attachment handling add-on's especially ones which auto-attach linked images?
Yes, I did have one of andy's which converts media embeds to attachments (you'll see it in my list) , however I only used it briefly and it was disabled by the time I got these errors.
 
Not really. How XF serves attachments is something ClouldFlare don't like too much.
Thanks for reply Xon, in those features i only need one, which is limit attachment count, but can I limit images attachment X files and limit videos attachment Y files ? I mean seperate limit for each type
 
Thanks for reply Xon, in those features i only need one, which is limit attachment count, but can I limit images attachment X files and limit videos attachment Y files ? I mean seperate limit for each type
Can you help me answer that question @Xon , i would really appreciate
 
Thanks for reply Xon, in those features i only need one, which is limit attachment count, but can I limit images attachment X files and limit videos attachment Y files ? I mean seperate limit for each type
Currently the add-on only supports maximum attachment size and count for conversations/posts.
 
  • Like
Reactions: Xon
I think it's now safe to say this is/was a xenforo bug and NOT related to xon's addon


Just wondering if this error is connected to this addon???

Code:
Server error log

    LogicException: Temp hash must be specified if no content is specified. src/XF/Entity/Attachment.php:270

    Generated by: DavidUK Feb 3, 2021 at 12:01 PM

Stack trace

#0 src/XF/Mvc/Entity/Entity.php(1355): XF\Entity\Attachment->_preSave()
#1 src/XF/Mvc/Entity/Entity.php(1208): XF\Mvc\Entity\Entity->preSave()
#2 src/XF/Service/Attachment/Preparer.php(267): XF\Mvc\Entity\Entity->save()
#3 src/XF/Service/Attachment/Preparer.php(29): XF\Service\Attachment\Preparer->insertTemporaryAttachment(Object(SV\AttachmentImprovements\XF\Attachment\Post), Object(SV\AttachmentImprovements\XF\Entity\AttachmentData), '[{"id":"458869-...', Object(XF\FileWrapper))
#4 src/XF/Attachment/Manipulator.php(170): XF\Service\Attachment\Preparer->insertAttachment(Object(SV\AttachmentImprovements\XF\Attachment\Post), Object(XF\FileWrapper), Object(SV\ConversationEssentials\XF\Entity\User), '[{"id":"458869-...')
#5 src/XF/Pub/Controller/Attachment.php(89): XF\Attachment\Manipulator->insertAttachmentFromUpload(Object(XF\Http\Upload), NULL)
#6 src/XF/Mvc/Dispatcher.php(350): XF\Pub\Controller\Attachment->actionUpload(Object(XF\Mvc\ParameterBag))
#7 src/XF/Mvc/Dispatcher.php(257): XF\Mvc\Dispatcher->dispatchClass('XF:Attachment', 'Upload', Object(XF\Mvc\RouteMatch), Object(SV\AttachmentImprovements\XF\Pub\Controller\Attachment), NULL)
#8 src/XF/Mvc/Dispatcher.php(113): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(SV\AttachmentImprovements\XF\Pub\Controller\Attachment), NULL)
#9 src/XF/Mvc/Dispatcher.php(55): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#10 src/XF/App.php(2326): XF\Mvc\Dispatcher->run()
#11 src/XF.php(488): XF\App->run()
#12 index.php(20): XF::runApp('XF\\Pub\\App')
#13 {main}

Request state

array(4) {
  ["url"] => string(131) "/attachments/upload?type=post&context[thread_id]=31023&hash=%5B%7B%22id%22%3A%22458869-0%22%7D%2C%7B%22id%22%3A%22458889-0%22%7D%5D"
  ["referrer"] => string(62) "https://cafesaxophone.com/threads/todays-buy-what-is-it.31023/"
  ["_GET"] => array(3) {
    ["type"] => string(4) "post"
    ["context"] => array(1) {
      ["thread_id"] => string(5) "31023"
    }
    ["hash"] => string(37) "[{"id":"458869-0"},{"id":"458889-0"}]"
  }
  ["_POST"] => array(3) {
    ["_xfToken"] => string(8) "********"
    ["_xfResponseType"] => string(4) "json"
    ["_xfWithData"] => string(1) "1"
  }
 
Hi @Xon,

After upgrading to XF v2.2.4, tapping on embedded SVG images on iOS 14.4.1 fails to trigger the LightBox overlay, while performing the same action on raster images (PNG, JPG, etc.) does open the overlay.
 
Top Bottom