'Send thanks' button fails on Flow thanks page: "The postid parameter must be set"
Closed, ResolvedPublic

Description

Steps to reproduce:

  1. Open browser on mobile device.
  2. Browse to https://m.mediawiki.org/wiki/Project:Support_desk
  3. Make sure you are logged in
  4. Scroll down to any 'Thank' link, and tap 'Thank'.
  5. On next screen, tap 'Send thanks' button.
  6. Receive:
The postid parameter must be set.

Johnywhy created this task.Apr 4 2018, 4:38 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 4 2018, 4:38 PM
Johnywhy updated the task description. (Show Details)Apr 4 2018, 4:38 PM
Johnywhy updated the task description. (Show Details)
Aklapper renamed this task from Bug? 'Thank' Fails on Mobile Project:Support_desk to 'Send thanks' button fails on mobile mw:Project:Support_desk: "The postid parameter must be set".Apr 5 2018, 3:13 PM
Aklapper updated the task description. (Show Details)
Restricted Application added a project: Collaboration-Team-Triage. · View Herald TranscriptApr 5 2018, 3:13 PM
Johnywhy added a comment.EditedApr 5 2018, 4:18 PM

i received a thank this a.m. from @Aklapper over there. Was that a test?

Indicator: That's a separate topic - please file a separate task if no tasks exists already.

Confirmed in betalabs (Thank action from Flow boards) - can be successfully reproduced on desktop mobile. No errors in the Console.

Note: the issue does not exist in Minerva.

This error can be reproduced on desktop view, our Chinese Wikipedia community has noticed this issue.
Steps to reproduce:
Go to any Flow thanks page (Other types of thanks seem to have no problem) E.g. https://www.mediawiki.org/wiki/Special:Thanks/Flow/uancdwmnjy7nvs4y

RazeSoldier renamed this task from 'Send thanks' button fails on mobile mw:Project:Support_desk: "The postid parameter must be set" to 'Send thanks' button fails on Flow thanks page: "The postid parameter must be set".Apr 30 2018, 1:30 PM
Aklapper edited projects, added Mobile; removed goodfirstbug.
Aklapper added a subscriber: Jdlrobson.
Aklapper added a subscriber: jmatazzoni.

@jmatazzoni: goodfirstbug tasks are issues with a clear approach and should be well-described with pointers to help the new contributor. Given the current short task description I'm removing the goodfirstbug tag. Please re-add the tag once the task description has been polished and provides sufficient information for a new contributor. Thanks!

Jdlrobson updated the task description. (Show Details)May 8 2018, 2:03 PM
Niedzielski moved this task from Needs triage to Triaged on the Mobile board.May 9 2018, 12:55 PM
Mh-3110 claimed this task.Aug 13 2018, 12:09 AM
Restricted Application added a project: Growth-Team. · View Herald TranscriptAug 13 2018, 12:09 AM
Catrope moved this task from Inbox to To Triage on the Growth-Team board.Aug 20 2018, 10:58 PM

Hi,
will start working on this.
Thanks

JTannerWMF moved this task from To Triage to External on the Growth-Team board.Aug 23 2018, 12:23 PM

will start working on this.

@Mh-3110: How is it going? Do you need any help with something?

Mh-3110 added a comment.EditedSep 17 2018, 2:40 PM

will start working on this.

@Mh-3110: How is it going? Do you need any help with something?

Hi @Aklapper ,
Now really start working on it. Will let you know if any help needed.
Thanks so much

[off-topic] @Mh-3110: Please do not put a ">>" at the beginning of lines when these lines are not quoted text that was originally written by somebody else. It is super confusing. See https://phabricator.wikimedia.org/T191442#4589122 in your browser. Thanks.

[off-topic] @Mh-3110: Please do not put a ">>" at the beginning of lines when these lines are not quoted text that was originally written by somebody else. It is super confusing. See https://phabricator.wikimedia.org/T191442#4589122 in your browser. Thanks.

Hi @Aklapper, my mistake. Sorry for that.

Change 461189 had a related patch set uploaded (by Mh-3110; owner: Mahuton):
[mediawiki/extensions/Thanks@master] 'Send thanks' fails on Flow thanks page

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

@SBisson ,
Following my comment on gerrit, please find attached the screenshot.

I can notice that when user clicks on the thanks link on Flow page this opens a new tab what is not the expected behavior since there is a preventDefault() call on it.

jrbs added a subscriber: jrbs.Sep 27 2018, 6:04 PM

@Mh-3110: Please avoid full-quotes of previous comments, and please don't quote previous comments without adding anything on your own. Thanks.

@Mh-3110 I encourage you to continue your work on this. It's certainly an issue worth fixing and I'll do what I can to support you.

From previous comments, keep in mind that $().on() is not deprecated. The reason is it used is to capture events from topics that are added via infinite scrolling after the initial page load.

@SBisson, I do really appreciate your motivating comment.
From my first look, here are notices:
1-On click on the 'Thank' link, it follows the Url even though there is a preventDefault() called on it.
2-When the 'Thank' link doesn't follow the URL (preventDefault() is working), then 'Send thank' succeeds. No error message. But it follows the link and open a new tab then 'Send thank' fails with the error message : "The postid parameter must be set"
3-It is a little bit weird as this is working fine in my local environment (Vagrant) but not in production.
I'm still investigating and I will surely let you if I have any question.
Thanks so much

@SBisson, I do really appreciate your motivating comment.
From my first look, here are notices:
1-On click on the 'Thank' link, it follows the Url even though there is a preventDefault() called on it.
2-When the 'Thank' link doesn't follow the URL (preventDefault() is working), then 'Send thank' succeeds. No error message. But it follows the link and open a new tab then 'Send thank' fails with the error message : "The postid parameter must be set"

It's common for a link like that to follow the URL when any error occurs in the javascript handler.

You probably know this but just in case: you can add debugger; at the beginning of the event handler to start debugging with chrome as soon as you click the link. If there's an error, that would help you find it.

3-It is a little bit weird as this is working fine in my local environment (Vagrant) but not in production.

From the screenshot it looks like this is happening with the mobile site. Make sure you use it in you local environment with the 'mobilefrontend' vagrant role and by putting your browser in mobile mode (in chrome: second button in the top-left corner of the devtools panel).

I'm still investigating and I will surely let you if I have any question.

Don't hesitate!

Thanks @SBisson ,
I think I will open a new ticket to track the e.preventDefault() issue.
When focusing on the main issue we're tracking here in this ticket, I can notice that the below function is trying to get the flow post id from with a wrong param $data[revid]. There is no input in the submit form with the attribute name = revid. Then correcting it to $data[id] to get the correct flow post id fixes the issue.

/**
	 * Call the API internally.
	 * @param string[] $data The form data.
	 * @return Status
	 */
	public function onSubmit( array $data ) {
		if ( !isset( $data['id'] ) ) {
			return Status::newFatal( 'thanks-error-invalidrevision' );
		}

		if ( in_array( $this->type, [ 'rev', 'log' ] ) ) {
			$requestData = [
				'action' => 'thank',
				$this->type => (int)$data['id'],
				'source' => 'specialpage',
				'token' => $this->getUser()->getEditToken(),
			];
		} else {
			$requestData = [
				'action' => 'flowthank',
				'postid' => $data['revid'],
				'token' => $this->getUser()->getEditToken(),
			];
		}

		$request = new DerivativeRequest(
			$this->getRequest(),
			$requestData,
			true // posted
		);

		$api = new ApiMain(
			$request,
			true // enable write mode
		);

		try {
			$api->execute();
		} catch ( ApiUsageException $e ) {
			return Status::wrap( $e->getStatusValue() );
		}

		$this->result = $api->getResult()->getResultData( [ 'result' ] );
		return Status::newGood();
	}

Change 461189 merged by jenkins-bot:
[mediawiki/extensions/Thanks@master] Fix postid parameter on Flow thanks page

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

Is this task solved ? If yes, good job @Mh-3110 :)

Looks like not solved.

@Framawiki , this task is resolved. Thanks.
@RazeSoldier, can you comment more details why you say it is not resolved?
Note that this fix is not yet deployed in production.
Thanks

Mh-3110 closed this task as Resolved.Oct 28 2018, 2:17 PM

@RazeSoldier, can you comment more details why you say it is not resolved?
Note that this fix is not yet deployed in production.

I reproduce this problem in MediaWiki.org, I thought it was deployed to production. :)

Trizek-WMF reopened this task as Open.Oct 29 2018, 10:02 AM
Trizek-WMF added a subscriber: Trizek-WMF.

Let's wait for QA's review before resolving that task. :)

Etonkovidova closed this task as Resolved.Oct 29 2018, 10:28 PM

Checked in betalabs - looks good (added to the list of tasks to check in wmf.2)

.

@SBisson ,
Thank you so much for your support on this!