Skip to content

[5.0] Deprecated message: libraries/src/HTML/Helpers/Select.php #41783

@Ruud68

Description

@Ruud68

Steps to reproduce the issue

create a filter field like below that will NOT return a (in this case) item:

		<field
			name="created_by"
			type="sql"
			sql_select="a.id, a.created_by, u.id, u.name AS name"
			sql_from="#__example_clickedlinks AS a"
			sql_join="#__users AS u ON a.created_by = u.id"
			sql_group="a.created_by"
			sql_order="u.name ASC"
			key_field="created_by"
			value_field="name"
			onchange="this.form.submit();"
			>
			<option value="">COM_EXAMPLE_CLICKEDBY_FILTER</option>
		</field>

Expected result

empty filter without errors

Actual result

Deprecated: trim(): Passing null to parameter # 1 ($string) of type string is deprecated in /var/www/html/test/50/libraries/src/HTML/Helpers/Select.php on line 388
and
Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /var/www/html/test/50/libraries/src/HTML/Helpers/Select.php on line 557

Additional comments

change line 388 in libraries/src/HTML/Helpers/Select.php from:

$obj->{$options['option.text']} = trim($text) ? $text : $value;

to

$obj->{$options['option.text']} = trim((string) $text) ? $text : $value;

change line 557 in libraries/src/HTML/Helpers/Select.php from:

$splitText = explode(' - ', $text, 2)

to

$splitText = explode(' - ', (string) $text, 2)

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