ElkArte Community

Elk Development => Bug Reports => Exterminated Bugs => Topic started by: Jorin on November 24, 2017, 06:15:30 am

Title: editing a post
Post by: Jorin on November 24, 2017, 06:15:30 am
Everytime I try to edit one of my own posts here at elkarte.net in the custom theme board an error occurs:

QuoteInvalid argument supplied for foreach()

...and I can't make any changes.
Title: Re: editing a post
Post by: emanuele on November 24, 2017, 06:26:08 am
hmm.... let me check the errors log
Title: Re: editing a post
Post by: emanuele on November 24, 2017, 06:27:55 am
Try now, the specific one should be fixed.
Title: Re: editing a post
Post by: Jorin on November 24, 2017, 06:35:28 am
Yep, but what happened with my attachments? They seem to be gone after I saved my changes.  :o

https://www.elkarte.net/community/index.php?topic=4773.0
Title: Re: editing a post
Post by: emanuele on November 24, 2017, 06:42:49 am
I thought I fixed that one yesterday...
The attachments are there, just it is a bit messy with all the stuff regarding thumbnails and not.
Title: Re: editing a post
Post by: Jorin on November 24, 2017, 06:43:15 am
Okay, how can I fix my post?  O:-)
Title: Attachments not working
Post by: emanuele on November 24, 2017, 07:17:49 am
(Link-5215) test
Title: Re: editing a post
Post by: emanuele on November 24, 2017, 07:20:23 am
Sorry, I have to debug it better and now I'm at work, I'll check this evening...
Title: Re: Attachments not working
Post by: Jorin on November 24, 2017, 07:40:31 am
That's an old attachment never attached to this topic.  :o  But as it's only a test...  O:-)
Title: Re: editing a post
Post by: Jorin on November 24, 2017, 07:40:57 am
No problem!
Title: Re: Attachments not working
Post by: Spuds on November 24, 2017, 10:52:45 am
Any idea what happened to the attachments?
Title: Re: Attachments not working
Post by: emanuele on November 24, 2017, 03:19:52 pm
Would you mind attaching them to a new post here?
Do not use the inline function, just plain attachment.
Title: Re: editing a post
Post by: emanuele on November 24, 2017, 03:40:39 pm
Test not in line
Title: Re: editing a post
Post by: emanuele on November 24, 2017, 03:41:27 pm
Test inline
(Link-5226)
that is it

try to edit
full modify
Title: Re: Attachments not working
Post by: emanuele on November 24, 2017, 04:03:58 pm
@Spuds I got it now: it was just yet another bug I introduced trying to fix the attachments... :-\

@Jorin now it really works, I have to say sorry, but the attachments are gone... :'(
The problem was I wrote a function that was assuming the $_SESSION data for the attachments was there, but in fact there was no session data because $_SESSION is used only when uploading a post, no during the editing.

/me feels attachments is another piece of code that will benefit in 2.0 from a general overhaul and simplification, because at the moment is kind of totally messed (including the counter-intuitive $_POST['attach_del'])
Title: Re: Attachments not working
Post by: Jorin on November 24, 2017, 04:40:37 pm
Quote from: emanuele – Would you mind attaching them to a new post here?
Do not use the inline function, just plain attachment.

No problem.
Title: Re: Attachments not working
Post by: Jorin on November 24, 2017, 04:41:08 pm
Quote from: emanuele – @Jorin now it really works, I have to say sorry, but the attachments are gone... :'(

I attached them a second time, no problem.
Title: Re: Attachments not working
Post by: Jorin on November 24, 2017, 04:41:50 pm
Maybe we can move the posts about the attachment problem to the bug report board?
Title: Re: editing a post
Post by: Jorin on November 28, 2017, 07:09:43 am
Changed the post a last time and the old (second) attachment ist missing again after saving changes.  :'(

https://www.elkarte.net/community/index.php?topic=4773.0
Title: Re: editing a post
Post by: emanuele on November 28, 2017, 07:20:53 am
So you:
1) created a post with an attachment,
2) edited the post adding an attachment,
3) the second one was not saved?
Or did you edit it two times?
Title: Re: editing a post
Post by: Jorin on November 28, 2017, 07:55:33 am
1. I created a post with two inline attachments.
2. I edited the post, deleted one attachment and attached another instead. The second, not changed attachment disappears after saving the changes.
3. After you tried to understand what happened (successful I hope  ;)  ) I edited the post, deleted both old attachments, attached two new ones. This worked.

4. Today I wanted to change one of the attachments again, repeated step 2 from above. Same result: The old attachment disappeared.

I can delete both attachments and upload both again, that will help for the moment. But it seems to be still a bug.
Title: Re: editing a post
Post by: emanuele on November 28, 2017, 08:09:47 am
meh... I guess it's again the backward logic for deleting attachments that is affecting the result. :-\
Title: Re: editing a post
Post by: Jorin on November 28, 2017, 08:21:40 am
Quote from: Jorin – I can delete both attachments and upload both again, ...

Can I?

Edit: I fixed the post. It is strange:

Whenever I edit a post (no matter which), the attachments disappear from the attachment list under the editor. When I save my changes, the attach BBC is still within the post, but the attachments aren't linked with the post any more so they can't be shown. I have to edit the post again, delete the BBC inside it, attach new images and set new BBCodes for them.
Title: Re: editing a post
Post by: emanuele on November 28, 2017, 10:39:23 am
meh...
Bug indeed, I'll have to see WTF is going on... ::)

Probably after dinner though.
Title: Re: editing a post
Post by: emanuele on November 29, 2017, 04:03:45 am
xD
Title: Re: editing a post
Post by: emanuele on November 29, 2017, 02:13:49 pm
Image 1, Death: (Link-5281) <= removed

Image 2, Orange-kun: (Link-5283)

Image 3, bouncing parrot: (Link-5284)
Title: Re: editing a post
Post by: emanuele on November 29, 2017, 02:23:29 pm
Now it looks correct.

It's official: I hate attachments. I'll lobby to remove them from 2.0. LOL
Title: Re: editing a post
Post by: ahrasis on November 30, 2017, 04:04:47 am
Why not? If files / images can already be display via other ways that is. :P
Title: Re: editing a post
Post by: Jorin on November 30, 2017, 04:41:06 am
Would it be possible to "attach" them the same way as a link to a website inside a post?

If I would use ElkArte 2.0.0 right now, I would love to attach a file with the bbc [file][/file]. When I click the editor bbc button for this, I should be asked for the file on my computer, ElkArte should upload it onto the server and create the bbc for me. The file should then appear inside my post automatically where the code is when I publish my post.

To remove the file I would edit the post, remove the code. When I save the change, ElkArte should look for the file and remove it from the server.
Title: Re: editing a post
Post by: emanuele on December 02, 2017, 05:23:20 pm
I think @Spuds posted somewhere wondering about the preview not showing the attachments, not they are there again! :D
Title: Re: editing a post
Post by: Spuds on December 02, 2017, 06:40:28 pm
Quote from: emanuele – I think @Spuds posted somewhere wondering about the preview not showing the attachments, not they are there again! :D
Lets (Link-5285) test :D

Woot ... it works again !!
Title: Re: editing a post
Post by: emanuele on December 03, 2017, 05:02:37 am
YAY! :D

BTW, really, attachments are a P.I.T.A. the way are now...
Title: Re: editing a post
Post by: radu81 on December 03, 2017, 05:29:14 am
Quote from: emanuele – attachments are a P.I.T.A. the way are now...
but the preview seems to work fine here ;) Don't touch it anymore  ;D :D
It was asked several times on my forum why preview of  attachments inserted with ILA addon is not working?
Title: Re: editing a post
Post by: badmonkey on December 03, 2017, 08:29:15 am
Quote from: emanuele – Now it looks correct.

It's official: I hate attachments. I'll lobby to remove them from 2.0. LOL


Certainly hope you are joking!  Lol! My forums are pic heavy with tech related stuffs. I really don't want to migrate again either...lol
Title: Re: editing a post
Post by: Spuds on December 03, 2017, 08:41:38 am
Yeah he is just kidding  :D   Its a natural reaction once you look at the attachment code for to long LOL
Title: Re: editing a post
Post by: emanuele on December 03, 2017, 09:03:48 am
You know this feeling when you see all red? Then you go in front of a mirror and you see your face covered in blood coming out from your eyes?
That's what you get looking at the attachments code for more than 1 minute! xD
Title: Re: editing a post
Post by: badmonkey on December 03, 2017, 09:33:37 am
Quote from: Spuds – Yeah he is just kidding  :D  Its a natural reaction once you look at the attachment code for to long LOL

Yes, and figured that the case. All the same, there is a tiny bit of panic on the other side of the screen in the context of "what if". ;D