Page 1 of 1

Errors of the version 1.22.2

PostPosted: 21 Nov 2017, 16:14
by support
Errors of the version 1.22.2

Re: Errors of the version 1.22.2

PostPosted: 12 Feb 2018, 22:34
by Tavovb
Hi guys:

I installed 1.22.2 version on xampp server on windows 10, no errors on installation process, but when I login as admin and try to enter any of this menus (listings/listings, listings/complaints,listings booking property, users/all, etc) I get this error:

Fatal error: Declaration of CustomActiveDataProvider::getPagination() must be compatible with CDataProvider::getPagination($className = 'CPaginatio...') in C:\Users\...\myfolder\protected\components\CustomActiveDataProvider.php on line 21

Here´s de code I find in CustomActiveDataProvider.php´lin 21:

class CustomActiveDataProvider extends CActiveDataProvider {


1) It´s installed on localhost
3) I´m testing on chrome 64.0.3

Thanks.

Re: Errors of the version 1.22.2

PostPosted: 13 Feb 2018, 08:03
by Xpycm
Hello.

Thanks for error.

What version of PHP you have? And what version of XAMPP?

Re: Errors of the version 1.22.2

PostPosted: 22 Feb 2018, 20:40
by Xpycm
Tavovb wrote:Fatal error: Declaration of CustomActiveDataProvider::getPagination() must be compatible with CDataProvider::getPagination($className = 'CPaginatio...')


So I did not wait for your reply, but I understood the error.

It seems like you use PHP 7.2 version.

Solution for PHP 7.2 bugfix. HG Mercurial patch file:

Code: Select all
diff -r a978217813de -r 76c99dd78990 protected/modules/messages/controllers/MainController.php
--- a/protected/modules/messages/controllers/MainController.php    Thu Feb 22 20:11:39 2018 +0300
+++ b/protected/modules/messages/controllers/MainController.php    Thu Feb 22 20:32:16 2018 +0300
@@ -115,+115,@@
             $allUsers = $return['allUsers'];
             $pages = $return['pages'];
 
-            if (count($allUsers)) {
+
            if (is_array($allUsers) && !empty($allUsers)) {
                 $itemsProvider = new CArrayDataProvider(
                     $allUsers, array(
                     'pagination' => array(
diff -r a978217813de -r 76c99dd78990 protected/modules/messages/controllers/backend/MainController.php
--- a/protected/modules/messages/controllers/backend/MainController.php    Thu Feb 22 20:11:39 2018 +0300
+++ b/protected/modules/messages/controllers/backend/MainController.php    Thu Feb 22 20:32:16 2018 +0300
@@ -60,+60,@@
             $allUsers = $return['allUsers'];
             $pages = $return['pages'];
 
-            if (count($allUsers)) {
+
            if (is_array($allUsers) && !empty($allUsers)) {
                 $itemsProvider = new CArrayDataProvider(
                     $allUsers, array(
                     'pagination' => array(
diff -r 481644ae5d0d -r a978217813de protected/components/CustomActiveDataProvider.php
--- a/protected/components/CustomActiveDataProvider.php    Thu Feb 22 20:02:52 2018 +0300
+++ b/protected/components/CustomActiveDataProvider.php    Thu Feb 22 20:11:39 2018 +0300
@@ -24,+24,@@
     private $_pagination;
 
     
// override to create instance of CustomPagination
-    public function getPagination()
+
    public function getPagination($className='CPagination')
     {
         if ($this->_pagination === null) {
diff -r a111b4626c86 -r 481644ae5d0d framework/db/ar/CActiveFinder.php
--- a/framework/db/ar/CActiveFinder.php    Wed Feb 21 09:01:03 2018 +0300
+++ b/framework/db/ar/CActiveFinder.php    Thu Feb 22 20:02:52 2018 +0300
@@ -588,+588,10 @@
                 $childCondition=array();
                 $count=0;
                 $params=array();
+
                $pkCount=is_array($parent->_table->primaryKey)?count($parent->_table->primaryKey):1;
                 foreach($fks as $i=>$fk)
                 {
-
                    if($i<count($parent->_table->primaryKey))
+
                    if($i<$pkCount)
                     {
                         $pk=is_array($parent->_table->primaryKey) ? $parent->_table->primaryKey[$i] : $parent->_table->primaryKey;
                         $parentCondition[$pk]=$joinAlias.'.'.$schema->quoteColumnName($fk).'=:ypl'.$count;
@@
 -599,+600,@@
                     }
                     else
                     
{
-
                        $j=$i-count($parent->_table->primaryKey);
+
                        $j=$i-$pkCount;
                         $pk=is_array($this->_table->primaryKey) ? $this->_table->primaryKey[$j] : $this->_table->primaryKey;
                         $childCondition[$pk]=$this->getColumnPrefix().$schema->quoteColumnName($pk).'='.$joinAlias.'.'.$schema->quoteColumnName($fk);
                     }
@@
 -1173,16 +1174,17 @@
         {
             $parentCondition=array();
             $childCondition=array();
+
            $pkCount=is_array($parent->_table->primaryKey)?count($parent->_table->primaryKey):1;
             foreach($fks as $i=>$fk)
             {
-
                if($i<count($parent->_table->primaryKey))
+
                if($i<$pkCount)
                 {
                     $pk=is_array($parent->_table->primaryKey) ? $parent->_table->primaryKey[$i] : $parent->_table->primaryKey;
                     $parentCondition[$pk]=$parent->getColumnPrefix().$schema->quoteColumnName($pk).'='.$joinAlias.'.'.$schema->quoteColumnName($fk);
                 }
                 else
                 
{
-
                    $j=$i-count($parent->_table->primaryKey);
+
                    $j=$i-$pkCount;
                     $pk=is_array($this->_table->primaryKey) ? $this->_table->primaryKey[$j] : $this->_table->primaryKey;
                     $childCondition[$pk]=$this->getColumnPrefix().$schema->quoteColumnName($pk).'='.$joinAlias.'.'.$schema->quoteColumnName($fk);
                 }
@@
 -1426,+1428,10 @@
         $table=$model->getTableSchema();
         $parent=$this->_parent;
         $pkTable=$parent->model->getTableSchema();
+
        $pkCount=is_array($pkTable->primaryKey)?count($pkTable->primaryKey):1;
 
         $fks
=preg_split('/\s*,\s*/',$relation->foreignKey,-1,PREG_SPLIT_NO_EMPTY);
-
        if(count($fks)!==count($pkTable->primaryKey))
+
        if(count($fks)!==$pkCount)
             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)));
 
@@ -1534,+1537,11 @@
         $relation=$this->relation;
         $model=$this->_finder->getModel($relation->className);
         $table=$model->getTableSchema();
+
        $pkCount=is_array($table->primaryKey)?count($table->primaryKey):1;
         $builder=$model->getCommandBuilder();
         $schema=$builder->getSchema();
         $pkTable=$this->_parent->model->getTableSchema();
+
        $pkCountPk=is_array($pkTable->primaryKey)?count($pkTable->primaryKey):1;
 
         $tableAlias
=$model->getTableAlias(true);
 
@@ -1545,+1550,@@
                 array('{class}'=>get_class($this->_parent->model), '{relation}'=>$relation->name, '{joinTable}'=>$joinTableName)));
 
         $fks
=preg_split('/\s*,\s*/',$keys,-1,PREG_SPLIT_NO_EMPTY);
-
        if(count($fks)!==count($table->primaryKey)+count($pkTable->primaryKey))
+
        if(count($fks)!==$pkCount+$pkCountPk)
             throw new CDbException(Yii::t('yii','The relation "{relation}" in active record class "{class}" is specified with an incomplete foreign key. The foreign key must consist of columns referencing both joining tables.',
                 array('{class}'=>get_class($this->_parent->model), '{relation}'=>$relation->name)));
 
@@ -1585,14 +1590,14 @@
             $map=array();
             foreach($fks as $i=>$fk)
             {
-
                if($i<count($pkTable->primaryKey))
+
                if($i<$pkCountPk)
                 {
                     $pk=is_array($pkTable->primaryKey) ? $pkTable->primaryKey[$i] : $pkTable->primaryKey;
                     $map[$pk]=$fk;
                 }
                 else
                 
{
-
                    $j=$i-count($pkTable->primaryKey);
+
                    $j=$i-$pkCountPk;
                     $pk=is_array($table->primaryKey) ? $table->primaryKey[$j] : $table->primaryKey;
                     $joinCondition[$pk]=$tableAlias.'.'.$schema->quoteColumnName($pk).'='.$joinTable->rawName.'.'.$schema->quoteColumnName($fk);
                 }
 


"-" remove line
"+" add line (instead of)