extcode / cart

Cart is a small but powerful extension which "solely" adds a shopping cart to your TYPO3 installation. The extension allows you to create coupons, products with or without variants, special prices.
GNU General Public License v2.0
57 stars 51 forks source link

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

Open dontWatchMeCode opened 3 months ago

dontWatchMeCode commented 3 months ago

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

reproduce:

Best regards.

rintisch commented 3 months ago

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

dontWatchMeCode commented 3 months ago

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.

rintisch commented 3 months ago

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 commented 3 months ago

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

rintisch commented 3 months ago

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.

dontWatchMeCode commented 3 months ago

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

rintisch commented 3 months ago

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.