Simple Machines Community Forum

SMF Support => SMF 2.1.x Support => Topic started by: Sir Osis of Liver on May 19, 2022, 06:57:41 PM

Title: Confusing behaviour when embedded attachment is deleted
Post by: Sir Osis of Liver on May 19, 2022, 06:57:41 PM
Quote inserted for context after topic was split
Quote from: Sir Osis of Liver on May 19, 2022, 06:06:01 PMOr you can do this - butt_ss1.png with a tooltip.  ;) 

Quote from: Sesquipedalian on May 19, 2022, 12:27:12 AMAnyone who doesn't like the current behaviour can change it on their own install.
Sure, but we shouldn't have to.

Just as an aside, when I preview this post I get 'Not a valid attachment ID.' instead of the image.  It posted correctly, now it doesn't.

As expected, 2.1 is a mess. :P




Here's what's in the post -


Or you can do this - [attach id=281552]butt_ss1.png[/attach] with a tooltip.


If it wasn't a valid attachment thumb wouldn't work.

Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: FrizzleFried on May 19, 2022, 06:58:11 PM
The tag at can be fixed by changing 281552 to 281554. 

I am not sure why the tag ended up 2 numbers below your image number unless you'd attached an image... then deleted it... then re-uploaded an image and left the original tag?
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Sir Osis of Liver on May 19, 2022, 07:05:08 PM
Didn't post the insert first try, uploaded it several times to try to get it to post correctly. 
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Sesquipedalian on May 19, 2022, 07:50:19 PM
Quote from: Sir Osis of Liver on May 19, 2022, 06:06:01 PM
Quote from: Sesquipedalian on May 19, 2022, 12:27:12 AMAnyone who doesn't like the current behaviour can change it on their own install.
Sure, but we shouldn't have to.

(https://c.tenor.com/rjbF8zqomZMAAAAC/janeway-startrek.gif)

Quote from: Sir Osis of Liver on May 19, 2022, 06:06:01 PMJust as an aside, when I preview this post I get 'Not a valid attachment ID.' instead of the image.  It posted correctly, now it doesn't.

You have the wrong number specified in the id parameter of the attach BBCode. I suspect that you attached a file, inserted the BBCode, accidentally deleted the attachment, and then uploaded a fresh copy of the file. Or perhaps you were working in source view instead of WYSIWYG mode and simply made a typo. Either way, correct the id number in your post, and it'll work just fine.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Sir Osis of Liver on May 19, 2022, 11:53:45 PM
Not a typo, nothing to do with WYSIWYG.  Just trying to attach a png, like any other dumb member, didn't work.  Bad enough it's poorly designed, it's buggy as well.  Not on my computer so can't replicate the glitch, will try tomorrow (if I remember).
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Aleksi "Lex" Kilpinen on May 20, 2022, 12:28:45 AM
Looks like you previewed the post with Attachment id 281552,
but before you actually made the post it ID the attachment eventually had climbed to 281554.
I'm not sure what caused that, but it's worth looking at IMO @Sesquipedalian

EDIT: I was slow and missed the second page completely before posting :P Sorry about that.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Sesquipedalian on May 20, 2022, 12:39:59 AM
Quote from: Aleksi "Lex" Kilpinen on May 20, 2022, 12:28:45 AMbefore you actually made the post it ID the attachment eventually had climbed to 281554.
I'm not sure what caused that, but it's worth looking at IMO @Sesquipedalian

That can't happen. Every attachment, even if it is just a preview that is discarded before the post is submitted, is assigned a unique, permanent ID number. That ID number will never change, no matter how many other attachments might be uploaded before the post is submitted.

Since Sir Osis said that he uploaded copies of the file several times, the only explanation I can see is the scenario that both I and FrizzleFried described:

Quote from: FrizzleFried on May 19, 2022, 06:58:11 PMI am not sure why the tag ended up 2 numbers below your image number unless you'd attached an image... then deleted it... then re-uploaded an image and left the original tag?
Quote from: Sesquipedalian on May 19, 2022, 07:50:19 PMI suspect that you attached a file, inserted the BBCode, accidentally deleted the attachment, and then uploaded a fresh copy of the file.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Sesquipedalian on May 20, 2022, 01:28:25 AM
Thinking more about it, Sir Osis' confusion probably arose because the editor's thumbnail preview does not disappear when an attachment is deleted. We could improve that by adding some JavaScript to remove the attach BBC from the post text in the editor when the attachment is deleted.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: @rjen on May 20, 2022, 01:39:17 AM
This exact same problem is reported to me as well by forum users. It seems to happen more often
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Sesquipedalian on May 20, 2022, 01:46:50 AM
Tracked in #7477 (https://github.com/SimpleMachines/SMF2.1/issues/7477). Fix submitted in #7478 (https://github.com/SimpleMachines/SMF2.1/pull/7478).
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Antechinus on May 20, 2022, 09:02:11 AM
If you're interested, there's a simple CSS tweak which will also immediately hide the deleted ones in the attachments preview:
.dz-complete.errorbox {
display: none;
}

I'm running it on local already, and I'm liking it quite a lot. ;)
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Sir Osis of Liver on May 20, 2022, 12:46:29 PM
IIRC, first attempt to insert the image failed.

It's failed again in preview, first upload, no delete - butt_ss1.png

But as you can see it posted correctly.

Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Sir Osis of Liver on May 20, 2022, 01:06:01 PM
test - butt_ss1.png

Fails every time.  Add file > Upload > Insert > Preview

butt_ss2.png

Posts ok.

Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Sir Osis of Liver on May 20, 2022, 01:19:04 PM
The ui is unecessarily complicated.  There are seven buttons after you've added one file, two more for each additional file.  Uploading should not be a separate step, once added all attachments should upload on post, as in 2.0.  That would greatly simplify things.  It's ridiculous the way it is now.


Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Arantor on May 20, 2022, 01:22:34 PM
There is actually one side point to this method - though certainly not this presentation - that you can theoretically handle attachments that are larger than the server would normally let you upload in one go.

We haven't seen that for a while as a support question - I guess hosts are more lax than they used to be - but there was a time you couldn't upload several files together because it'd be too big for the server to cope with in a single go. Which is what this was *trying* to deal with.

But there are vastly better ways of presenting this.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: FrizzleFried on May 20, 2022, 02:01:14 PM
...and one is being currently worked on in the Mod Requests sub-forum.  :D

https://www.simplemachines.org/community/index.php?topic=582391.0
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Antechinus on May 20, 2022, 04:09:07 PM
Quote from: Arantor on May 20, 2022, 01:22:34 PMThere is actually one side point to this method - though certainly not this presentation - that you can theoretically handle attachments that are larger than the server would normally let you upload in one go.

We haven't seen that for a while as a support question - I guess hosts are more lax than they used to be - but there was a time you couldn't upload several files together because it'd be too big for the server to cope with in a single go. Which is what this was *trying* to deal with.
It's a fair point, and one that may not be relevant to hosts anymore but can still be relevant to connections, especially on mobile. I'm not that fussed about having to have an upload button if the  "Upload all" option is available (and obviously available) for connections that can deal with it.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Arantor on May 20, 2022, 04:14:52 PM
You could still have upload all do it out of band and return the ids for inclusion into the post. It's still bad UX even taking that factor into account and it can and I would argue should be improved.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Antechinus on May 20, 2022, 04:32:12 PM
Ok, I'm fine with improvements.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Sir Osis of Liver on May 20, 2022, 09:02:14 PM
Quote from: Sesquipedalian on May 20, 2022, 01:28:25 AMThinking more about it, Sir Osis' confusion probably arose because the editor's thumbnail preview does not disappear when an attachment is deleted.

I'm not confused, the f@#king thing doesn't work.  Nothing to do with deleting attachement, as posted above, it doesn't work.

Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: FrizzleFried on May 21, 2022, 09:55:47 AM
(1) Upload (just did that)

(2) Insert: 

ScreenHunter 449.jpg

(3) Preview:

ScreenHunter 474.jpg

(4) OP is 100% correct.  This behavior is not correct.   
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Antechinus on May 21, 2022, 06:04:06 PM
I have no idea what you mean. All I see is two inline attachments in this post, and a screenshot of the editor. Try using more words. :P

ETA: Oh hang on, the error box in the preview shot. Got it.

Funnily enough, I had an error with the attachments system on a local test site the other night. I have not yet tried to replicate it, because honestly I think the only way of replicating it would be by repeatedly adding and removing attachment until it randomly happens again, and that could take ages. However...

I was testing adding and removing attachments (tweaking presentation) and I uploaded a new attachment, inserted it into the test post by clicking the insert button, and after saving the post I was presented with the "No message is associated with this attachment" message inside the post.

So, I go back into the editor to check it out, and I find that the attachment was inserted with its ID number off by 1. Note that this cannot possibly be a manual editing error, because the insertion was done via the insert button. So. it was handled directly by the SMF back end with no possibility for human error.

Despite this, it still came up with "ID + 1" for the value it inserted into the post.

Obvious question: is Ant hallucinating? Not unless Arantor is too, because I mentioned this to him via PM and he said he has occasionally seen the same error. Nothing in the error log either, before anyone asks.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Sir Osis of Liver on May 21, 2022, 11:16:30 PM
Nothing occasional about it, happens every time -

bushwick.jpg


Add file > upload > insert > preview



Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Antechinus on May 21, 2022, 11:29:30 PM
I didn't preview though. I just uploaded, inserted, and saved. So, different issue.

ETA: Just tried doing a test your way on local. No problem. Preview works as it should. Saved post is fine. So, not an "all the time" issue for everyone.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Sir Osis of Liver on May 21, 2022, 11:39:17 PM
It's an attachment id error, that shouldn't be client side.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: FrizzleFried on May 21, 2022, 11:40:52 PM
Oddly... while this issue is 100% repeatable HERE for me.  Every time.  I have ZERO issue with the same exact procedure on both my sandbox and main sites...

So I can't explain it unless it's a permissions issue as I obviously don't have admin access here.  Maybe when I have a little time I'll test as a user on my sites.

Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Antechinus on May 21, 2022, 11:43:08 PM
Ok, hang on a sec and I'll try it here.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Antechinus on May 21, 2022, 11:44:17 PM
black-opal.jpg

Yup. Confirmed. Immediate hit here. FIrefox on W10.

But, it only affects the preview. The submitted post is fine.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: FrizzleFried on May 21, 2022, 11:45:18 PM
FWIW ... I just tried a USER account at my main site and in both WYSIWYG and TEXT MODE editors using the exact procedure above that I have the same result as OP here with... I have no issues at all on my local site.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: FrizzleFried on May 21, 2022, 11:46:12 PM
Quote from: Antechinus on May 21, 2022, 11:44:17 PMblack-opal.jpg

Yup. Confirmed. Immediate hit here. FIrefox on W10.

But, it only affects the preview. The submitted post is fine.

Correct... exact same behavior I experience here ... but on Chrome.  I do NOT experience this same behavior on either of my local sites using either editor it seems.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Sir Osis of Liver on May 21, 2022, 11:46:21 PM
Confirmed, doesn't happen on 2.1 test install, only here.

Running a later version here?
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: FrizzleFried on May 21, 2022, 11:47:31 PM
Oh,  I should mention that my sandbox site is 2.1.2 and main site is 2.1.1 so it's not a version thing.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Sir Osis of Liver on May 21, 2022, 11:48:42 PM
Test install is 2.1.2.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Oldiesmann on May 22, 2022, 01:27:01 PM
I was able to reproduce the problem on my test board. Running the latest code from GitHub, PHP 8.1.6, MariaDB 10.3.34, APCu caching. Interesting how it shows just fine in WYSIWYG mode but not when I preview it.

Screenshot_20220522_132334.png
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Sesquipedalian on May 24, 2022, 11:54:08 AM
Okay, to summarize, this bug occurs consistently for people on this site, but not on their own sites and test installs, except for Oldiesmann. Is that correct, everyone?

@Oldiesmann:


@Sir Osis of Liver: When I said "confusion" I was not trying to deny that you were seeing what you were seeing. It was simply that the only way I could reproduce the same output on my test install was to delete and reattach a file, and because the editor's thumbnail preview was not deleted when I performed those steps—which is indeed confusing to anyone—I supposed that this confusing behaviour of the UI was the source of the problem.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Oldiesmann on May 24, 2022, 05:06:05 PM
Quote from: Sesquipedalian on May 24, 2022, 11:54:08 AMOkay, to summarize, this bug occurs consistently for people on this site, but not on their own sites and test installs, except for Oldiesmann. Is that correct, everyone?

@Oldiesmann:

  • In that screenshot, the BBCode string in the attachment info box says the attachment ID number is 6. Is 6 really the correct ID number for the attachment, or should it have been 4 or 5 or something else?
  • Do you see any difference in behaviour if the editor is in WYSIWYG mode vs. source mode when you click the INSERT button and then generate the preview?
  • Am I correct to assume that the test forum has no mods installed?

6 is the correct ID for that attachment. 7 is the thumbnail for that one.
No difference between the two modes
No mods installed at the moment. It has had mods installed at other times though.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Sir Osis of Liver on May 24, 2022, 05:11:50 PM
Works correctly on clean 2.1.2 install from current upgrade package.  Doesn't work here.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: shawnb61 on June 05, 2022, 01:47:45 AM
Quote from: Sir Osis of Liver on May 24, 2022, 05:11:50 PMWorks correctly on clean 2.1.2 install from current upgrade package.  Doesn't work here.

Yep.  That's exactly why some (like me... ::)) couldn't reproduce.  The issues were primarily in current GitHub, and this site is often closer to current GH than 2.1.2. 

PR submitted: https://github.com/SimpleMachines/SMF/pull/7497
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: shawnb61 on June 05, 2022, 01:27:35 PM
The upload/insert/preview issue should be addressed on this site.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Sir Osis of Liver on June 05, 2022, 02:50:53 PM
Fixed. :)
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Arantor on June 05, 2022, 02:53:40 PM
Uh... is it? See attached.

That attachment produces a 404 when clicked, but it's still in the attachments table.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Arantor on June 05, 2022, 03:18:23 PM
Hm, seems like it might be fixed now, now I see an image and it's not 404ing.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Sir Osis of Liver on June 05, 2022, 03:21:16 PM
Server glitch?  Works for me.  Original problem was only in preview, posting was normal.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Steve on June 06, 2022, 06:48:02 AM
So this topic is solved? I can't keep up with you coders.  :P
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Sir Osis of Liver on June 06, 2022, 12:58:01 PM
The preview problem seems to be fixed, but Arantor may have found another glitch.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Arantor on June 06, 2022, 02:31:14 PM
There was definitely a glitch when it was announced as fixed on here - I think there may be some residual issues with old attachments vs the mod site, but I have no solid feelings on what causes what yet.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Arantor on June 07, 2022, 08:22:56 AM
I am still seeing glitches, e.g. in https://www.simplemachines.org/community/index.php?msg=4127833 there is an attachment, it has a thumbnail, but opening the full size attachment gets a 404.

And the image is attempting to embed inside the post - and failing also with a 404.

Something isn't right here.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: FrizzleFried on June 07, 2022, 09:08:37 AM
Quote from: Arantor on June 07, 2022, 08:22:56 AMI am still seeing glitches, e.g. in https://www.simplemachines.org/community/index.php?msg=4127833 there is an attachment, it has a thumbnail, but opening the full size attachment gets a 404.

And the image is attempting to embed inside the post - and failing also with a 404.

Something isn't right here.

What is strange is that I see that post fine.  The behavior seems to be a DELAY between when the post is made and when the image actually appears for folks.  I saw that happen in "real time" with an attachment earlier (and commented about it as did others).

The attachment didn't show for me... for minutes... then all of a sudden... it did.

Here is what I see at the link above:

ScreenHunter 500.jpg
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Arantor on June 07, 2022, 09:12:19 AM
Weird, it's there now for me too. Which really doesn't make sense, because 10 minutes after it was definitely 404ing for me and offhand I can't fathom why that would happen, not even related to background tasks happening.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: FrizzleFried on June 07, 2022, 09:19:27 AM
When I saw it in real-time... a post was made a minute or two before I saw exactly what you saw.  I fuddled around for a couple minutes hard refreshing, etc... but it would not come up.  So I posted about it.  Someone else posted they saw the same thing... then... a few minutes later... there it was... for both of us.

Let me see if I can find the post/response.


EDIT: Here it is - https://www.simplemachines.org/community/index.php?msg=4126787

Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: shawnb61 on June 08, 2022, 08:59:35 PM
We believe the occasional 404s on this site have been addressed.
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: Sir Osis of Liver on June 08, 2022, 09:56:25 PM
What was causing it?
Title: Re: Confusing behaviour when embedded attachment is deleted
Post by: shawnb61 on June 08, 2022, 10:16:26 PM
Site/server side stuff.  Over my head, tbh.

The mod site was impacted as well.  But all appears to be good now.