SMF 2.0 Deleting attachment from post doesn't revert clip icon [WITH FIX]

Started by rawlogic, August 19, 2011, 05:50:28 PM

Previous topic - Next topic

rawlogic

This is a new install without mods.

When adding an attachment to a post, and the user hasn't selected a custom icon for the post (standard icon), SMF will set the icon to the clip icon.

This is done on line 1859 of Post.php:
$_POST['icon'] = !empty($attachIDs) && $_POST['icon'] == 'xx' ? 'clip' : $_POST['icon'];

However, if you modify the post to delete the attachment, the icon is not reverted back to the standard icon. This leads the readers to believe that there is an attachment, even though there isn't. Note that you can't normally select the clip icon if there is no attachment.

I've added the following lines after 1859 to revert the icon back if the attachment is deleted:

// Revert clip icon to standard icon if no attachment (attachment may have been removed) - MdA
if (empty($attachIDs) && $_POST['icon'] == 'clip') {
$_POST['icon'] = 'xx';
}

Douglas

Why are you installing and testing this on RC5 when 2.0 Final has been out for a couple months?

Please test this on a 2.0 FINAL version installation and then report back accordingly.

Thanks!
Doug Hazard
* Full Stack (Web) Developer for The Catholic Diocese of Richmond
(20+ Diocesan sites, 130+ Church sites & 24 School sites)
* Sports Photographer and Media Personality
* CFB Historian
* Tech Admin for one 1M+ post, one 2M+ post and one 10M+ post sites (last two are powered by multiple servers)
* WordPress Developer (Junkie / Guru / Maven / whatever)

emanuele

I'm quite sure the behaviour is the same. And I think it applies to attachments pruning as well.

Is it a bug? Don't know.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

rawlogic

Quote from: Douglas on August 19, 2011, 09:19:02 PM
Why are you installing and testing this on RC5 when 2.0 Final has been out for a couple months?

Please test this on a 2.0 FINAL version installation and then report back accordingly.
This is using the latest 2.0 "Full Install". I thought it said RC5, but apparently the version is unknown. It's just the one that's available for download as the full install with the filename smf_2-0_install.zip. I've updated the subject accordingly. Thanks.

Douglas

Thanks for the clarification; that's definitely the Gold version. :)
Doug Hazard
* Full Stack (Web) Developer for The Catholic Diocese of Richmond
(20+ Diocesan sites, 130+ Church sites & 24 School sites)
* Sports Photographer and Media Personality
* CFB Historian
* Tech Admin for one 1M+ post, one 2M+ post and one 10M+ post sites (last two are powered by multiple servers)
* WordPress Developer (Junkie / Guru / Maven / whatever)

Illori


Joker™

Seems to be a bug to me

An untested fix :P (Make backup before testing it)


Sources/Post.php
Code (Find:) Select
$_POST['icon'] = !empty($attachIDs) && $_POST['icon'] == 'xx' ? 'clip' : $_POST['icon'];

Code (Replace it with:) Select
$_POST['icon'] = !empty($attachIDs) ? 'clip' : (($_POST['icon'] == 'clip') ? 'xx' : $_POST['icon']);
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

emanuele



Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Arantor

Is this a bug? No. It is quite intentional that it should do this, so that there is an icon to indicate attachments, which will propagate up to the topic listing, thus indicating there are attachments in the first post.

I'm not sure exactly whether this should be fixed though... but I'm inclined to go with the above fix that pushes the icon back to being 'xx' if there's no attachments.


Advertisement: