Skip to content

CArrayDataProvider cast sort field to strlower issue #4573

@sveneld

Description

@sveneld

Deprecated: mb_strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in vendor/yiisoft/yii/framework/web/CArrayDataProvider.php on line 179

protected function getSortingFieldValue($data, $fields)
	{
		if(is_object($data))
		{
			foreach($fields as $field)
				$data=isset($data->$field) ? $data->$field : null;
		}
		else
		{
			foreach($fields as $field)
				$data=isset($data[$field]) ? $data[$field] : null;
		}
		return $this->caseSensitiveSort ? $data : mb_strtolower($data,Yii::app()->charset);
	}

What steps will reproduce the problem?

If your dataprovider have a field with null value and caseSensitiveSort = false you will have a notice due to the casting $data to string

What is the expected result?

No deprecation notice

What do you get instead?

deprecation notice

Additional info

Q A
Yii version 1.1.29
PHP version 8.1
Operating system

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions