Skip to content

[3.0] Stop the posting form repeating two ids - #9458

Open
albertlast wants to merge 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/post-duplicate-ids
Open

[3.0] Stop the posting form repeating two ids#9458
albertlast wants to merge 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/post-duplicate-ids

Conversation

@albertlast

Copy link
Copy Markdown
Collaborator

Description

Two ids on the posting form are emitted more than once per document.

post_modify is on the quote button of every previous post shown below the reply box:

<li id="post_modify"><a href="#postmodify" onclick="return insertQuoteFast(', $post['id'], ');">

That loop runs once per post, so replying to a topic with any history serves the id several times over — and $newPostsHTML, the template the page uses to append posts that arrived while you were typing, carries the same id, so each new arrival adds another. Nothing looks it up; the only thing that names it is one stylesheet rule, #post_modify { border-radius: 4px }, and a rule does not need an id. It becomes .post_modify, and the rule follows it.

attachment1 is on both file inputs in the attachments area. One belongs to the plain UI and one is the drop zone's fallback, and only one of them is ever shown: smf_fileUpload.js removes #postAttachment outright when it initialises, and when it does not run the fallback stays hidden inside #attachment_previews. The fallback is the one looked up by id — cleanFileInput('attachment1'), the clear link sitting next to it — so the plain one gives up its copy and keeps its name, which is all the server reads.

How this was tested

On a local 3.0 install, against ?action=post;topic=1.0 and ?action=post;board=1.0:

  • Counting every id in the served document: post_modify ×2 and attachment1 ×2 before, no repeated id at all after.
  • Every .quickbuttons > li on the reply page measured before and after — position, size, all four border radii, background and display are identical, so the id-to-class swap changes nothing on screen. The attachments area's box is unchanged too.
  • With scripts disabled, the plain file input is still the visible one and the fallback still measures 0×0, as before.

Issues References (Fixes|Related|Closes)

Related: #7933

The reply form gives every previous post's quote button the same
id="post_modify", so a reply to a topic with any history serves a
document with that id several times over, and the ajax that appends
newly arrived posts adds one more each time. It is only ever reached by
a stylesheet, and a stylesheet does not need an id, so it becomes a
class and the one rule that names it follows.

The attachments area repeats id="attachment1" as well. It draws two
file inputs, one for the plain UI and one as the drop zone's fallback,
and only ever shows one of them: the plain block is removed by
smf_fileUpload.js when the script runs, and the fallback sits inside a
container the stylesheet hides until it does. Only the fallback is
looked up by id, by the clear link beside it, so the other one gives up
its copy.

Signed-off-by: Mathias Albert <mathiaspapealbert@hotmail.com>
Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
@jdarwood007 jdarwood007 added this to the 3.0 Alpha 5 milestone Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants