0

After updating from 2.3.5p2 to 2.4.1 and from php 7.1 to php 7.4 I have strange trouble with request parameters.

I see, that there are parameters set, when I var_dump

$parameters=$this->request->getParams();

var_dump($parameters);

Output:

array(5) { ["key"]=> string(64) "4e10c465f6988a7fjdueia57dbac2407f7990206d27eb47d531c5a94311ca51fd" ["namespace"]=> string(10) "importgrid" ["filters"]=> array(1) { ["placeholder"]=> string(4) "true" } ["paging"]=> array(2) { ["pageSize"]=> string(2) "20" ["current"]=> string(1) "1" } ["isAjax"]=> string(4) "true" } 

I can also access $parameters["key"]; but every other value gives me an error:

var_dump($parameters["paging"]);

Notice: Undefined index: paging in .....

Its like those array keys dont exist, even they show up in the dump $parameters... Any ideas, what is happening here? Have I missed something big in php-arrays from 7.1 to 7.4?

6
  • This makes no sense, must be something else that is wrong, do u have the full code including the request? – Kristoffer Oct 24 '20 at 16:05
  • Here is the compolete DataProvider: pastebin.com/AJYPKjqt – Mario Oct 24 '20 at 17:01
  • I try to access paging (pagesize) and paging(current), sorting (field) and sorting (direction)... line 242-243 and 292 - 293 – Mario Oct 24 '20 at 17:08
  • what do you get if you var_dump($this->request->getParam('sorting')) on line 243 ? – Kristoffer Oct 24 '20 at 19:21
  • I just get NULL – Mario Oct 24 '20 at 19:44
0

As usual, I came back to answer the question myself.

The problem is, that you can't declare an null value to a variable with php 7.4. You can handle it by setting a condition:

if (isset($this->request->getParam('sorting')['field'])) {
  $field=$this->request->getParam('sorting')['field'];
}
else {
  $field="id";
}

Same goes for direction, pagesize and current page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.