Upgrade from PHP 7.0 to PHP 7.1. Fatal error: Only variables can be passed by reference - $string get_param command using array

Upgrade from PHP 7.0 to PHP 7.1. Fatal error: Only variables can be passed by reference - $string get_param command using array

我们是一个网球和壁球俱乐部 运行 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;
        }

        /**

非常感谢收到的任何帮助。请注意,我们正在积极寻找替代发票系统并试用 CBSub。

CBSheen

<?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 函数中传递数组时。

nbf_common::get_param()

查看此函数,查看哪些参数是通过引用传递的,然后检查作为该参数实际传递的值是否可以作为引用传递。大概就是pr1nc3说的吧