-
Notifications
You must be signed in to change notification settings - Fork 322
Open
Description
The following blueprint is outputting errors related to the Collator class, enabled by the static Intl extension.
{
"login": true,
"landingPage": "/wp-admin/",
"features": {
"intl": true
},
"steps": [
{
"step": "installPlugin",
"pluginData": {
"resource": "url",
"url": "https://github-proxy.com/proxy/?repo=woocommerce/woocommerce&release=latest&asset=woocommerce.zip"
},
"options": {
"activate": true,
"targetFolderName": "wc"
}
},
{
"step": "installPlugin",
"pluginData": {
"resource": "url",
"url": "https://github-proxy.com/proxy/?repo=woocommerce/wc-smooth-generator&release=latest&asset=wc-smooth-generator.zip"
},
"options": {
"activate": true,
"targetFolderName": "wc-smooth-generator"
}
}
]
}
[06-Aug-2025 09:08:37 UTC] An unexpected error occurred while trying to use PHP Intl Collator class, it may be caused by an incorrect installation of PHP Intl and ICU, and could be fixed by reinstallaing PHP Intl, see more details about PHP Intl installation: https://www.php.net/manual/en/intl.installation.php. Error message: Constructor failed
[06-Aug-2025 09:08:44 UTC] An unexpected error occurred while trying to use PHP Intl Collator class, it may be caused by an incorrect installation of PHP Intl and ICU, and could be fixed by reinstallaing PHP Intl, see more details about PHP Intl installation: https://www.php.net/manual/en/intl.installation.php. Error message: Constructor failed
The errors are printed from this WooCommerce file function :
function wc_asort_by_locale( &$data, $locale = '' ) {
// Use Collator if PHP Internationalization Functions (php-intl) is available.
if ( class_exists( 'Collator' ) ) {
try {
$locale = $locale ? $locale : get_locale();
$collator = new Collator( $locale );
$collator->asort( $data, Collator::SORT_STRING );
return $data;
} catch ( IntlException $e ) {
/*
* Just skip if some error got caused.
* It may be caused in installations that doesn't include ICU TZData.
*/
if ( Constants::is_true( 'WP_DEBUG' ) ) {
error_log( // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
sprintf(
'An unexpected error occurred while trying to use PHP Intl Collator class, it may be caused by an incorrect installation of PHP Intl and ICU, and could be fixed by reinstallaing PHP Intl, see more details about PHP Intl installation: %1$s. Error message: %2$s',
'https://www.php.net/manual/en/intl.installation.php',
$e->getMessage()
)
);
}
}
}
Constructor failed
is a concise error returned by PHP from this file :
ext/intl/collator/collator_create.c
/* {{{ Collator object constructor. */
PHP_METHOD( Collator, __construct )
{
zend_error_handling error_handling;
bool error_handling_replaced = 0;
return_value = ZEND_THIS;
if (collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, &error_handling, &error_handling_replaced) == FAILURE) {
if (!EG(exception)) {
zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
}
}
if (error_handling_replaced) {
zend_restore_error_handling(&error_handling);
}
}
/* }}} */
When running the code returning an error in a blueprint :
{
"features": {
"intl": true
},
"landingPage": "/test.php",
"steps": [
{
"step": "writeFile",
"path": "/wordpress/test.php",
"data": "<?php require_once '/wordpress/wp-load.php'; $data = [ 'banana', 'apple' ]; $locale = get_locale(); $collator = new Collator( $locale ); $collator->asort( $data, Collator::SORT_STRING ); echo '<div style=\"background-color: blue; color: white;\">'; print_r( $data ); echo '</div>'; ?>"
}
]
}
It returns the correct sorted data : Array ( [1] => apple [0] => banana )
Metadata
Metadata
Assignees
Labels
No labels