Skip to content

PHP 8.1 Issue with saving rate limiting function #551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bugcskai opened this issue Jul 26, 2022 · 0 comments · Fixed by #552
Closed

PHP 8.1 Issue with saving rate limiting function #551

bugcskai opened this issue Jul 26, 2022 · 0 comments · Fixed by #552

Comments

@bugcskai
Copy link

System Usage
Version PHP 8.1
Maria Db
Magento 2.4.4
Composer 2

When using the

The line impacted seems to be located here, when the rate limiting path does not exist in the database, the retrieval returns null and the line evaluates into a warning:
https://github.com/fastly/fastly-magento2/blob/master/Controller/Adminhtml/FastlyCdn/RateLimiting/ToggleRateLimiting.php

The warning is as below:

{"status":false,"msg":"Deprecated Functionality: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in /app/3dnmb2vtbqzfq_stg/vendor/fastly/magento2/Controller/Adminhtml/FastlyCdn/RateLimiting/ToggleRateLimiting.php on line 270"}

Description of the deprecating function is noted here as well:
https://php.watch/versions/8.1/internal-func-non-nullable-null-deprecation

To reproduce the issue you can try saving enabling path protection with PHP81 and it would give you the error if no path is specified, trying to work around this by attempting to insert paths would not work because the path protection needs to be first enabled in order to do so.

image

Additional info:
Similarly this is the data in the DB

select * from core_config_data where path like '%rate_limit%';
+-----------+---------+----------+----------------------------------------------------------------------------------------------------------+-------+---------------------+
| config_id | scope   | scope_id | path                                                                                                     | value | updated_at          |
+-----------+---------+----------+----------------------------------------------------------------------------------------------------------+-------+---------------------+
|      1108 | default |        0 | system/full_page_cache/fastly/fastly_rate_limiting_settings/enable_rate_limiting_master                  | 1     | 2022-07-19 00:25:55 |
|      1111 | default |        0 | system/full_page_cache/fastly/fastly_rate_limiting_settings/enable_rate_limiting_logging                 | 0     | 2020-08-17 09:08:18 |
|      1114 | default |        0 | system/full_page_cache/fastly/fastly_rate_limiting_settings/crawler_protection/enable_crawler_protection | 0     | 2020-08-17 09:08:18 |
|      1117 | default |        0 | system/full_page_cache/fastly/fastly_rate_limiting_settings/crawler_protection/exempt_good_bots          | 1     | 2020-08-17 09:08:18 |
+-----------+---------+----------+----------------------------------------------------------------------------------------------------------+-------+---------------------+
4 rows in set (0.00 sec)
+-----------+---------+----------+----------------------------------------------------------------------------------------------------------+-------+---------------------+
| config_id | scope   | scope_id | path                                                                                                     | value | updated_at          |
+-----------+---------+----------+----------------------------------------------------------------------------------------------------------+-------+---------------------+
|      1108 | default |        0 | system/full_page_cache/fastly/fastly_rate_limiting_settings/enable_rate_limiting_master                  | 1     | 2022-07-19 00:25:55 |
|      1111 | default |        0 | system/full_page_cache/fastly/fastly_rate_limiting_settings/enable_rate_limiting_logging                 | 0     | 2020-08-17 09:08:18 |
|      1114 | default |        0 | system/full_page_cache/fastly/fastly_rate_limiting_settings/crawler_protection/enable_crawler_protection | 0     | 2020-08-17 09:08:18 |
|      1117 | default |        0 | system/full_page_cache/fastly/fastly_rate_limiting_settings/crawler_protection/exempt_good_bots          | 1     | 2020-08-17 09:08:18 |
+-----------+---------+----------+----------------------------------------------------------------------------------------------------------+-------+---------------------+
4 rows in set (0.00 sec)

Can we give this a check and implement a null check if possible for all json_decode functions straight from the database?

dpotkoc added a commit to favicode/fastly-magento2 that referenced this issue Jul 27, 2022
vvuksan added a commit that referenced this issue Jul 28, 2022
MickaelDatadome pushed a commit to DataDome/fastly-magento2 that referenced this issue Oct 5, 2023
MickaelDatadome added a commit to DataDome/fastly-magento2 that referenced this issue Oct 5, 2023
Co-authored-by: Shohei Maeda <[email protected]>
Co-authored-by: Domagoj Potkoc <[email protected]>
Co-authored-by: kirgiv4oja <[email protected]>
Co-authored-by: Vladimir Vuksan <[email protected]>
Co-authored-by: Pawel Siejba <[email protected]>
Co-authored-by: Andrew Kett <[email protected]>
Co-authored-by: Peter Dohogne <[email protected]>
Co-authored-by: Lex <[email protected]>
Co-authored-by: Dan Wallis <[email protected]>
Co-authored-by: Sean <[email protected]>
Co-authored-by: Domagoj Potkoc <[email protected]>
Co-authored-by: Jack Scotson <[email protected]>
Co-authored-by: Bohdan Korablov <[email protected]>
Co-authored-by: github-actions <smaeda-ks [email protected]>
Co-authored-by: Alejandro Marroni <[email protected]>
Co-authored-by: github-actions <vvuksan [email protected]>
Co-authored-by: Vladimir Vuksan <[email protected]>
Co-authored-by: Joao Oliveira Pereira <[email protected]>
Co-authored-by: Borna Butkovic <[email protected]>
Co-authored-by: Frangolacci Sebastien <[email protected]>
Co-authored-by: Borzas Laszlo <[email protected]>
Co-authored-by: mizdebski-netacea <[email protected]>
Co-authored-by: Pawel Siejba <[email protected]>
Co-authored-by: ivanviduka <[email protected]>
Co-authored-by: Lauredg <[email protected]>
Co-authored-by: Lauredg <[email protected]>
Fix unset req.http.graphql
fix typo (fastly#464)
fix Fastly const value ti int value fastly#466
fix plugin annotation fastly#466
fix fastly#466
fixing old value in core_config_data fastly#466
fix type check in Image (fastly#472)
fix config save - image optimization fastly#476
Fix ambiguous behavior in Blocking toggle (fastly#479)
Fix type check (fastly#483)
Fix bugs in upadte backend dialog (fastly#487)
Fix for: GetUpdateFlag call flushes all configuration fastly#499
Fix for fastly#504
fix for fastly#520
fixing duplicate line reported under issue#518
Fix fastly#393
fix fastly#393
Fix javascript fastly#544
fix fastly#551
fix getImageOptimization - Deprecated Functionality: explode(): Passing null to parameter #2
fix for fastly#549 as submitted by customer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant