首页 > 解决方案 > 从 PHP 7.0 升级到 PHP 7.1。致命错误:只能通过引用传递变量 - 使用数组的 $string get_param 命令

问题描述

我们是一家运行 nBill 的网球和壁球俱乐部,这是一个不再受到积极支持的发票系统。我在从 PHP 5 升级到 7 时对其进行了护理,但在进一步升级到 PHP7.1 时,应用程序无法加载,并且我收到以下致命错误消息:

Fatal error: Only variables can be passed by reference in /xxxxxxxx/public_html/administrator/components/com_nbill/classes/base/data_mapper.php on line 98.

我知道出了什么问题,但我无法解决它,这超出了我对 PHP 的有限了解。删除代码部分使应用程序能够工作,然后它似乎工作正常。

过错陈述是:

  $string = nbf_common::get_param(array($key=>$value), $key, '', false, (string)@$col[0]->encode_html != "false", (string)@$col[0]->allow_html == "true", (string)@$col[0]->allow_html == "true");

完整的代码部分如下:

     * Return an appropriate string to use for the value in an SQL statement
     (escaped, or intval'd as appropriate for the data type, based on the XML

    schema file, if found, or just treated as a string [and escaped] otherwise)

        * @param string $key Column name
        * @param mixed $value Literal value
        */
        protected function getValueSqlString($key, $value)
        {
            $string = "";

            if ($this->schema)
            {
                $col = $schema->xpath("columns/column[@name='$key']");
                switch (@$col->type)
                {
                    case "int":
                    case "tinyint":
                    case "smallint":
                    case "mediumint":
                    case "bigint":
                    case "integer":
                    case "long":
                        $string = strval(intval($value));
                        break;
                    default:
                        $string = nbf_common::get_param(array($key=>$value),
 $key, '', false, (string)@$col[0]->encode_html != "false", 
(string)@$col[0]->allow_html == "true", 
(string)@$col[0]->allow_html == "true");
                        break;
                }
            }

            if (!$string) {
                $string = "'" . $this->db->getEscaped($value) . "'";
            }
            return $string;
        }

        /**

非常感激地收到任何帮助。请注意,我们正在积极寻求替代发票系统,并正在试用 CBSubs。

CBSheen

标签: phpjoomla3.0

解决方案


<?php
$array = array($key=>$value);
$string = nbf_common::get_param(strtolower(array_pop($array)), $key, '', false, (string)@$col[0]->encode_html != "false", (string)@$col[0]->allow_html == "true", (string)@$col[0]->allow_html == "true");

试试上面的代码。我不是 joomla 专家,但根据您的错误,我认为问题出在您尝试在get_param函数内部传递数组时。


推荐阅读