Skip to content

[Bug] PHP 8.5 has mbstring compiled in, but mbstring.sh appends mbstring.so and causes "Module already loaded" #287

Description

@ooopus

Environment:

  • Ubuntu 26.04 LTS x86_64
  • PHP 8.5.8 installed by aaPanel
  • Script: /www/server/panel/install/mbstring.sh

Problem:
aaPanel builds PHP 8.5 with --enable-mbstring, so mbstring is already
available even when PHP is started with -n.

Reproduction:

/www/server/php/85/bin/php -n -r
'echo extension_loaded("mbstring") ? "loaded\n" : "missing\n";'

Output:
loaded

After installing mbstring from aaPanel, mbstring.sh appends:

extension = /www/server/php/85/lib/php/extensions/no-debug-non-zts-20250925/mbstring.so

to both php.ini and php-cli.ini.

Every PHP invocation then prints:

PHP Warning: Module "mbstring" is already loaded in Unknown on line 0

Root cause:
Install_mbstring() only treats mbstring as installed when both a
/mbstring.so configuration line and php -m output exist. It does not
detect a statically compiled mbstring module.

Suggested fix:
Before building or appending mbstring.so, test the no-configuration PHP
binary:

/www/server/php/$version/bin/php -n -r
'exit(extension_loaded("mbstring") ? 0 : 1);'

If it returns 0, report mbstring as built in and do not append the
dynamic extension line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions