卷曲牙括号php 8更新后的致命错误
我有一个WordPress网站,可以大量使用插件,NextEnd Accialion菜单,该菜单不再维护。它仍然可以很好地适用于WordPress的每个新版本,如果可能的话,我想坚持下去。但是,当我测试站点从php 7.3到8的更新时,插件会断开。最终,我将不得不去PHP 8,所以我正在尝试为那个时候做准备。
我认为我已经找到了需要修复的内容,就像在错误日志中一样,我看到了致命错误 - “不再支持带有卷曲括号的数组和字符串偏移访问语法。”当我查看触发错误的线路时,我可以看到大多数错误的修复程序。
对于五个错误中的四个错误,这只是更改类似的问题的问题,
if ($tag{0} == $this->lessc->vPrefix)
但是
if ($tag[0] == $this->lessc->vPrefix)
对于最后一个错误,问题在此处是在Elseif行上:
protected function end() {
if ($this->literal(';')) {
return true;
} elseif ($this->count == strlen($this->buffer) || $this->buffer{$this->count} == '}') {
// if there is end of file or a closing block next then we don't need a ;
return true;
}
return false;
}
$ this-> buffer {$ this- this-> count}
似乎是有问题的项目,但我在弄清楚如何更改它方面远远超出了深度。
我尝试将卷发括号更改为方形牙套,括号,双卷发括号,在每种情况下,它都会造成更多和不同的错误。
尝试方形牙套 $ this-> buffer [$ this-> count]
给我这个更为复杂和不透明的新错误:(
PHP Fatal error: Uncaught TypeError: array_merge(): Argument #2 must be of type array, null given in /nas/content/live/stagingsitexray/wp-content/plugins/nextend-accordion-menu/nextend/parse/font.php:27\nStack trace:\n#0 /nas/content/live/stagingsitexray/wp-content/plugins/nextend-accordion-menu/nextend/parse/font.php(27): array_merge(Array, NULL)\n#1 /nas/content/live/stagingsitexray/wp-content/plugins/nextend-accordion-menu/themes/default/default/context.php(39): NextendParseFont->mixinTab('Active')\n#2 /nas/content/live/stagingsitexray/wp-content/plugins/nextend-accordion-menu/library/accordionmenu/menu.php(161): include('/nas/content/li...')\n#3 /nas/content/live/stagingsitexray/wp-content/plugins/nextend-accordion-menu/library/accordionmenu/wordpress/menu.php(67): NextendMenu->addCSS()\n#4 /nas/content/live/stagingsitexray/wp-content/plugins/nextend-accordion-menu/library/accordionmenu/menu.php(56): NextendMenuWordpress->addCSS()\n#5 /nas/content/live/stagingsitexray/wp-content/plugins/nextend-accordion-menu/widget.php(62): NextendMenu->render()\n#6 /nas/content/live/stagingsitexray/wp-includes/class-wp-widget.php(393): NextendAccordionMenuWidget->widget(Array, Array)\n#7 /nas/content/live/stagingsitexray/wp-includes/widgets.php(835): WP_Widget->display_callback(Array, Array)\n#8 /nas/content/live/stagingsitexray/wp-content/themes/customizr/sidebar-left.php(13): dynamic_sidebar('left')\n#9 /nas/content/live/stagingsitexray/wp-includes/template.php(770): require_once('/nas/content/li...')\n#10 /nas/content/live/stagingsitexray/wp-includes/template.php(716): load_template('/nas/content/li...', true, Array)\n#11 /nas/content/live/stagingsitexray/wp-includes/general-template.php(136): locate_template(Array, true, true, Array)\n#12 /nas/content/live/stagingsitexray/wp-content/themes/customizr/inc/czr-front-ccat.php(7650): get_sidebar('left')\n#13 /nas/content/live/stagingsitexray/wp-includes/class-wp-hook.php(307): CZR_sidebar->czr_fn_render_sidebar('')\n#14 /nas/content/live/stagingsitexray/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters('', Array)\n#15 /nas/content/live/stagingsitexray/wp-includes/plugin.php(476): WP_Hook->do_action(Array)\n#16 /nas/content/live/stagingsitexray/wp-content/themes/customizr/index.php(28): do_action('__before_articl...')\n#17 /nas/content/live/stagingsitexray/wp-includes/template-loader.php(106): include('/nas/content/li...')\n#18 /nas/content/live/stagingsitexray/wp-blog-header.php(19): require_once('/nas/content/li...')\n#19 /nas/content/live/stagingsitexray/index.php(17): require('/nas/content/li...')\n#20 {main}\n thrown in /nas/content/live/stagingsitexray/wp-content/plugins/nextend-accordion-menu/nextend/parse/font.php on line 27, referer: https://stagingsitexray/wp-admin/edit.php?post_type=page
那是其他文件,而不是我当前编辑的文件,即/nas/content/live/stagingsitexray/wp-content/plugins/nextend-accordion-menu/nextend/css/css/.php
I've got a WordPress site that makes heavy use of a plugin, NextEnd Accordion Menu, which is no longer maintained. It still works great with each new version of WordPress and I'd like to stick to it if possible. But when I test a site update from PHP 7.3 to 8, the plugin breaks. Eventually I am going to have to go to PHP 8, so I'm trying to prepare for that time.
I think I've found what needs to be fixed, as in the error logs I see fatal errors--"Array and string offset access syntax with curly braces is no longer supported." When I look at the lines triggering the errors, I can see an easy fix for most of them.
For four out of five of the errors, it's just a matter of changing something like
if ($tag{0} == $this->lessc->vPrefix)
to
if ($tag[0] == $this->lessc->vPrefix)
But for the last error the problem is on the elseif line here:
protected function end() {
if ($this->literal(';')) {
return true;
} elseif ($this->count == strlen($this->buffer) || $this->buffer{$this->count} == '}') {
// if there is end of file or a closing block next then we don't need a ;
return true;
}
return false;
}
That $this->buffer{$this->count}
seems to be the offending item, but I am way beyond my depth in figuring out how to change it.
I tried changing the curly braces to square braces, to parentheses, to double curly braces, and in each case it just caused more and different errors.
Trying the square braces$this->buffer[$this->count]
Gives me this more complicated and opaque to me new error:
PHP Fatal error: Uncaught TypeError: array_merge(): Argument #2 must be of type array, null given in /nas/content/live/stagingsitexray/wp-content/plugins/nextend-accordion-menu/nextend/parse/font.php:27\nStack trace:\n#0 /nas/content/live/stagingsitexray/wp-content/plugins/nextend-accordion-menu/nextend/parse/font.php(27): array_merge(Array, NULL)\n#1 /nas/content/live/stagingsitexray/wp-content/plugins/nextend-accordion-menu/themes/default/default/context.php(39): NextendParseFont->mixinTab('Active')\n#2 /nas/content/live/stagingsitexray/wp-content/plugins/nextend-accordion-menu/library/accordionmenu/menu.php(161): include('/nas/content/li...')\n#3 /nas/content/live/stagingsitexray/wp-content/plugins/nextend-accordion-menu/library/accordionmenu/wordpress/menu.php(67): NextendMenu->addCSS()\n#4 /nas/content/live/stagingsitexray/wp-content/plugins/nextend-accordion-menu/library/accordionmenu/menu.php(56): NextendMenuWordpress->addCSS()\n#5 /nas/content/live/stagingsitexray/wp-content/plugins/nextend-accordion-menu/widget.php(62): NextendMenu->render()\n#6 /nas/content/live/stagingsitexray/wp-includes/class-wp-widget.php(393): NextendAccordionMenuWidget->widget(Array, Array)\n#7 /nas/content/live/stagingsitexray/wp-includes/widgets.php(835): WP_Widget->display_callback(Array, Array)\n#8 /nas/content/live/stagingsitexray/wp-content/themes/customizr/sidebar-left.php(13): dynamic_sidebar('left')\n#9 /nas/content/live/stagingsitexray/wp-includes/template.php(770): require_once('/nas/content/li...')\n#10 /nas/content/live/stagingsitexray/wp-includes/template.php(716): load_template('/nas/content/li...', true, Array)\n#11 /nas/content/live/stagingsitexray/wp-includes/general-template.php(136): locate_template(Array, true, true, Array)\n#12 /nas/content/live/stagingsitexray/wp-content/themes/customizr/inc/czr-front-ccat.php(7650): get_sidebar('left')\n#13 /nas/content/live/stagingsitexray/wp-includes/class-wp-hook.php(307): CZR_sidebar->czr_fn_render_sidebar('')\n#14 /nas/content/live/stagingsitexray/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters('', Array)\n#15 /nas/content/live/stagingsitexray/wp-includes/plugin.php(476): WP_Hook->do_action(Array)\n#16 /nas/content/live/stagingsitexray/wp-content/themes/customizr/index.php(28): do_action('__before_articl...')\n#17 /nas/content/live/stagingsitexray/wp-includes/template-loader.php(106): include('/nas/content/li...')\n#18 /nas/content/live/stagingsitexray/wp-blog-header.php(19): require_once('/nas/content/li...')\n#19 /nas/content/live/stagingsitexray/index.php(17): require('/nas/content/li...')\n#20 {main}\n thrown in /nas/content/live/stagingsitexray/wp-content/plugins/nextend-accordion-menu/nextend/parse/font.php on line 27, referer: https://stagingsitexray/wp-admin/edit.php?post_type=page
(those are a bunch of other files, not the one I'm currently editing, which is /nas/content/live/stagingsitexray/wp-content/plugins/nextend-accordion-menu/nextend/css/less.php
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
替换
$ this-> buffer {$ this-> count} =='}'}'
tostr_ends_with($ this-> buffer,'}'}')
or 代码> substr($ this-> buffer,-1)==='}'replace
$this->buffer{$this->count} == '}'
tostr_ends_with($this->buffer, '}')
orsubstr($this->buffer, -1) === '}'