PHP mailparse.so error - undefined symbol mbfl_convert_filter_flush

Vladimir Kornea picture Vladimir Kornea · Jan 15, 2014 · Viewed 7.5k times · Source

sudo pecl install mailparse ends with:

Build process completed successfully
Installing '/usr/lib64/php/5.5/modules/mailparse.so'
install ok: channel://pecl.php.net/mailparse-2.1.6
configuration option "php_ini" is not set to php.ini location
You should add "extension=mailparse.so" to php.ini

After adding extension=mailparse.so to the Dynamic Extensions section of php.ini, running php prints this:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/5.5/modules/mailparse.so' - /usr/lib64/php/5.5/modules/mailparse.so: undefined symbol: mbfl_convert_filter_flush in Unknown on line 0

Answer

Vladimir Kornea picture Vladimir Kornea · Jan 15, 2014

Solution

mailparse must be loaded after mbstring, and mbstring is loaded by /etc/php-5.5.d/mbstring.ini which is read after php.ini.

Merely adding mailparse.ini to php-5.5.d will not work, because ini files are loaded alphabetically; though you could just name it zz_mailparse.ini instead.

Loading both extensions in only(sic) php.ini results in:

PHP Warning:  Module 'mbstring' already loaded in Unknown on line 0
PHP Warning:  Module 'mailparse' already loaded in Unknown on line 0

That one's a mystery.

Proof

$ echo '<?php echo extension_loaded("mailparse") ? "mailparse loaded\n" : "mailparse not loaded\n";' > ~/is_mailparse_loaded.php
$ php ~/is_mailparse_loaded.php
mailparse loaded
$ pwd
/etc/php-5.5.d
$ sudo mv zz_mailparse.ini mailparse.ini
$ php ~/is_mailparse_loaded.php
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/5.5/modules/mailparse.so' - /usr/lib64/php/5.5/modules/mailparse.so: undefined symbol: mbfl_convert_filter_flush in Unknown on line 0
mailparse not loaded
$ sudo mv mailparse.ini zz_mailparse.ini
$ php ~/is_mailparse_loaded.php
mailparse loaded
$