Skip to content

Notepad dashboard widget method changed to POST#469

Merged
rinatkhaziev merged 2 commits intoAutomattic:masterfrom
TheCrowned:fix/466-notepad-widget-post-form
Jun 14, 2018
Merged

Notepad dashboard widget method changed to POST#469
rinatkhaziev merged 2 commits intoAutomattic:masterfrom
TheCrowned:fix/466-notepad-widget-post-form

Conversation

@TheCrowned
Copy link
Copy Markdown
Contributor

Form method changed to POST and function handle_notepad_update() updated accordingly.
Fixes #466.

Copy link
Copy Markdown
Contributor

@sboisvert sboisvert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case when I first saw the change from GET to POST I wondered why that would work (since REQUEST is frowned upon) https://vip.wordpress.com/documentation/code-review-what-we-look-for/#using-_request

In the PR we should mention the answer to any expected questions or things that feel strange. Changing a form without changing the way superglobals are accessed would fall under that. We try to make it as easy and clear to review the why of the change (and this includes "why" it works)

wp_insert_post( $new_note );
}

wp_safe_redirect( wp_get_referer() );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change expected to be part of this PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. When data was sent over GET, that line had the use of hiding the querystring. The user was immediately redirected to the page it created the note from, so that he would not see the GET parameters. However, wp_get_referer returns false after a POST request, so I had to be taken away, together with the following exit.

$current_id = ( ! empty( $posts[0]->ID ) ) ? $posts[0]->ID : 0;
$current_post = ( ! empty( $posts[0] ) ) ? $posts[0] : false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whitespace should be part of a separate commit as per https://vip.wordpress.com/documentation/creating-good-changesets/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right - should I create a new commit restoring that line to what it was before? :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right - should I create a new commit restoring that line to what it was before? :)
Yup!

}

} No newline at end of file
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change, while also fine, should probably not be part of this commit :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right - should I create a new commit restoring that line to what it was before? :)

(Here, I think that the issue is that my editor adds a newline at the end of the file after saving - will see how to get rid of it)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right - should I create a new commit restoring that line to what it was before? :)
That would be optimal :)

@TheCrowned
Copy link
Copy Markdown
Contributor Author

About (not) using $_REQUEST, should I create a new commit in which $_POST is used instead? I did not change them because I supposed that, since they were like that before, I should have left them alone :)

Nod (for the future) about explaining why the changes work and answering to questions you may have when reviewing!

@sboisvert
Copy link
Copy Markdown
Contributor

About (not) using $_REQUEST, should I create a new commit in which $_POST is used instead? I did not change them because I supposed that, since they were like that before, I should have left them alone :)

This should be a separate PR. Leaving it as is in this PR is the right call. Just having information on "why" it works is good.

@TheCrowned
Copy link
Copy Markdown
Contributor Author

I have removed the whitespace changes :)

I will create another branch + PR to change $_REQUEST usage in $_POST usage in this file.

Copy link
Copy Markdown
Contributor

@sboisvert sboisvert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@sboisvert
Copy link
Copy Markdown
Contributor

cc @rinatkhaziev to decide in what release to stick this in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants