Jaime Ayala
Forum Replies Created
-
Forum: Plugins
In reply to: [Super Page Cache] PHP 8.1 Deprecated NoticesForum: Plugins
In reply to: [Super Page Cache] PHP 8.1 Deprecated NoticesOh, I took another look at the Notices themselves:
strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated
Seems like passing “null” on a STRING argument in a function is deprecated, NOT the use of “null” itself. So I guess they want people to explicitly pass an empty string rather than “null” for STRING arguments.
Forum: Plugins
In reply to: [Super Page Cache] PHP 8.1 Deprecated NoticesHi @isaumya ,
I’m currently running PHP 8.2 as of now, as for the Notices, it SEEMS like the issue is caused by sending ‘null’ in the functions highlighted by the Notices.
For example, I managed to get rid of 1 Notice here: /wp-content/plugins/wp-cloudflare-page-cache/libs/html_cache.class.php @ line 36.
It had this:
function add_admin_menu_pages() { add_submenu_page( null, __( 'Super Page Cache for Cloudflare cached HTML pages', 'wp-cloudflare-page-cache' ), __( 'Super Page Cache for Cloudflare cached HTML pages', 'wp-cloudflare-page-cache' ), 'manage_options', 'wp-cloudflare-super-page-cache-cached-html-pages', array($this, 'admin_menu_page_cached_html_pages') ); }
Notice the “null”, after the add_submenu_page() function.
If I replace it with:
''
The Notice disappear.
This is how it looks like when I replace it:
function add_admin_menu_pages() { add_submenu_page( '', __( 'Super Page Cache for Cloudflare cached HTML pages', 'wp-cloudflare-page-cache' ), __( 'Super Page Cache for Cloudflare cached HTML pages', 'wp-cloudflare-page-cache' ), 'manage_options', 'wp-cloudflare-super-page-cache-cached-html-pages', array($this, 'admin_menu_page_cached_html_pages') ); }
As I understand it, PHP 8.1+ has deprecated passing “null” as parameters to a lot of core functions. Now, I’m no PHP programmer (I understand the basics) but, if I keep replacing nulls with ” from function arguments, the Notices disappear.
Why was this decision made? I have no idea, but it looks like they want developers to be explicit when passing arguments through functions. As:
null == ''
If I’m understanding this correctly anyways.
Let me know your thoughts.
Kind regards,
Jaime.
Forum: Plugins
In reply to: [Super Page Cache] PHP 8.1 Deprecated NoticesHi Saumya,
No rush, but just to reiterate. These are NOT errors, but rather notices of deprecated functions.
You can take a look at these notices by installing the Query Monitor plugin and just loading the wp-admin dashboard.
Kind regards,
Jaime.