Title: Bug Report: PHP 8.1+: `plugin_basename()` / `wp_normalize_path()` receive null..
Last modified: April 16, 2026

---

# Bug Report: PHP 8.1+: `plugin_basename()` / `wp_normalize_path()` receive null..

 *  Resolved [Saskia Teichmann](https://wordpress.org/support/users/jyria/)
 * (@jyria)
 * [1 month, 3 weeks ago](https://wordpress.org/support/topic/bug-report-php-8-1-plugin_basename-wp_normalize_path-receive-null/)
 * **Bug report: **PHP 8.1+: `plugin_basename()` / `wp_normalize_path()` receive
   null when Sugar Calendar registers its admin menu
 * **Environment**
    - **Plugin:** Sugar Calendar (Lite) **v3.11.0**
    - **Also active:** Sugar Calendar Gridview Add-On (custom, by Saskia Teichmann)
    - **WordPress:** 6.9.x
    - **PHP:** 8.4.20
    - **Webserver:** nginx (WordOps)
 * **Summary**
 * On every backend request, the following two PHP deprecation warnings fire in 
   series:
 *     ```wp-block-code
       [PHP Deprecated] strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated
          in wp-includes/functions.php on line 7374
       [PHP Deprecated] str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
          in wp-includes/functions.php on line 2196
       ```
   
 * These originate in WordPress core (`wp_is_stream()` and `wp_normalize_path()`),
   but they are reached through Sugar Calendar’s admin menu registration path — 
   specifically `Sugar_Calendar\Admin\Area->admin_menu()` calling `add_submenu_page()`
   with a `$menu_slug` / file path argument that is `null`.
 * We identified the caller by installing a narrow diagnostic error handler (`Tierheim_MU_Deprecation_Tracer`)
   which, when triggered by those specific deprecations from `wp-includes/functions.
   php:7374` or `:2196`, attaches a backtrace.
 * **Captured backtrace (real, from our site)**
 *     ```wp-block-code
       strpos
       wp_is_stream
       wp_normalize_path
       plugin_basename
       add_submenu_page
       Sugar_Calendar\Admin\Area->admin_menu
       WP_Hook->apply_filters
       WP_Hook->do_action
       do_action('admin_menu')
       require_once('wp-admin/includes/menu.php')
       require('wp-admin/menu.php')
       require_once('wp-admin/admin.php')
       ```
   
 * Same chain for `str_replace`/`wp_normalize_path` → `plugin_basename` → `add_submenu_page`
   → `Sugar_Calendar\Admin\Area->admin_menu`.
 * **Expected vs. actual**
    - **Expected:** `add_submenu_page()` receives a non-null `$menu_slug` (and, 
      when it represents a filesystem path, a non-null path argument).
    - **Actual:** Sugar Calendar passes `null` into `add_submenu_page()` for at 
      least one menu slot, which propagates through `plugin_basename() → wp_normalize_path()
      → str_replace(null)` and `wp_is_stream() → strpos(null)`.
 * **Reproduction**
    1. WordPress 6.9.x on PHP 8.1 or later (we observed on 8.4.20).
    2. Activate Sugar Calendar (Lite) v3.11.0.
    3. Enable `WP_DEBUG` + `WP_DEBUG_LOG`.
    4. Visit any `/wp-admin/` page.
    5. Tail `wp-content/debug.log` — two deprecation entries per request.
 * **Suggested fix**
 * Inside `Sugar_Calendar\Admin\Area::admin_menu()`, review every `add_submenu_page()`
   call and ensure the `$menu_slug` argument is always a non-null string. A minimal
   local fix is to coerce:
 *     ```wp-block-code
       add_submenu_page(
           $parent_slug,
           $page_title,
           $menu_title,
           $capability,
           (string) $menu_slug,       // was sometimes null
           $function
       );
       ```
   
 * A better fix is to track down where `$menu_slug` becomes null (likely a conditional
   branch that returns early without assigning a slug) and assign a sensible default
   or skip the `add_submenu_page()` call entirely.
 * **Workaround in place**
 * No workaround for this one – we only installed a **diagnostic tracer** that logs
   the backtrace once per unique signature, so we could identify the caller. The
   two deprecation messages still appear in our debug log (which is fine: we want
   them visible upstream).
 * The tracer will be removed after this ticket is acknowledged or the plugin is
   updated.

Viewing 1 replies (of 1 total)

 *  Plugin Author [Michael](https://wordpress.org/support/users/donmhico/)
 * (@donmhico)
 * [1 month, 2 weeks ago](https://wordpress.org/support/topic/bug-report-php-8-1-plugin_basename-wp_normalize_path-receive-null/#post-18885370)
 * [@jyria](https://wordpress.org/support/users/jyria/) – Thank you so much and 
   we appreciate your detailed report! We will include the fix in our next release.
   
   Michael PanagaSugar Calendar Lead Developer

Viewing 1 replies (of 1 total)

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fbug-report-php-8-1-plugin_basename-wp_normalize_path-receive-null%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](https://ps.w.org/sugar-calendar-lite/assets/icon.svg?rev=3370563)
 * [Sugar Calendar - Events Calendar, Event Tickets, and Events Management Platform](https://wordpress.org/plugins/sugar-calendar-lite/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/sugar-calendar-lite/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/sugar-calendar-lite/)
 * [Active Topics](https://wordpress.org/support/plugin/sugar-calendar-lite/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/sugar-calendar-lite/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/sugar-calendar-lite/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/donmhico/)
 * Last activity: [1 month, 2 weeks ago](https://wordpress.org/support/topic/bug-report-php-8-1-plugin_basename-wp_normalize_path-receive-null/#post-18885370)
 * Status: resolved