Skip to content

wpbones_modules() cannot load a module whose name ends with 'p' or 'h' #142

Closed

Description

@bardrop

wpbones_modules() (and import()) build the file name with rtrim($file, '.php') . '.php'. The second argument of rtrim is a list of characters, so every trailing ., p and h is removed, not only the .php suffix:

call file that is loaded
wpbones_modules('shop') plugin/modules/sho.php
wpbones_modules('map') plugin/modules/ma.php
wpbones_modules('Help.php') plugin/modules/Hel.php

Expected: only a .php suffix is removed before .php is added, for example preg_replace('/\.php$/', '', $file) . '.php'.

Seen on master (v3.3.0), src/helpers.php, PHP 8.5.

Activity

  1. self-assigned this
    on Nov 23, 2026
  2. added a commit that references this issue on Nov 23, 2026
    0ba5e05
  3. gfazioli commented on Nov 23, 2026

    @gfazioli
    Collaborator

    @bardrop thanks, the table with the three names made this one quick to confirm 🙏 you're right, rtrim() takes a list of characters, not a suffix, so any module name ending in ., p or h lost its tail... it's been like that since the helper landed in 1.8.0

    fixed in #144: .php is appended only when the name doesn't already end with it, and import() gets the fix too since it's just an alias. there's a unit test for it, plus a run in a real WordPress install with your three names that fails on 3.3.0 and passes on the fix. it's out in v3.3.1, composer update wpbones/wpbones and you're set

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions