Icon picker fatal error
还没有人认领这个 Issue。
评估
调研方向
从 includes/fields/class-acf-field-icon_picker.php 第 132 行开始,使用 issue 中显示的自定义选项卡和图标过滤器重现失败。使用提供的 ACF 区块配置以及 WordPress/PHP 版本,确认失败的渲染路径。页面编辑器能够加载带有自定义图标集的区块且不发生致命错误,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
When using the icon picker field type in a custom ACF block with a custom icon set I am getting the following error when trying to edit a page where that block is used:
Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /var/www/html/wp-content/plugins/advanced-custom-fields-pro/includes/fields/class-acf-field-icon_picker.php:132 Stack trace: #0 /var/www/html/wp-includes/class-wp-hook.php(324): acf_field_icon_picker->render_field(Array) #1 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array) #2 /var/www/html/wp-includes/plugin.php(565): WP_Hook->do_action(Array) #3 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/includes/acf-hook-functions.php(113): do_action_ref_array('acf/render_fiel...', Array) #4 /var/www/html/wp-includes/class-wp-hook.php(324): _acf_apply_hook_variations(Array) #5 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array) #6 /var/www/html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #7 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/includes/acf-field-functions.php(807): do_action('acf/render_fiel...', Array) #8 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/includes/acf-field-functions.php(763): acf_render_field(Array) #9 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/includes/acf-field-functions.php(614): acf_render_field_wrap(Array, 'div', 'field') #10 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php(613): acf_render_fields(Array, 'block_32caf81ff...', 'div', 'field') #11 /var/www/html/wp-content/plugins/advanced-custom-fields-pro/pro/blocks.php(543): acf_rendered_block(Array, '', true, 1307, Object(WP_Block)) #12 /var/www/html/wp-includes/class-wp-block.php(586): acf_render_block_callback(Array, '', Object(WP_Block)) #13 /var/www/html/wp-includes/blocks.php(2358): WP_Block->render() #14 /var/www/html/wp-includes/blocks.php(2410): render_block(Array) #15 /var/www/html/wp-includes/class-wp-hook.php(324): do_blocks('<!-- wp:acf/her...') #16 /var/www/html/wp-includes/plugin.php(205): WP_Hook->apply_filters('<!-- wp:acf/her...', Array) #17 /var/www/html/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php(1961): apply_filters('the_content', '<!-- wp:acf/her...') #18 /var/www/html/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php(655): WP_REST_Posts_Controller->prepare_item_for_response(Object(WP_Post), Object(WP_REST_Request)) #19 /var/www/html/wp-includes/rest-api/class-wp-rest-server.php(1292): WP_REST_Posts_Controller->get_item(Object(WP_REST_Request)) #20 /var/www/html/wp-includes/rest-api/class-wp-rest-server.php(1125): WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/wp/v2/pages/(?...', Array, NULL) #21 /var/www/html/wp-includes/rest-api.php(586): WP_REST_Server->dispatch(Object(WP_REST_Request)) #22 /var/www/html/wp-includes/rest-api.php(2973): rest_do_request(Object(WP_REST_Request)) #23 [internal function]: rest_preload_api_request(Array, '/wp/v2/pages/13...') #24 /var/www/html/wp-includes/block-editor.php(754): array_reduce(Array, 'rest_preload_ap...', Array) #25 /var/www/html/wp-admin/edit-form-blocks.php(114): block_editor_rest_api_preload(Array, Object(WP_Block_Editor_Context)) #26 /var/www/html/wp-admin/post.php(187): require('/var/www/html/w...') #27 {main} thrown in /var/www/html/wp-content/plugins/advanced-custom-fields-pro/includes/fields/class-acf-field-icon_picker.php on line 132
To Reproduce
Steps to reproduce the behavior:
- Create an ACF block with an icon picker field with a custom icon set.
- Use the following code (or similar) in functions.php to manage the custom icon set
add_filter('acf/fields/icon_picker/tabs', function(array $tabs): array {
$tabs['nwlp'] = 'NWLP';
return $tabs;
});
add_filter('acf/fields/icon_picker/nwlp/icons', function(array $icons): array {
$base_url = get_template_directory_uri() . '/assets/images/icons/';
return [
[
'url' => $base_url . 'accreditations.svg',
'key' => 'accreditations',
'label' => 'Accreditations',
],
[
'url' => $base_url . 'audio-podcast.svg',
'key' => 'audio-podcast',
'label' => 'Audio podcast',
]
];
});
- Try to insert/edit a page where this block is embedded and the error should show.
Expected behavior
No error to show
Code
{
"key": "group_687639d742f8f",
"title": "Block: Icon",
"fields": [
{
"key": "field_687639d70f893",
"label": "Icon",
"name": "icon",
"aria-label": "",
"type": "icon_picker",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"tabs": [
"nwlp"
],
"return_format": "array",
"allow_in_bindings": 0,
"library": "all",
"default_value": {
"type": null,
"value": null
}
},
{
"key": "field_68763a145e4e2",
"label": "Icon Colour",
"name": "icon_colour",
"aria-label": "",
"type": "select",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"choices": {
"blue": "Blue",
"green": "Green",
"pink": "Pink"
},
"default_value": false,
"return_format": "value",
"multiple": 0,
"allow_null": 0,
"allow_in_bindings": 0,
"ui": 0,
"ajax": 0,
"placeholder": "",
"create_options": 0,
"save_options": 0
}
],
"location": [
[
{
"param": "block",
"operator": "==",
"value": "acf\/icon"
}
]
],
"menu_order": 0,
"position": "normal",
"style": "default",
"label_placement": "top",
"instruction_placement": "label",
"hide_on_screen": "",
"active": true,
"description": "",
"show_in_rest": 0,
"modified": 1752583984
}
Version Information:
- WordPress Version 6.8.2
- PHP Version 8.2.28
- ACF Version ACF Pro 6.4.3
- Browser Chrome 138
- 主要语言
- PHP
- 星标
- 946
- 派生
- 197
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
AdvancedCustomFields/acf 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
AdvancedCustomFields/acf#1041 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 86/100
AdvancedCustomFields/acf#1038 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
AdvancedCustomFields/acf#1034 · 2 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 86/100
AdvancedCustomFields/acf#1032 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
AdvancedCustomFields/acf#1029 · 1 条评论 ·
查看 AdvancedCustomFields/acf 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
rap2hpoutre/fast-excel#425 ·
-
bug Medium Priority
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
sync-en
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
sync-en
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复
-
Перевод устарел
难度 1/5 1-3 小时 新手友好度 78/100