yiisoft
Repos
186

Yii 2: The Fast, Secure and Professional PHP Framework

14030
6411

Yii 2.0 Basic Application Template

613
675

Yii 2.0 Advanced Application Template

1597
1251

Yii 3 application template

153
41

Yii 3 demo application

284
123

Yii PHP Framework 1.1.x

4838
2254

Events

issue comment
Pass coverage from all PHP versions in `phpunit.yml`
  • The if condition was changed from matrix.php == '8.0' && matrix.os == 'ubuntu-latest' to just matrix.os == 'ubuntu-latest'. This means that the codecov upload will now run on all php versions and not only 8, as it did before this change
Created at 24 minutes ago
pull request opened
Pass coverage from all PHP versions in `phpunit.yml`

| Q | A | ------------- | --- | Is bugfix? | ✔️ | New feature? | ❌ | Breaks BC? | ❌ | Fixed issues | -

Created at 24 minutes ago
create branch
vjik create branch vjik-patch-1
Created at 24 minutes ago
issue comment
Allow use rule attributes for classes and add support for this in `Nested` rule

Codecov Report

Base: 100.00% // Head: 99.93% // Decreases project coverage by -0.06% :warning:

Coverage data is based on head (eb475ed) compared to base (7bdca6e). Patch coverage: 95.23% of modified lines in pull request are covered.

:exclamation: Current head eb475ed differs from pull request most recent head af77f4a. Consider uploading reports for the commit af77f4a to get more accurate results

@@              Coverage Diff              @@
##              master     #437      +/-   ##
=============================================
- Coverage     100.00%   99.93%   -0.07%     
- Complexity       656      661       +5     
=============================================
  Files             76       76              
  Lines           1564     1578      +14     
=============================================
+ Hits            1564     1577      +13     
- Misses             0        1       +1     

| Impacted Files | Coverage Δ | | |---|---|---| | src/EmptyCriteria/NeverEmpty.php | 100.00% <ø> (ø) | | | src/EmptyCriteria/WhenEmpty.php | 100.00% <ø> (ø) | | | src/Rule/Nested.php | 100.00% <ø> (ø) | | | src/Helper/ObjectParser.php | 98.50% <94.73%> (-1.50%) | :arrow_down: | | src/DataSet/ArrayDataSet.php | 100.00% <100.00%> (ø) | | | src/DataSet/SingleValueDataSet.php | 100.00% <100.00%> (ø) | |

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

Created at 32 minutes ago
issue comment
Allow use rule attributes for classes and add support for this in `Nested` rule
  • Added support for class attributes.
  • Fixed type of $rules in ObjectParser::getRules().
Created at 33 minutes ago
pull request opened
Allow use rule attributes for classes and add support for this in `Nested` rule

| Q | A | ------------- | --- | Is bugfix? | ❌ | New feature? | ✔️ | Breaks BC? | ❌ | Fixed issues | -

Created at 34 minutes ago

Apply fixes from StyleCI

Created at 34 minutes ago
create branch
vjik create branch class-attr
Created at 35 minutes ago
Created at 50 minutes ago
delete branch
bizley delete branch upd-per
Created at 1 hour ago

update tutorial-performance-tuning.md php.net links (#19708)

Created at 1 hour ago
pull request closed
update tutorial-performance-tuning.md php.net links

| Q | A | ------------- | --- | Is bugfix? | ❌ | New feature? | ❌ | Breaks BC? | ❌ | Fixed issues | -

Created at 1 hour ago
started
Created at 1 hour ago
issue comment
Disallow using of arrays and objects with `SingleValueDataSet`

Why?

Created at 1 hour ago
Created at 2 hours ago
opened issue
Eager load with() has one bug when relation dynamic className

Eager load with() has one bug when relation dynamic className

table_like id,class_name,object_id 1,\App\Post,1 2,\App\Post,2 3,\App\Comment,3 4,\App\Comment,4

Model: Like extends ActiveRecord{

public function getLikeEntity(){
	return $this->hasOne($this->class_name,['id'=>'obj_id']);
}

}

Now query:

$items = Like::find()->with('likeEnity')->all();

queryBuilder will generate sql like:

select * from post where id in(1,2,3,4)

comment not query !

$items[0]->likeEntity is post model $items[1]->likeEntity is post model $items[2]->likeEntity is null $items[43]->likeEntity is null

Right sql may be like this: select * from post where id in(1,2) select * from comment where id in(3,4)

foreach($items as $item){ //$items[0]->likeEntity is post model //$items[1]->likeEntity is post model //$items[2]->likeEntity is comment model //$items[3]->likeEntity is comment model }

Additional info

| Q | A | ---------------- | --- | Yii version | 2.0.47? | PHP version 8.1 | | Operating system | ubuntu 22.04

Created at 2 hours ago
opened issue
Disallow using of arrays and objects with `SingleValueDataSet`
Created at 2 hours ago

Docs, part 7 (#435)

  • Docs, part 7

  • Apply fixes from StyleCI

  • Fix wording

  • Update src/DataSet/ArrayDataSet.php

Co-authored-by: Alexander Makarov sam@rmcreative.ru

  • Update src/DataSet/ArrayDataSet.php

Co-authored-by: Alexander Makarov sam@rmcreative.ru

  • Update src/DataSet/ArrayDataSet.php

Co-authored-by: Alexander Makarov sam@rmcreative.ru

  • Fix linebreaks [skip ci]

  • Update src/DataSetInterface.php

Co-authored-by: Alexander Makarov sam@rmcreative.ru

  • Update src/DataSet/SingleValueDataSet.php

Co-authored-by: Alexander Makarov sam@rmcreative.ru

  • Move default note from WhenEmpty to NeverEmpty

Co-authored-by: StyleCI Bot bot@styleci.io Co-authored-by: Alexander Makarov sam@rmcreative.ru

Created at 2 hours ago
delete branch
arogachev delete branch docs-7
Created at 2 hours ago
pull request closed
Docs, part 7

| Q | A | ------------- | --- | Is bugfix? | ❌ | New feature? | ❌ | Breaks BC? | ❌ | Fixed issues | #358

Created at 2 hours ago

Move default note from WhenEmpty to NeverEmpty

Created at 2 hours ago

Update src/DataSet/SingleValueDataSet.php

Co-authored-by: Alexander Makarov sam@rmcreative.ru

Created at 2 hours ago

Update src/DataSetInterface.php

Co-authored-by: Alexander Makarov sam@rmcreative.ru

Created at 2 hours ago

Fix linebreaks [skip ci]

Created at 2 hours ago

Update src/DataSet/ArrayDataSet.php

Co-authored-by: Alexander Makarov sam@rmcreative.ru

Created at 2 hours ago

Update src/DataSet/ArrayDataSet.php

Co-authored-by: Alexander Makarov sam@rmcreative.ru

Created at 2 hours ago

Update src/DataSet/ArrayDataSet.php

Co-authored-by: Alexander Makarov sam@rmcreative.ru

Created at 2 hours ago
issue comment
oci8 schema adapter returns null for 'KEY' field in column info which causes strpos deprecation error

Yeah why not.

Given Test.php

<?php
class Test extends CActiveRecord {

	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	public function tableName()
	{
		return 'SCOTT.TEST';
	}

    public function primaryKey(){
        return array('ID');
    }

}

and test.php

<?php
define('YII_DEBUG', true);
require 'vendor/autoload.php';
$config = [
	'components'=>array(
		'db'=>array(
			'class'=>'ext.oci8Pdo.OciDbConnection',
            'connectionString' => 'oci:dbname=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)
                (PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL)));charset=UTF-8;',
            'username'=> 'scott',
			'password'=> 'tiger',
		),
	)
];
$app = Yii::createWebApplication($config);
echo 'Connection string: '; echo Yii::app()->db->connectionString; echo '<br />'.PHP_EOL;

$command = Yii::app()->db->createCommand("create table test (id number, col varchar2(1), constraint id_pk primary key (id))");
$command->execute();
$command = Yii::app()->db->createCommand("insert into test values (1, '1')");
$command->execute();
var_dump(Test::Model()->findByPk(1));

I get

PHP error
strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated

/home/user/src/yii/framework/db/schema/oci/COciSchema.php(234)

222 
223     /**
224      * Creates a table column.
225      * @param array $column column metadata
226      * @return CDbColumnSchema normalized column metadata
227      */
228     protected function createColumn($column)
229     {
230         $c=new COciColumnSchema;
231         $c->name=$column['COLUMN_NAME'];
232         $c->rawName=$this->quoteColumnName($c->name);
233         $c->allowNull=$column['NULLABLE']==='Y';
234         $c->isPrimaryKey=strpos($column['KEY'],'P')!==false;
235         $c->isForeignKey=false;
236         $c->init($column['DATA_TYPE'],$column['DATA_DEFAULT']);
237         $c->comment=$column['COLUMN_COMMENT']===null ? '' : $column['COLUMN_COMMENT'];
238 
239         return $c;
240     }
241 
242     /**
243      * Collects the primary and foreign key column details for the given table.
244      * @param COciTableSchema $table the table metadata
245      */
246     protected function findConstraints($table)
Stack Trace
#0	
–  /home/user/src/yii/framework/db/schema/oci/COciSchema.php(234): strpos(null, "P")
229     {
230         $c=new COciColumnSchema;
231         $c->name=$column['COLUMN_NAME'];
232         $c->rawName=$this->quoteColumnName($c->name);
233         $c->allowNull=$column['NULLABLE']==='Y';
234         $c->isPrimaryKey=strpos($column['KEY'],'P')!==false;
235         $c->isForeignKey=false;
236         $c->init($column['DATA_TYPE'],$column['DATA_DEFAULT']);
237         $c->comment=$column['COLUMN_COMMENT']===null ? '' : $column['COLUMN_COMMENT'];
238 
239         return $c;
#1	
–  /home/user/src/yii/framework/db/schema/oci/COciSchema.php(205): COciSchema->createColumn(array("COLUMN_NAME" => "COL", "DATA_TYPE" => "VARCHAR2(1)", "NULLABLE" => "Y", "DATA_DEFAULT" => null, ...))
200             return false;
201         }
202 
203         foreach($columns as $column)
204         {
205             $c=$this->createColumn($column);
206 
207             $table->columns[$c->name]=$c;
208             if($c->isPrimaryKey)
209             {
210                 if($table->primaryKey===null)
#2	
–  /home/user/src/yii/framework/db/schema/oci/COciSchema.php(123): COciSchema->findColumns(COciTableSchema)
118     protected function loadTable($name)
119     {
120         $table=new COciTableSchema;
121         $this->resolveTableNames($table,$name);
122 
123         if(!$this->findColumns($table))
124             return null;
125         $this->findConstraints($table);
126 
127         return $table;
128     }
#3	
–  /home/user/src/yii/framework/db/schema/CDbSchema.php(103): COciSchema->loadTable("SCOTT.TEST")
098                         $cache->set($key,$table,$duration);
099                 }
100                 $this->_tables[$name]=$table;
101             }
102             else
103                 $this->_tables[$name]=$table=$this->loadTable($realName);
104 
105             if(isset($qcDuration))  // re-enable query caching
106                 $this->_connection->queryCachingDuration=$qcDuration;
107 
108             return $table;
#4	
–  /home/user/src/yii/framework/db/ar/CActiveRecord.php(2390): CDbSchema->getTable("SCOTT.TEST")
2385     public function __construct($model)
2386     {
2387         $this->_modelClassName=get_class($model);
2388 
2389         $tableName=$model->tableName();
2390         if(($table=$model->getDbConnection()->getSchema()->getTable($tableName))===null)
2391             throw new CDbException(Yii::t('yii','The table "{table}" for active record class "{class}" cannot be found in the database.',
2392                 array('{class}'=>$this->_modelClassName,'{table}'=>$tableName)));
2393                 
2394         if(($modelPk=$model->primaryKey())!==null || $table->primaryKey===null)
2395         {
#5	
–  /home/user/src/yii/framework/db/ar/CActiveRecord.php(413): CActiveRecordMetaData->__construct(Test)
408     {
409         $className=get_class($this);
410         if(!array_key_exists($className,self::$_md))
411         {
412             self::$_md[$className]=null; // preventing recursive invokes of {@link getMetaData()} via {@link __get()}
413             self::$_md[$className]=new CActiveRecordMetaData($this);
414         }
415         return self::$_md[$className];
416     }
417 
418     /**
#6	
–  /home/user/src/yii/framework/db/ar/CActiveRecord.php(663): CActiveRecord->getMetaData()
658      * Returns the metadata of the table that this AR belongs to
659      * @return CDbTableSchema the metadata of the table that this AR belongs to
660      */
661     public function getTableSchema()
662     {
663         return $this->getMetaData()->tableSchema;
664     }
665 
666     /**
667      * Returns the command builder used by this AR.
668      * @return CDbCommandBuilder the command builder used by this AR
#7	
–  /home/user/src/yii/framework/db/ar/CActiveRecord.php(1493): CActiveRecord->getTableSchema()
1488      */
1489     public function findByPk($pk,$condition='',$params=array())
1490     {
1491         Yii::trace(get_class($this).'.findByPk()','system.db.ar.CActiveRecord');
1492         $prefix=$this->getTableAlias(true).'.';
1493         $criteria=$this->getCommandBuilder()->createPkCriteria($this->getTableSchema(),$pk,$condition,$params,$prefix);
1494         return $this->query($criteria);
1495     }
1496 
1497     /**
1498      * Finds all active records with the specified primary keys.
#8	
–  /home/user/work/arrest/front/test.php(22): CActiveRecord->findByPk(1)
17 
18 $command = Yii::app()->db->createCommand("create table test (id number, col varchar2(1), constraint id_pk primary key (id))");
19 $command->execute();
20 $command = Yii::app()->db->createCommand("insert into test values (1, '1')");
21 $command->execute();
22 var_dump(Test::Model()->findByPk(1));
2022-12-08 14:54:03 Apache/2.4.52 (Ubuntu) Yii Framework/1.1.28-dev

Actually I ve already fixed it in a fork.

And slightly optimized the query. But now struggling to run unit test on phpunit v9.5.10:

phpunit framework                                                                      ↑
PHP Fatal error:  Declaration of CComponentTest::setUp() must be compatible with PHPUnit\Framework\TestCase::setUp(): vo
id in /home/user/src/yii/tests/framework/base/CComponentTest.php on line 23
PHP Stack trace:
PHP   1. {main}() /usr/bin/phpunit:0
PHP   2. PHPUnit\TextUI\Command::main($exit = *uninitialized*) /usr/bin/phpunit:73
PHP   3. PHPUnit\TextUI\Command->run($argv = [0 => '/usr/bin/phpunit', 1 => 'framework'], $exit = TRUE) /usr/share/php/P
HPUnit/TextUI/Command.php:96
PHP   4. PHPUnit\Runner\BaseTestRunner->getTest($suiteClassFile = '/home/user/src/yii/tests/framework', $suffixes
= [0 => 'Test.php', 1 => '.phpt']) /usr/share/php/PHPUnit/TextUI/Command.php:120
PHP   5. PHPUnit\Framework\TestSuite->addTestFiles($fileNames = [0 => 

Apparently this also needs a little php compatibility updates

Created at 2 hours ago
Created at 4 hours ago