⬆️ ⬇️

Yii 1.1.14 RC

Released release candidate for PHP framework Yii 1.1.14. You can pick it up from github .



Fixed more than 80 bugs, added more than 60 small improvements and new features. There is a new class

CPasswordHelper , which provides a reliable method for storing and verifying password hashes. Also added CRedisCache ,

with which you can use Redis for cache storage. Yii can be set as

Composer package . Full list of changes given

in changelog .



Much of the changes were made by community members: creocoder , tom--, paystey, Ragazzo, antoncpu, Yiivgeny, and others,

for which many thanks to them.

')

Since this is a release candidate (RC), you should not use it on combat servers. Stable release 1.1.14 will be available in

for several weeks, but for now we will be very grateful if you check the RC and

let us know about errors . Thank you in advance.



Well, now consider the major improvements.







New class CPasswordHelper





CPasswordHelper provides a reliable method for storing and verifying password hashes. Using it is very simple:



 //  ,      . $password     $hash = CPasswordHelper::hashPassword($password); // $hash —  ,     , $password     if (CPasswordHelper::verifyPassword($password, $hash) //   else //   




New method CDbCommandBuilder::createMultipleInsertCommand()





Using CDbCommandBuilder::createMultipleInsertCommand() it became possible to insert several records in one request:



 $builder=Yii::app()->db->schema->commandBuilder; $command=$builder->createMultipleInsertCommand('tbl_post', array( array('title' => 'record 1', 'text' => 'text1'), array('title' => 'record 2', 'text' => 'text2'), )); $command->execute(); 




CRedisCache





Now the application can be configured to store the cache in Redis. Done via `protected / config / main.php`:



 array( // ... 'components'=>array( 'cache'=>array( 'class'=>'CRedisCache', 'hostname'=>'localhost', 'port'=>6379, 'database'=>0, ), ), ) 




Installing Yii as a Composer package :





Yii can now be installed via Composer . For this you need to add

following in composer.json .



 "yiisoft/yii": "dev-master" 




Automatic user logout after a certain time





If you need the user to log out after a strictly defined time, regardless of his activity, do so.

can be so:



  // ... 'components'=>array( 'user'=>array( // ... 'absoluteAuthTimeout' => 60*60*24; ), ), ) 




RANGE support when uploading files





When using CHttpRequest::sendFile Yii now correctly responds to RANGE requests, that is, the end user

gets more speed when downloading in multiple streams.



Using through with BELONGS_TO





The “through” option can now be used with CActiveRecord::BELONGS_TO . More about this

written in the full manual .



Selective logging of global variables





CLogFilter::$logVars now accepts an array of arrays in which you can specify what to log from $GLOBALS :



  'components'=>array( 'log'=>array( 'class'=>'CLogRouter', 'routes'=>array( array( 'class'=>'system.logging.CWebLogRoute', 'filter'=>array( 'class'=>'system.logging.CLogFilter', 'logVars'=>array( '_COOKIE', //  , < 1.1.14 array('_SERVER','REMOTE_ADDR'), //  , >= 1.1.14 array('_SERVER','HTTP_USER_AGENT'), //  , >= 1.1.14 ), ), ), ), ), ), 




The above configuration will log the following:



 $_COOKIE=array ( '__utma' => '111872281.473431406.1366046648.1366046648.1366046648.1', '__utmz' => '111872281.1366046648.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)', 'cartVisible' => '1', '96ab4aec0c2977c9b793d4ba009eb3ce' => '...', 'PHPSESSID' => 'vb8pk7obs3q2lc7bl8ield7si7', ) $_SERVER.REMOTE_ADDR='::1' $_SERVER.HTTP_USER_AGENT='Mozilla/5.0 (Windows NT 6.1; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0' 




New CLocalizedFormatter





The new CLocalizedFormatter class allows CLocalizedFormatter to format values ​​according to the current locale:



 'components'=>array( 'format'=>array( 'class'=>'system.utils.CLocalizedFormatter', 'locale'=>'en_US', ), 'germanFormat'=>array( 'class'=>'system.utils.CLocalizedFormatter', 'locale'=>'de_DE', ), 'russianFormat'=>array( 'class'=>'system.utils.CLocalizedFormatter', 'locale'=>'ru_RU', ), ), 




 echo Yii::app()->format->formatDatetime(time()) . "\n"; echo Yii::app()->germanFormat->formatDatetime(time()) . "\n"; echo Yii::app()->russianFormat->formatDatetime(time()) . "\n"; // Jul 7, 2013 9:34:56 PM // 07.07.2013 21:34:56 // 07.07.2013, 21:34:56 




Generation of field names from DB comments





Gii can now use table field comments as field names for the generated model. For example,

if the table is created as follows:



 CREATE TABLE `tbl_user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `first_name` varchar(100) NOT NULL COMMENT ':', `last_name` varchar(100) NOT NULL COMMENT 'Nachname:', `title` varchar(50) NOT NULL COMMENT 'Title (eg Mr., Mrs., etc.):', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1; 




The generated attributeLabels method will be as follows (if you select “Use Column Comments as Attribute Labels” in Gii):



 /** * @return array customized attribute labels (name=>label) */ public function attributeLabels() { return array( 'id' => 'ID', 'first_name' => ':', 'last_name' => 'Nachname:', 'title' => 'Title (eg Mr., Mrs., etc.):', ); } 




New methods in CSecurityManager





Added to CSecurityManager :



* CSecurityManager::generateSessionRandomBlock() : generates a random byte sequence based on the current session

user

* CSecurityManager::generatePseudoRandomBlock() : an improved alternative to mt_rand() .

* CSecurityManager::generateRandomBytes() : generates random binary data. Crypt resistance is set second

by argument. It is worth noting that the generation is rather slow.

* CSecurityManager::generateRandomString() : generates a random string. Crypto resistance is given by the second argument.

It is worth noting that the generation is rather slow.

Source: https://habr.com/ru/post/186596/



All Articles