News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Attachments not uploading on boardless posting page

Started by davo88, May 02, 2024, 08:19:11 PM

Previous topic - Next topic

davo88

SMF 2.1.4
Default theme
No code edits
No imported data
Mods - Quick New Topic Button

Need a bit of help to troubleshoot an attachment loading problem when using the Quick New Topic Button. This is a stock standard SMF with no mods apart from the QNT button.
Logged in as admin, attachments load, display as thumbnails and post as normal.

Logged in as a member:
- one attachment will load (green bar completes), but not display as a thumbnail or attach to the post when the message is posted.

You cannot view this attachment.

- can load one attachment to the point where the green bar is complete, but not displaying as a thumbnail, then repeat the process and load a second, then a third to the same point. Looks like this

You cannot view this attachment.

But if I try to save that post, the attachments aren't attaching.

However, if I first post a text only message without any attachments, then choose Modify and attach an image, the attachment loads, displays as a thumbnail and is attached after saving - all as normal.

You cannot view this attachment.

I have tried different attachments, all well under the current limits set in Attachments settings.
Not sure how to go about troubleshooting this problem. Any suggestions appreciated.

Sesquipedalian

Your issues are not due to this mod, which simply adds a link in the menu to take the user to the post authoring page. What happens on the post authoring page is all controlled by SMF itself.

You should ask for help in the general support board for SMF 2.1.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

davo88

I forgot to mention that, when logged in as a member, the attaching process works normally when the post authoring page is opened via the normal 'New Topic' button within the forum. However when accessed via the Quick New Topic button, and attempting to attach the same file, it doesn't.

It looks like I have not set some permissions properly but I can't figure out what they might be.

davo88

Another observation. Logged in as a member and making a post via the 'Reply' button - attachments load (green bar completes), thumbnail displays and attachment is displayed when the post is saved. The attaching process seems to work normally whether for one or multiple attachments.

davo88

Some information from the browser console.
This was taken when logged in as a member, posting window is opened via the Quick New Topic button, one attachment as loaded, the green bar had completed its travel but no thumbnail was displayed. Not sure if this is relevant.

You cannot view this attachment.

Another browser console snip from a different test site under same attaching conditions.

You cannot view this attachment.

Sesquipedalian

#5
As I said, this is an SMF issue, not an issue with the Quick New Topic Button mod.

If you don't believe me, uninstall the mod and then go to index.php?action=post in your browser's address bar. You will see the exact same posting page, complete with the board selection menu. Then try making your post with attachments again. I guarantee that you will still encounter the same issue that you described above.

In fact, you can verify this right here on this site. Go to https://www.simplemachines.org/community/index.php?action=post and try to upload an attachment. You will see the same thing happen. It's a bug in SMF itself.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Sesquipedalian

I have split and moved this bug report to the Bug Reports board, because the issue is a bug in SMF itself, as can be confirmed by following the link in my previous reply.

I suspect that a permissions issue is at work here, but it will take more investigation to find out.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

davo88

Quote from: Sesquipedalian on May 03, 2024, 05:27:28 PMIf you don't believe me, uninstall the mod and then go to index.php?action=post in your browser's address bar. You will see the exact same posting page, complete with the board selection menu. Then try making your post with attachments again.
Yes, tested this and the same thing happens.

shawnb61

I recently saw this as well.

I believe the problem in my case was the pics were so big (in terms of height vs width in pixels) the thumbnail generation was failing.

I regenerated my pix with smaller dimensions and it all worked.

So the thumbnail info that comes back to dropzone is broken, causing that dz console error.   No further js processing.

No idea why I only started seeing this recently.  I upload pix all the time.  (Browser update???)


(So in my case the issue was picture specific, not user specific.  Possibly browser specific.  If you look at the values it's trying to read in the console debugger, it's not an array as expected, it's html for a little web page that says memory exhausted....)
A question worth asking is born in experience & driven by necessity. - Fripp

davo88

Bit more information.

When logged in as admin, this appears in the console at the point where I click "Click or drag files here to attach them" before I have even selected a file to attach. Yet after selecting a file, it uploads, displays a thumbnail and posts OK.

You cannot view this attachment.

When logged in as member, this appears in the console after the file has been selected, has uploaded to the point where the green bar completes, but is unable to display a thumbnail.

You cannot view this attachment.

shawnb61

An update on this...  I am not seeing this issue anymore.  Thumbnails are fine & dz doesn't freeze.

For me, this issue went away as mysteriously as it appeared.

Note: I double-checked, & my FF has been updated, and also the point release of php on my server was updated by my host, both within the last week.  The php release notes for the new version indicate multiple fixes for memory issues & also a bug fix related to image type detection in gd. 

A question worth asking is born in experience & driven by necessity. - Fripp

davo88

Quote from: shawnb61 on May 07, 2024, 10:37:38 PM... the point release of php on my server was updated by my host
Could you tell me what release of PHP is now running please? I'd like to try it out.

shawnb61

A question worth asking is born in experience & driven by necessity. - Fripp

davo88

My cPanel only lists 8.0, 8.1, 8.2, 8.3. Tried 8.2 but get this error:
Connection Problems
Sorry, SMF was unable to connect to the database. This may be caused by the server being busy. Please try again later.

With 8.3, that error doesn't occur and no change with the original problem - thumbnails don't display and attachments don't attach when logged in as a member. But everything works OK when logged in as admin.

shawnb61

I would not use 8.3 - there are known issues with the session handler which was changed a bit in php 8.3.
https://github.com/SimpleMachines/SMF/issues/7793

I suggest figuring out what is wrong with your 8.1/8.2 config.  First making sure that mysqli extension is loaded, etc.
A question worth asking is born in experience & driven by necessity. - Fripp

davo88

Quote from: shawnb61 on May 08, 2024, 03:31:01 PMFirst making sure that mysqli extension is loaded, etc.

Thanks shawnb61. That was the problem. 8.2.18 now working. Updated all three browsers and tested the problem again.  But no change in the attaching result.

Firefox - 125.0.3 (64-bit)
Brave - Version 1.65.130 Chromium: 124.0.6367.159 (Official Build) (64-bit)
Chrome - Version 124.0.6367.156 (Official Build) (64-bit)

Maybe we are talking about different attaching issues?

shawnb61

#16
I'm pretty sure it was the same issue.  The behavior and original screenshots matched.  Most of the console errors matched.

(The only console error that did not match was the draft autosave one - I never saw that.)

What are the dimensions of the pictures in question?

Anything in the apache error logs?

What is your php memory limit?

ONE MORE QUESTION:  Do you have "Adaptive Thumbnail Memory" checked under attachment settings?

I can fairly easily reproduce this (~similar) if (a) I have a very low php memory limit and (b) "Adaptive Thumbnail Memory" is unchecked and (c) my image has large dimensions - 8000x6000....
You cannot view this attachment.You cannot view this attachment.
A question worth asking is born in experience & driven by necessity. - Fripp

davo88

What are the dimensions of the pictures in question? - 800 x 600
Anything in the apache error logs? - Yes
You cannot view this attachment.
What is your php memory limit? - 1024M
post_max_size - 128M
upload_max_filesize - 64M

ONE MORE QUESTION:  Do you have "Adaptive Thumbnail Memory" checked under attachment settings? - Yes

shawnb61

Ah - first thing I'd ask your host is to disable mod security.

Also, what version of gd do you have?
A question worth asking is born in experience & driven by necessity. - Fripp

davo88

The host seemed reluctant to disable Modsecurity completely. Maybe it affects all accounts on the server. Anyway, he did find one rule that was being triggered (ID 77317957) and disabled that. I then did another test and there were no errors in the Apache log this time. Just did a second test and no errors again.

Quote from: shawnb61Also, what version of gd do you have?

GD headers Version - 2.33
GD library Version - 2.33

Quote from: shawnb61I'm pretty sure it was the same issue.  The behavior and original screenshots matched.  Most of the console errors matched.

Are you testing when logged in as a regular member? It works fine here when logged in as admin. The problem only exists when logged in as a regular member.

shawnb61

Quote from: davo88 on May 09, 2024, 04:15:30 AMAnyway, he did find one rule that was being triggered (ID 77317957) and disabled that. I then did another test and there were no errors in the Apache log this time. Just did a second test and no errors again.

Is the issue resolved?
A question worth asking is born in experience & driven by necessity. - Fripp

davo88


shawnb61

Does the error happen any time a user attempts to post with an attachment, e.g., when replying to an existing topic?

Or does it only fail when using the quick New Topic button?
A question worth asking is born in experience & driven by necessity. - Fripp

shawnb61

#23
@Sesquipedalian - I believe we are dealing with two different underlying issues here, that produce the same mode of failure. 

The first is a general memory problem, which I saw on my forum and that can be seen here on SMF.  Certain combinations of ~low-ish memory, attachment settings, & attachment dimensions will cause failure upon thumbnail generation.  I believe even certain point releases of php are more sensitive than others.  The response back to the browser is actually a 'memory exhausted' error, which of course cannot be parsed for filenames, mime types, etc.  Enabling Adaptive Thumbnail Memory usually fixes this.  (If you haven't yet, I'd try it here on SMF...)

The second, I believe, is an issue with Quick New Topic Button.  I cannot get QNTB to post when a user posts an attachment via the New Topic button.  At issue, I think, is this line:
https://github.com/SimpleMachines/SMF/blob/7a757ab13e42ac20f88e9b30b807fd857defdec8/Sources/Attachments.php#L121

allowedTo() always returns true for admins, which is why it always works for admins.  But when an end user gets here via QNTB, there is no board yet, so $this->_board is NULL and allowedTo() returns false.

For both issues, since the attachment could not be created, the response is either incomplete or missing, so it cannot be parsed by .js.  Different browsers fail with slightly different messages, even on different lines in the console.  Further confusing is that FF, for me, yields the exact same console messages for the two different errors above...


I think we will see more of these given the extremely high resolution of current smartphone cameras.  A while back, I'd have occasional issues when posting uncropped pics from my full-frame Nikon.  But even my current cheapie Android pic dimensions far exceed my full-frame DSLR... 
A question worth asking is born in experience & driven by necessity. - Fripp

davo88

Quote from: shawnb61Does the error happen any time a user attempts to post with an attachment, e.g., when replying to an existing topic?
No, everything works fine for regular members when starting a new topic via the regular New Topic button within a forum, or via the Reply button.

Quote from: shawnb61Or does it only fail when using the quick New Topic button?
Yes. Either the QNTB or the command shown by Sesquipedalian in post #5 above '... index.php?action=post'.


Sesquipedalian

As explained above, it's not due to QNTB. That mod merely makes SMF's boardless posting page more discoverable. The problem is with the boardless posting page itself.

Aside from that qualification, I agree entirely with your diagnosis, @shawnb61.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

davo88

Quote from: shawnb61 on May 09, 2024, 08:06:39 PMAt issue, I think, is this line:
https://github.com/SimpleMachines/SMF/blob/7a757ab13e42ac20f88e9b30b807fd857defdec8/Sources/Attachments.php#L121

allowedTo() always returns true for admins, which is why it always works for admins.  But when an end user gets here via QNTB, there is no board yet, so $this->_board is NULL and allowedTo() returns false.

For both issues, since the attachment could not be created, the response is either incomplete or missing, so it cannot be parsed by .js.
So if all boards and all members are allowed to post attachments, is there any small code edit we can do, so that allowedTo() returns true and the attachment process completes OK?

shawnb61

A bug fix is needed in 2.1.x.

It is all setup to work properly, it's just that the requested board isn't passed.  That needs to be fixed.  Securely.
A question worth asking is born in experience & driven by necessity. - Fripp

Arantor

Hypothetical: if you start a new topic today in board 1 where you already have permission, perform the uploads so that they're already on the server, then edit the form in the inspector to change the board id, what happens?

This is really the same scenario you actually face with the editor, that the point at which attachment permissions are checked for the board you're 'on' is not the same as the one potentially being checked when you submit the post.

In 2.0 they get garbage collected if not attached to anything but in 2.1 I think there's something more complex going on because they must somehow get attachment ids to be able to embed which means they must end up in the attachments table, meaning it could be possible today to bypass the permissions if there is a board you can post attachments to, even if it's not the one you're creating a new post in.

I don't have the brainpower to investigate this fully (work sucks), but I think there is already a deeper problem on hand than the board-less posting page just pretending you don't have proper permissions.
Holder of controversial views, all of which my own.


Sesquipedalian

Quote from: Arantor on May 14, 2024, 09:14:31 PMmeaning it could be possible today to bypass the permissions if there is a board you can post attachments to, even if it's not the one you're creating a new post in.


It's not. The permissions are checked again at submit, and if attachments are not allowed, they are removed then.

What is needed on the boardless posting page is a way to dynamically enable or disable the attachments UI depending on which board the user chooses in the select menu.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Advertisement: