To get $_POST variables in Drupal 8 we need to use \Drupal::request()->request->get method.

CommentFileSizeAuthor
#2 patch-2842312.patch3.62 KBchaitanya17

Comments

chaitanya17 created an issue. See original summary.

chaitanya17’s picture

Status: Active » Needs review
StatusFileSize
new3.62 KB

I have changed all $_POST variables with required \Drupal::request()->request->get method.

Please check attached working patch.

abhaysaraf’s picture

Thanks Chaitanya17 for raising the concern and providing the solution.

Your solutions were very helpful.
I was not aware of this new way of handling $_POST data.

And in a solution for AnnotationsSaveAction.php, I have used:

$postReq = \Drupal::request()->request->all();
$nid = isset($postReq['nid']) ? $postReq['nid'] : FALSE;
$img_field = isset($postReq['img_field']) ? $postReq['img_field'] : FALSE;
$annotation = isset($postReq['annotation']) ? $postReq['annotation'] : FALSE;

This reduces multiple times calling get() function.

In 8.x-1.1, I have added a new feature and fixed the raised bug. Please use 8.x-1.1.

grimreaper’s picture

Assigned: chaitanya17 » Unassigned
Status: Needs review » Closed (outdated)

Hello,

I am sorry but the patch changes had been fixed in other issues.