📜 ⬆️ ⬇️

Yii 1.1.11

The PHP framework framework Yii released version 1.1.11, which includes more than one hundred improvements and bugfixes.

This release is special because it is the first since the code Yii migrated to GitHub . The community took the migration very well and put it in full , sending in the form of a pull-request new features, fixes, unit tests and translations.

For all this, many thanks! Especially note: resurtm , DaSourcerer , cebe and suralc .
')
You can see the list of changes and new features . If you plan to upgrade, carefully read the instructions .

After the release, there were some unpleasant errors . We work.


Well, now consider some of the changes.



HTML5 field support in CHtml



Added new methods to CHtml :



Use this:

 echo CHtml::activeNumberField($model, 'fieldName'); 


CFormatter::formatSize()



A new method that allows you to get a normally readable size of the size in bytes:

 echo Yii::app()->format->formatSize(115969); // : 113.25 KB 


Console Return Codes



Now you can return the integer from the action of the console application. The value will be used as a return code.

Read more in the manual.

CJavaScript::encode() and js:



If you used CJavaScript::encode() and took a value from a form or URL, your application is most likely vulnerable. To close the vulnerability, you need to pass the second parameter true :

 CJavaScript::encode($userInput, true); 


The parameter prohibits the use of the js: prefix. If you still need to pass a JavaScript expression, frame it with CJavaScriptExpression :

 CJavaScript::encode(new CJavaScriptExpression('alert("Yii!");'), true); 


The second parameter ( safe ) does not affect the behavior of CJavaScriptExpression .

HTTP caching



In addition to the usual page caching, you can use CHttpCacheFilter in the new version. This filter sends HTTP headers that make it clear to the client that the content of the page has not changed since the last request. In this case, the server does not need to re-send the content. CHttpCacheFilter is configured as well as COutputCache:

 public function filters() { return array( array( 'CHttpCacheFilter + index', 'lastModified'=>Yii::app()->db->createCommand("SELECT MAX(`update_time`) FROM {{post}}")->queryScalar(), ), ); } 


Read more in the manual.

Elimination of model validation rules



If you do not want to use one of the rules for validation when a particular script is active, you can now specify the except parameter that contains a list of scripts. The syntax is the same as on :

 //     ( ) array('username', 'required', 'except'=>'ignore, this, scenarios, at-all',) 


Read more in the manual.

New toolkit and documentation for translators



New documentation sets the workflow for translation using github. Tools allow you to get all the changes made since the last update of the translation. We hope that this will help keep translations of documentation up to date.

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


All Articles