ahmedkaludi / wp-multilang

15 stars 3 forks source link

Undefined array key during PHPUnit tests #107

Closed duakayra closed 1 month ago

duakayra commented 2 months ago

While running PHPUnit tests with WordPress, wp-multilang (version 2.4.10) triggers a PHP warning in class-wpm-install.php on line 271 with if(is_array($available_translations[ $locale ])). The issue occurs because WordPress provides test languages, such as Japanese, that are not available in wp-multilang, leading to an "Undefined array key" warning when trying to access those translations.

Stack trace:

PHP Warning:  Undefined array key "ja_JP" in /home/contentcontrol/git/rfp/wp-content/plugins/wp-multilang/includes/class-wpm-install.php on line 271
PHP Stack trace:
PHP   1. {main}() /home/contentcontrol/git/rfp/vendor/bin/phpunit:0
PHP   2. include() /home/contentcontrol/git/rfp/vendor/bin/phpunit:120
PHP   3. PHPUnit\TextUI\Command::main($exit = *uninitialized*) /home/contentcontrol/git/rfp/vendor/phpunit/phpunit/phpunit:107
PHP   4. PHPUnit\TextUI\Command->run($argv = [0 => 'vendor/bin/phpunit'], $exit = TRUE) /home/contentcontrol/git/rfp/vendor/phpunit/phpunit/src/TextUI/Command.php:99
PHP   5. PHPUnit\TextUI\Command->handleArguments($argv = [0 => 'vendor/bin/phpunit']) /home/contentcontrol/git/rfp/vendor/phpunit/phpunit/src/TextUI/Command.php:114
PHP   6. PHPUnit\TextUI\Command->handleBootstrap($filename = '/home/contentcontrol/git/rfp/tests/bootstrap.php') /home/contentcontrol/git/rfp/vendor/phpunit/phpunit/src/TextUI/Command.php:347
PHP   7. PHPUnit\Util\FileLoader::checkAndLoad($filename = '/home/contentcontrol/git/rfp/tests/bootstrap.php') /home/contentcontrol/git/rfp/vendor/phpunit/phpunit/src/TextUI/Command.php:567
PHP   8. PHPUnit\Util\FileLoader::load($filename = '/home/contentcontrol/git/rfp/tests/bootstrap.php') /home/contentcontrol/git/rfp/vendor/phpunit/phpunit/src/Util/FileLoader.php:49
PHP   9. include_once() /home/contentcontrol/git/rfp/vendor/phpunit/phpunit/src/Util/FileLoader.php:66
PHP  10. require_once() /home/contentcontrol/git/rfp/tests/bootstrap.php:43
PHP  11. require_once() /home/contentcontrol/git/rfp/vendor/wordpress/wordpress/tests/phpunit/includes/bootstrap.php:305
PHP  12. do_action($hook_name = 'init') /home/contentcontrol/git/rfp/vendor/wordpress/wordpress/src/wp-settings.php:695
PHP  13. WP_Hook->do_action($args = [0 => '']) /home/contentcontrol/git/rfp/vendor/wordpress/wordpress/src/wp-includes/plugin.php:517
PHP  14. WP_Hook->apply_filters($value = '', $args = [0 => '']) /home/contentcontrol/git/rfp/vendor/wordpress/wordpress/src/wp-includes/class-wp-hook.php:348
PHP  15. WPM\Includes\WPM_Install::check_version('') /home/contentcontrol/git/rfp/vendor/wordpress/wordpress/src/wp-includes/class-wp-hook.php:324
PHP  16. WPM\Includes\WPM_Install::install() /home/contentcontrol/git/rfp/wp-content/plugins/wp-multilang/includes/class-wpm-install.php:82
PHP  17. WPM\Includes\WPM_Install::create_options() /home/contentcontrol/git/rfp/wp-content/plugins/wp-multilang/includes/class-wpm-install.php:122

Thanks in advance!

Sanjeevsetu commented 2 months ago

Hi @duakayra

Thanks for reporting the bug. We will fix it in next milestone

shridhamdeveloper commented 1 month ago

It has been fixed and released in version 2.4.11