soflyy / oxygen-bugs-and-features

Bug Reports & Feature Requests for Oxygen
https://oxygenbuilder.com/
314 stars 29 forks source link

Oxy 4.7.1/4.8/4.9 PHP Deprecated 'strpos()/str_replace(): Passing null to parameter ...' in Backend #3452

Open maltmann-muc opened 11 months ago

maltmann-muc commented 11 months ago

Environment: PHP 8.1, WP 6.4.1, Oxy 4.7.1 Situation: In general for every backend screen

Files and Functions: wp-content/plugins/oxygen/component-framework/admin/pages.php • ct_admin_settings() • oxygen_vsb_register_signing_page() • oxygen_vsb_regenerate_css() wp-content/plugins/oxygen/component-framework/includes/oxygen-connection.php • oxygen_vsb_connection_register_options_page()

Warning and Call Stack: (Sample for one of the four cases)

Deprecated:  strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /.../wp-includes/functions.php on line 7241
Stack trace:
  1. {main}() /.../wp-admin/index.php:0
  2. require_once() /.../wp-admin/index.php:10
  3. require() /.../wp-admin/admin.php:158
  4. require_once() /.../wp-admin/menu.php:417
  5. do_action($hook_name = 'admin_menu', ...$arg = variadic('')) /.../wp-admin/includes/menu.php:161
  6. WP_Hook->do_action($args = [0 => '']) /.../wp-includes/plugin.php:517
  7. WP_Hook->apply_filters($value = '', $args = [0 => '']) /.../wp-includes/class-wp-hook.php:348
  8. oxygen_vsb_register_signing_page('') /.../wp-includes/class-wp-hook.php:324
  9. add_submenu_page($parent_slug = NULL, $page_title = 'Oxygen Sign Shortcodes', $menu_title = 'Oxygen Sign Shortcodes', $capability = 'read', $menu_slug = 'oxygen_vsb_sign_shortcodes', $callback = 'oxygen_vsb_sign_shortcodes_page', $position = *uninitialized*) /.../wp-content/plugins/oxygen/component-framework/admin/pages.php:1674
 10. plugin_basename($file = NULL) /.../wp-admin/includes/plugin.php:1409
 11. wp_normalize_path($path = NULL) /.../wp-includes/plugin.php:769
 12. wp_is_stream($path = NULL) /.../wp-includes/functions.php:2180
 13. strpos($haystack = NULL, $needle = '://') /.../wp-includes/functions.php:7241

Deprecated:  str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /.../wp-includes/functions.php on line 2187
Stack trace:
  1. {main}() /.../wp-admin/index.php:0
  2. require_once() /.../wp-admin/index.php:10
  3. require() /.../wp-admin/admin.php:158
  4. require_once() /.../wp-admin/menu.php:417
  5. do_action($hook_name = 'admin_menu', ...$arg = variadic('')) /.../wp-admin/includes/menu.php:161
  6. WP_Hook->do_action($args = [0 => '']) /.../wp-includes/plugin.php:517
  7. WP_Hook->apply_filters($value = '', $args = [0 => '']) /.../wp-includes/class-wp-hook.php:348
  8. oxygen_vsb_register_signing_page('') /.../wp-includes/class-wp-hook.php:324
  9. add_submenu_page($parent_slug = NULL, $page_title = 'Oxygen Sign Shortcodes', $menu_title = 'Oxygen Sign Shortcodes', $capability = 'read', $menu_slug = 'oxygen_vsb_sign_shortcodes', $callback = 'oxygen_vsb_sign_shortcodes_page', $position = *uninitialized*) /.../wp-content/plugins/oxygen/component-framework/admin/pages.php:1674
 10. plugin_basename($file = NULL) /.../wp-admin/includes/plugin.php:1409
 11. wp_normalize_path($path = NULL) /.../wp-includes/plugin.php:769
 12. str_replace($search = '\\', $replace = '/', $subject = NULL) /.../wp-includes/functions.php:2187

Description: Oxygen calls add_submenu_page() to add 'Add 3rd Party Design Set', 'Oxygen Sign Shortcodes', 'Oxygen Regenerate CSS', 'Oxygen QA Check', passing null as first parameter. 
First parameter to add_submenu_page is a required string.

Bildschirmfoto 2023-11-19 um 10 49 20

Solution: For all four occurrences, change add_submenu_page(null, ... to add_submenu_page('null', ...

maltmann-muc commented 11 months ago

Oxy 4.8 RC 1: Issue persists, but reporting for menu item "Oxygen QA Check" seems gone.

maltmann-muc commented 10 months ago

Oxy 4.8: Issue persists,

Kpudlo commented 10 months ago

Confirmed and reported internally via https://github.com/soflyy/oxygen/issues/5187 and https://github.com/soflyy/oxygen/issues/5255

maltmann-muc commented 5 months ago

Oxy 4.8.3: Issue persists.

maltmann-muc commented 5 months ago

Apparently, this can be solved easily by replacing the parent slug (null) in add_submenu_page with an empty string ('').

Yes, absolutely. The first parameter must be a string, not null.

FORTE-WP commented 5 months ago

Sorry @maltmann-muc, just seconds before your response I removed my comment, because my solution to replace the parent slug null by an empty string as Yoast has done, created a new error. The empty string returned: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated (wp-admin/admin-header.php:36)

maltmann-muc commented 5 months ago

Sorry @maltmann-muc, just seconds before your response I removed my comment, because my solution to replace the parent slug null by an empty string as Yoast has done, created a new error. The empty string returned: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated (wp-admin/admin-header.php:36)

I can't imagine why an empty string should cause any issues. An empty string is not null. Maybe I find some time to investigate

In my request I suggested 'null' (as string) which doesn't cause any issues – since at least a year where I used this modification.

FORTE-WP commented 5 months ago

The error occurs when accessing the submenu pages that have an empty parent slug. No title, not even an empty string, is returned by the function get_admin_page_title() (wp-admin/admin-header.php:35). Using any fake slug will probably do the trick. BTW: Yoast has the same problem for submenu pages with empty strings parent slugs.

maltmann-muc commented 5 months ago

The error occurs when accessing the submenu pages that have an empty parent slug. ... Using any fake slug will probably do the trick.

Thank you for reporting. Then my initial suggestion using 'null' (= fake slug) will work – as I can confirm from experiences.

perrelet commented 5 months ago

@Spellhammer Why does this remain unfixed?

maltmann-muc commented 2 months ago

Oxy 4.9: Issue persists.