Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I open this issue to report a little bug, really easy to solve
It's a common problem see this blog post for more information (in french)
Problem/Motivation
When I add a new asset type I have this Warning:
Strict warning: Only variables should be passed by reference in asset_type_form() (line 65 of /asset/includes/asset.admin.inc).
Proposed resolution
Line 57 asset.admin.inc we have this code :
$icons_options = array('none' => t('No icon'));
$module_icons = _assets_get_icons();
if (!empty($module_icons)) {
$icons_options = $icons_options + $module_icons;
}
$form['icons']['icon'] = array(
'#type' => 'radios',
'#default_value' => $asset_type->icon ? $asset_type->icon : reset(array_keys($icons_options)),
'#options' => $icons_options,
'#title' => t('Button icon'),
);
Just change to this :
$icons_options = array('none' => t('No icon'));
$module_icons = _assets_get_icons();
if (!empty($module_icons)) {
$icons_options = $icons_options + $module_icons;
}
$icons_options = array_keys($icons_options);
$form['icons']['icon'] = array(
'#type' => 'radios',
'#default_value' => $asset_type->icon ? $asset_type->icon : reset($icons_options),
'#options' => $icons_options,
'#title' => t('Button icon'),
);
and hop the warning disappear :)
Comment | File | Size | Author |
---|---|---|---|
#2 | asset-7.x-1.x-dev-fix-strict-warning-1952226-2.patch | 687 bytes | gurvan |
#1 | asset-7.x-1.x-dev-fix-strict-warning-1952226-1.patch | 886 bytes | agalitsyn |
Comments
Comment #1
agalitsyn CreditAttribution: agalitsyn commentedThanks, here is a patch. Will be committed in dev soon
Comment #2
gurvan CreditAttribution: gurvan commentedHere is the clean patch, only for the asset module and not for the entire Drupal docroot (see http://drupal.org/project/asset/git-instructions fore more information about patches)
Comment #3
agalitsyn CreditAttribution: agalitsyn commentedThanks
Comment #3.0
agalitsyn CreditAttribution: agalitsyn commentedremove todo
Comment #4
r2coder CreditAttribution: r2coder commentedThanks mucho for this!