Page MenuHomePhabricator

discussiontoolsedit API adds redundant signature when adding a topic with a lede section on an empty page
Closed, ResolvedPublicFeature

Description

Feature summary (what you would like to be able to do and where):

  • discussiontoolsedit API should have the option noautosignature
  • defaults to false
  • when set to true, prevents discussiontools from auto adding a signature

Use case(s) (list the steps that you performed to discover that problem, and describe the actual underlying problem which you want to solve. Do not describe only a solution):

  • prevent over-signing. for example here or here
  • i chose to use the discussiontoolsedit API instead of the edit API in the examples above because discussiontoolsedit makes it easy to subscribe to the section. but the third signature is undesirable
  • there are many repos where I plan to convert the edit API to the discussiontoolsedit API so that I can give users the option of auto subscribing, including AFC helper script, Twinkle, and PageTriage (T329346)

Benefits (why should this be implemented?):

Event Timeline

The option should not be needed when the API is working correctly – it's supposed to be able to detect existing signatures, and not add an unnecessary one. The question is why it's not accepting the signature in your examples. The code for that is here, unfortunately it's a bit complex under the hood: https://codesearch.wmcloud.org/search/?q=isSingleCommentSignedBy

(The check for signatures uses the same algorithm as all the other code in DiscussionTools, e.g. for inserting replies in the right place, so if there was such an option, that would allow adding messages using the discussiontoolsedit API that can't be correctly replied to using the discussiontoolsedit API, and I think that would be bad.)

I think in my examples, we are subst-ing two self-signing templates, which would explain why DiscussionTools can't detect the signatures.

If you're disinclined to have me write a patch to add noautosignature to the discussiontoolsedit API, perhaps I can get consensus to just remove the signatures from the templates. Let me work on that.

I think in my examples, we are subst-ing two self-signing templates, which would explain why DiscussionTools can't detect the signatures.

Even so, it should work, I wrote this feature specifically to support cases like this – see the tasks tagged on rEDTO0ecc8a4c051d: Improve detecting already signed comments, specifically T291421 mentions substitution and T282983 signatures inside wrapper templates.

Your edits have a HTML comment, a line break, and a category at the end; which is a bit weird, but even that should still be supported.

I tested by posting {{subst:Wikipedia:Teahouse/AfC Invitation|sign=~~~~}} through the normal interface, and I didn't get an extra signature: https://en.wikipedia.org/w/index.php?title=User_talk:Matma_Rex&diff=prev&oldid=1220608587

It could be helpful if you could share more details about the API requests you're sending.

Sounds like DiscussionTools can detect the wikitext of subst'd templates? That's pretty cool.

OK, I fiddled around with this and the steps to reproduce is something like...

  • make sure the target page doesn't exist yet
  • run this API query:
action: discussiontoolsedit
format: json
paction: addtopic
page: User talk:NovemBot
sectiontitle: 
wikitext: {{Talk header}}

== Your submission at [[Wikipedia:Articles for creation|Articles for creation]]: [[Draft:Sandbox|Sandbox]] ({{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}}) ==
{{subst:Afc decline|full=Draft:Sandbox|cv=no|reason=v|details=|reason2=bio|details2=|comment=|sig=yes}}

{{subst:Wikipedia:Teahouse/AFC invitation|sign=~~~~}}
summary: Notification: Your [[Draft:Sandbox|Articles for Creation submission]] has been declined ([[WP:AFCH|AFCH]])
autosubscribe: yes
token: [redacted for privacy]

I guess that {{Talk header}} is throwing it off

edit: Confirmed. It doesn't double signature when I remove the {{Talk header}}. I may take {{Talk header}} out of the gadget code.

You’re basically adding two comments in two topics, one of which is unsigned (the talk header). The PHPDoc in rEDTO includes/CommentUtils.php:729-735 (at 1130ab2491fa8bbfcb8113fbc0a35cd1725a9356) starts with Assuming that the thread item set contains exactly one comment (or multiple comments with identical signatures […]) – this assumption doesn’t hold. Maybe it would work if you signed the talk header, but of course signing a talk header doesn’t make any sense.

Duh, I've somehow overlooked the {{Talk header}} in both of your examples. I've never expected this API to be used this way. Now that I've seen it, I think the API needs to only look at the end of the added comments, and ignore whatever is going on at the beginning, since the only thing it really cares about is a functioning "Reply" button at the end.

(It would be nice if we could prevent you from accidentally adding unsigned comments by doing weird things with headings, but that seems difficult to do without breaking your use case, and it's probably not worth the effort to do it anyway, since users of the reply tool probably won't try that, and users of the API can be trusted to know what they're doing.)

matmarex renamed this task from discussiontoolsedit API should have the option noautosignature to discussiontoolsedit API adds redundant signature when adding a topic with a lede section on an empty page.Apr 25 2024, 9:09 PM

Change #1024512 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/DiscussionTools@master] Fix signature check not to look at the content of previous section

https://gerrit.wikimedia.org/r/1024512

Awesome. Thanks for writing a patch for my unusual use case. Feel free to add reviewers to the patch if needed.

Change #1024512 merged by jenkins-bot:

[mediawiki/extensions/DiscussionTools@master] Fix signature check not to look at the content of previous section

https://gerrit.wikimedia.org/r/1024512