A
A
Artyom2021-02-09 02:22:49
Yii
Artyom, 2021-02-09 02:22:49

How to cure count(): Parameter must be an array or an object that implements Countable?

Hello

There is an opensource engine on yii
There is nginx with ubuntu 16.04 and php 7.4

After installing the engine on the server in the template on the front, it gives an error

count(): Parameter must be an array or an object that implements Countable


In the logs this
2021/02/08 23:14:44 [error] 19068#19068: *137 FastCGI sent in stderr: "PHP message: PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /var/www/сайт/vendor/yiisoft/yii/framework/db/ar/CActiveFinder.php on line 1430PHP message: PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /var/www/сайт/vendor/yiisoft/yii/framework/db/ar/CActiveFinder.php on line 1430" while reading response header from upstream, client: айпиадрес, server: out.ixley.ru, request: "GET /store?q= HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.4-fpm.sock:", host: "сайт", referrer: "сайт"


if(count($fks)!==count($pkTable->primaryKey))

In this 1430 line, such a code
$fks=preg_split('/\s*,\s*/',$relation->foreignKey,-1,PREG_SPLIT_NO_EMPTY);
    if(count($fks)!==count($pkTable->primaryKey))
      throw new CDbException(Yii::t('yii','The relation "{relation}" in active record class "{class}" is specified with an invalid foreign key. The columns in the key must match the primary keys of the table "{table}".',
            array('{class}'=>get_class($parent->model), '{relation}'=>$relation->name, '{table}'=>$pkTable->name)));


Developers write in their docks (perhaps on this topic just)
Problems with CWebUser and the Gii module
Since the Gii module uses the CWebUser component that comes with Yii and does not allow you to specify another component as a "user", there may be problems associated with missing methods. The fact is that in Jupi! has its own implementation of the CWebUser component, namely YWebUser. This problem is known, but there is no solution without editing the framework code. Therefore, if you encounter this problem - just comment out (disable) the Gii module.


But I don't know how to replace this module, Google didn't help :(

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question