cart icon indicating copy to clipboard operation
cart copied to clipboard

[CLEANUP] ignore php warning if no page is selected via the page tree

Open dontWatchMeCode opened this issue 1 year ago • 7 comments

Screenshot from 2024-08-12 12-35-45

reproduce:

  • delete the pid query param / open the BE and directly go to the Cart BE Modules

Best regards.

dontWatchMeCode avatar Aug 12 '24 10:08 dontWatchMeCode

@dontWatchMeCode maybe I missed something so therefore: Why did you add a @ before the $this?

rintisch avatar Aug 13 '24 15:08 rintisch

Ignores the warning thrown if the array key is not set:

https://www.php.net/manual/en/language.operators.errorcontrol.php (Error Control Operators)

Since the value is set to PID 1 and the warning isn't needed.

dontWatchMeCode avatar Aug 13 '24 15:08 dontWatchMeCode

Interesting. Thanks for the input. It's not me to decide whether to go this way but: I cannot reproduce this error at all.

rintisch avatar Aug 13 '24 15:08 rintisch

Wait... I really need to setup a extra TYPO3 for the EXT:cart stuff...

rintisch avatar Aug 13 '24 15:08 rintisch

I can imagine that @extcode prefers something like

$pageId = isset($this->request->getQueryParams()['id']) ? (int)$this->request->getQueryParams()['id'] : 1;

to not block warning that we are not expecting at the moment.

rintisch avatar Aug 13 '24 15:08 rintisch

Thanks,

i'm using PHP 8.1 with t3 v12 and error reporting in dev mode.

Maybe an older PHP Version or t3 set to ignore warnings?

isset(... should still throw an error.

array_key_exists('id', $this->request->getQueryParams()) ... should work as an alternative to @.

dontWatchMeCode avatar Aug 13 '24 16:08 dontWatchMeCode

Yes, I meant with "wait..." that I had a wrong configuration. Now I can reproduce the error. But it's solved with the code snippet that I wrote above.

rintisch avatar Aug 13 '24 16:08 rintisch