📜 ⬆️ ⬇️

Changes in Kohana 3.2 in Russian

Today at Habré there was already a message that the release of Kohana 3.2 was released. I decided to transfer the information about the changes associated with this release to the best of my time. The description contains information about the most, in my opinion, significant changes.



Podaluysta, do not judge strictly for clumsiness in some places.
')

Core


# 4105 - Updated documentation Kohana_Valid :: exact_length

Previously, the documentation for this method said that this method only accepts an integer as the $ length parameter, whereas since the version of Kohana 3.2 it can accept an array of integers.

# 4089 - Updated migration documentation for new version of Kohana


# 4083 - Assembly file: phpcs no longer checks unit test coding standards

Previously, when you wrote unit tests, phpcs also checked them for compliance with Kohana Coding Standards. What caused a storm of rays of hatred against the developers of Kohana. Now the rays will be significantly less.

# 4068 - Added $ keys parameter to Arr :: map () method - now you can force it to “walk” only by specified keys


# 4066 - Fixed jamb in ORM method :: with ()

For example, this design:
ORM::factory('blog')->with('category')->find_all() 

here such request:
 SELECT `category`.`id` AS `category:id`, `category`.`name` AS `category:name`, `blogs`.* FROM `blogs` LEFT JOIN `categories` AS `category` ON (`category`.`id` = `blogs`.`category_id`) 

But now everything is ok.

# 4062 - Added method Validation :: data (), instead of method Validation :: as_array (), which will then be deleted

The Validation :: as_array () method is outdated and will be deleted later. Who cares why - follow the link .

# 4034 - Validation object no longer needs inheritance ArrayObject

This is all one field of berries - read a little higher.

# 4011 - Valid :: email () is more compliant with RFC, now email cannot be longer than 254 characters


# 4009 - Refactoring and optimization of HTTP_Header and HTTP_Header_Value classes


# 3993 - If you do not specify parameters in the Form :: open () method or use NULL as the first parameter, this will create a form with an empty action

Accordingly, the browser instead of action itself will substitute the current URI.

# 3992 - Request :: body () can accept file or resource pointers as an input parameter

This allows you to send files directly to the browser without having to read their contents into memory.

# 3974 - Added method Route :: defaults (), which returns the value Route :: $ _ defaults


# 3944 - The Request :: send_headers () method is deleted because he duplicated the Response :: send_headers () method


# 3942 - Standard Controllers Controller_Template and Controller_Rest now call parent :: before () before any manipulations


# 3929 - Kohana_Exception now supports more than integer error codes


# 3909 - Added recursive display of values ​​in Debug :: dump ()


# 3893 - In the Html :: anchor () method, by default, the parameter is now $ index = TRUE


# 3881 - Valid :: decimal () now supports negative values


# 3796 - Added support for aliases as callback functions in models

For example, now you can do it like this in the model:

 public $_rules = array ( 'fieldy' => array ( array('not_empty'), array('min_length', array(':value', 6)), array(array(':model', 'check_fieldy')), ), ); public function check_fieldy($value) { ... } 

And so in the controller:
 $validation->bind(':model', $model) ->rules('fieldy', $model->_rules['fieldy']); 


# 3765 - Eliminate confusion over exception names

For example, it used to be like this: Http_Exception, Validation_Exception, Database_Exception. But on the other hand, it was like this: Kohana_View_Exception, Kohana_Request_Exception, Kohana_Cache_Exception. This made confusion and ferment the minds.
Now View_Exception inherits Kohana_View exception, and the View class throws View_Exception, not Kohana_View_Exception, and so on.

# 3758 - Minor Request Class Changes

See also # 3648 .

# 3690 - Fixed Request :: uri () method


# 3655 - The mechanism for obfuscation of email addresses is complicated


# 3566 - Small changes in constants for the parameter Kohana :: $ environment


# 3558 - Request :: $ client_ip now contains an array of IP addresses

This is due to the fact that the X-Forwarded-For server parameter can contain multiple IP addresses.

# 3554 - Response object now contains information on whether it was generated for profit or taken from cache

See parameter Response :: cache ().

# 3536 - Removed support for parameters in controller methods

It is now recommended in controllers to use the $ this-> request-> param () construct instead of getting parameters from a controller method of type action_foobar ($ id).

# 3493 - Removed Request_Client_External interface

This is done so that we can organize support for various drivers - Curl, PECL HTTP and “native”.

# 3492 - Caching in Request_Client

In order to organize coherent logic, the Request_Client class now uses an adapter for caching.

# 3439 - A “takeaway” of routes from bootstrap.php is now considered a good tone.


# 3427 - Improved email validation

There should be no port entry in the email address.

# 3424 - Validate :: exact_length () method can now accept an array as the second parameter


# 3381 - Arr :: map () can now accept an array of callbacks

For example, this is how it can work:
 $var = Arr::map(array('UTF8::trim','HTML::strip','whatever'), $var); 


# 3367 - UTF8 helper functions now throw exceptions instead of using trigger_error


# 3183 - Kohana :: modules () now throws an exception if you are trying to initialize a non-existent module


# 3159 - Session corrupt - added more grace


# 3100 - Fixed problem of inability to start a new session immediately after deleting the current one


# 3000 - Changed system for working with configs

Now configs can not only “read”, but also “write”. The downside is that the syntax has changed:

 $reader = new Kohana_Config_Reader; $reader->load('alcohol', array('beer' => '1664', 'stout' => 'Guinness')); 


I advise you to pay more attention to this.

# 2687 - Separation of Request and Response classes

As said - to better support the HMVC paradigm.

# 2672 - Request now supports caching


# 2484 - Fixed bugs in Kohana_Controller_REST


# 2398 - The exceptions thrown during AJAX requests no longer contain HTML markup


Auth


# 3805 - Added session_type / driver parameter to config

Now you can separately configure the database connection instance for storing sessions.

# 3605 - AUTH :: login () no longer hashes the password on its own

This was caused due to difficulties in writing third-party drivers for user authentication. For example, drivers for LDAP authentication. For more details, click here .

Cache


# 4027 - xCache and Eaccelerator are no longer supported.


# 4023 - Support basic arithmetic

An interface has been added to support basic arithmetic operations in caching systems.

# 3275 - Fixed a bug where the file cacher did not correctly save data if it was not in UTF8


# 2819 - Unit tests added


Database


# 4103 - Non-friendly query optimization for MySQL driver

More details - by reference . Although everything is ingenious and simple, nonetheless.

# 3735 - Query constructors now support zeroing LIMIT, OFFSET and SELECT parameters

The update is due to the fact that the count_last_query () support has been removed from the functionality. Read more - in patches.

# 3502 - Added support for native PDO-shny getters and setters


# 3429 - DB :: expr () can now accept parameters

Now you can do this:

 DB::expr('CONCAT(?,?,?)', array($column, $literal, $column)); 


# 3329 - Added sql_mode parameter to config

Now, for example, you can set the STRICT_TRANS_TABLES mode for the MySQL connection, which will strictly process various errors that it did not react to in normal mode (for example, in normal mode, you can insert very long text in the VARCHAR field it will simply be “cut off”, in strict mode it will not succeed - an error will be generated).

# 3227 - Added the ability to return the result of the query as an object to the $ db-> execute () method


# 2760 - Improved query caching mechanism

 //    ,      DB::Query(Database::SELECT, $sql)->cached(null,false)->execute(); //    ,   ... ,    ,      DB::Query(Database::SELECT, $sql)->cached(60,false)->execute(); //    -     ,    .   -     ,   . DB::Query(Database::SELECT, $sql)->cached(60,true)->execute(); //   ,      (   ).   -    . DB::Query(Database::SELECT, $sql)->cached(null,true)->execute(); 


Image


# 3568 - Added ability to save image without extension


# 3563 - Image :: valid () static function for image validation

Check function - is the image loaded? Uses getimagesize () .

# 2246 - Added ImageMagick driver

Finally!

ORM


# 4094 - Added ORM method :: primary_val ()


# 4091 - Minor improvements

And a little more here .

# 4074 - ORM :: __ call () is no longer used


# 4059 - Fixed bug with param () method


# 4058 - In the model, you can now set an error message file


# 4028 - Improving the performance of the method ORM :: as_array ()


# 3906 - Improved model logic: states loaded, saved and changed


# 3880 - All sorts of buns in validation of several models at once


# 3877 - Removed directories from paths to messadzham


# 3823 - Added ORM method: unique ()


# 3706 - Improved functionality of the ORM :: has () method


# 3692 - Added ORM method :: changed ()


# 3691 - Added aliases: original_value and: changed to the ORM_Validation class


# 3174 - Data serialization support in ORM

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


All Articles