ME 1.39.6
PHP 8.1.27
Cargo @fc658e0df5c2369090a7d37970432f2d2124017c
The following four Cargo deprecation errors appear in my logs. I added a patch with a workaround solution that solves them in my case. I figured, you can spot the affected code more easily this way. Essentially they all share the fact that a cargo field value is null. I did not inspect any further, if you need to know how to actually reproduce all three of them, please let me know.
edit: the following function calls throw the deprecation errors for passing a param as null
- CargoListFormat.php(37): trim() param #1
- CargoTemplateFormat.php(38): str_replace() param #3
- CargoTemplateFormat.php(32): htmlspecialchars_decode() param #1
- CargoStore.php(396): explode() param #2
diff --git a/includes/formats/CargoListFormat.php b/includes/formats/CargoListFormat.php index a8869fc..aa815fd 100644 --- a/includes/formats/CargoListFormat.php +++ b/includes/formats/CargoListFormat.php @@ -33,7 +33,7 @@ class CargoListFormat extends CargoDisplayFormat { if ( !array_key_exists( $fieldName, $row ) ) { continue; } - $fieldValue = $row[$fieldName]; + $fieldValue = is_null($row[$fieldName]) ? '' : $row[$fieldName]; if ( trim( $fieldValue ) == '' ) { continue; } diff --git a/includes/formats/CargoTemplateFormat.php b/includes/formats/CargoTemplateFormat.php index 5586707..4052701 100644 --- a/includes/formats/CargoTemplateFormat.php +++ b/includes/formats/CargoTemplateFormat.php @@ -28,6 +28,7 @@ class CargoTemplateFormat extends CargoDisplayFormat { // because it's the only one that uses the // unformatted values - the formatted values // do this HTML-encoding on their own. + $row[$fieldName] = is_null($row[$fieldName]) ? '' : $row[$fieldName]; if ( $fieldDescription->mType == 'Wikitext' || $fieldDescription->mType == 'Wikitext string' ) { $value = htmlspecialchars_decode( $row[$fieldName] ); } else { diff --git a/includes/parserfunctions/CargoStore.php b/includes/parserfunctions/CargoStore.php index fe57c6b..3fa4c88 100644 --- a/includes/parserfunctions/CargoStore.php +++ b/includes/parserfunctions/CargoStore.php @@ -393,7 +393,8 @@ class CargoStore { if ( $fieldDescription->mIsList ) { $fieldTableName = $tableName . '__' . $fieldName; $delimiter = $fieldDescription->getDelimiter(); - $individualValues = explode( $delimiter, $tableFieldValues[$fieldName] ); + $valuesForField = is_null($tableFieldValues[$fieldName]) ? '' : $tableFieldValues[$fieldName]; + $individualValues = explode( $delimiter, $valuesForField ); $valueNum = 1; foreach ( $individualValues as $individualValue ) { $individualValue = trim( $individualValue );