Page MenuHomePhabricator

'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.

Screenshot_20180507-131432_Chrome.jpg (2×1 px, 233 KB)

Event Timeline

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)

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.

Image-1.jpg (1×640 px, 92 KB)

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 good first task.
Aklapper added a subscriber: Jdlrobson.
Aklapper added a subscriber: jmatazzoni.

@jmatazzoni: good first task 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 good first task tag. Please re-add the tag once the task description has been polished and provides sufficient information for a new contributor. Thanks!

Hi,
will start working on this.
Thanks

will start working on this.

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

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.

deprecated.PNG (296×1 px, 38 KB)

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.

@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 :)

@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

@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 subscribed.

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

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

IMG_6297.PNG (1×640 px, 70 KB)
.

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