Recently, the first release of the 6.x branch was released, which means that in addition to the rejected backwards compatibility, there are also innovations that I would like to talk about.
Previous changes: part 1 , part 2 , part 3 , part 4 , part 5 .
In general, each new release simplifies the framework itself, minor features are removed (they can be implemented without interfering with the framework core), new ones appear, and those that remain are polished.
It is also becoming increasingly important to give the developer the opportunity to abandon the built-in functionality that can lead to overheads. This allows you to speed up the development at the expense of suitable built-in functionality, but at the same time not incur the inevitable overhead for what is not used.
Even in versions 5.x, the work with the multi-lingual interface became asynchronous. At 6.x, translation downloads became asynchronous, as well as the connection of the sprintf.js library.
In general, this means two things:
This means that if you do not need support for web components and you will not use translations in the frontend, then the overhead framework (at the time of release) in production:
This is quite a bit (almost half of this volume is occupied by Alameda, the modern version of RequireJS).
But even this is not the limit, in the near future I plan to write an article on how statics caching in the framework works, there will be information on how you can give up 100% of the framework's frontend in production, how to integrate your build system if you wish, and so on ( so far you can read a new page of documentation ).
On the front end, the performance of system events has been improved, and, more importantly, translation downloads.
The fact is that translations on the frontend can be used either as strings or as methods. In the second case, you can pass some arguments and get a formatted string with the given parameters:
cs.Language('system_profile_').ready().then(function (L) { console.log(L.hello('Guest')); // , Guest! });
At the same time, several new functions were created for each key in the translations. This is not a problem if there are only a few keys, but when there are several hundred of them, this is noticeable.
As a result of refactoring, it was possible to reduce the number of created functions to one per key.
The performance of some commonly used user elements is also improved.
cs-icon
sometimes has more than a hundred copies on a page, so its speed is very important, in recent versions (starting with the latest 5.x) it supports from 1 to 2 icons (earlier it was possible more) and renders them much faster, avoiding adding / delete items in its shadow tree.
MySQL is forced into strict mode. This avoids a number of unpleasant problems, including security issues.
As a result of the inclusion of strict mode, several minor problems were found, now they are fixed and covered with tests.
Continuing the topic of security - the implementation of the xap()
function used everywhere to clear input data has been rewritten and is now based on HTML Purifier. Now this function is truly safe, it used to be the same as it turned out.
In multilingual configurations, this treit did not always correctly search. The search could not take into account the multilingual parameters when searching and sorting data by its own fields of the table, now its own fields, and the fields of the related tables are always taken into account correctly.
Also, a search in a multilingual configuration now always uses the current system language, and does not allow to specify it as a parameter (otherwise, sometimes it was not strange docking that turned out when the main table uses one language, but related another).
System classes actively use traits, but in some cases loading traits may not be very rational (for example, a trait involved in building a static cache is not needed when processing API requests).
Now a number of system traits have been refactored into independent classes, which are loaded only when they are really needed.
A number of small optimizations found during profiling were also made. For example, on the server, a significant percentage of the execution time was taken by loading translations from the cache (in fact, JSON deserialization), which was not always used for query APIs and with multilingual support turned off. In such scenarios, translation downloads no longer occur, it is delayed until real use.
Now, under the usual Apache2 + PHP7, the rendering time of a simple page starts from 0.8 ms, that is 0.0008 s, which was previously possible only under HHVM.
The framework no longer supports Internet Explorer, basic IE11 support is available in the Old IE module, IE10 is not supported at all.
In the next major version, most likely, IE11 will also be dropped, and the last 2 stable versions of Edge will be supported, however, the same is true with all other major browsers (sometimes people remember Safari 5 on Windows, but this is no longer funny).
The polishing of the internal API of system objects continued.
You no longer need to use additional methods to store / retrieve some system configuration fields.
The supported fields themselves are now defined by the special class cs\Config\Options
(previously taken from the JSON file), which, in addition to the field name and default values, also returns additional metadata, which, in principle, is enough to automatically build the UI, which in Future versions will be used to fully manage the system configuration via the CLI interface.
Fixed the order of calls to initialization methods and constructor in cs\Singleton
, which caused some problems when working in HTTP server mode.
Historically, the use of includes
renamed to assets
(this resulted in the renaming of directories for the entire project), which is a much more common name.
On this wave, the static structure was transferred from a separate includes/map.json
to the assets
key of a shared file with meta-information of the meta.json
module, which stores information on supported languages, databases, dependencies and other details.
Another great renaming steel engines. Different implementations of working with cache, database and storage were called engines, while in the connection parameters to the database one could see the type of database ( type
), and such connections were found in the repositories.
All of this is now consistently referred to as drivers
/ driver
so as not to confuse anyone (including himself) with confusion.
From early alpha versions to the last release, the framework had two mechanisms for blocking users:
Both of these locks were primitive in secondary, and therefore removed. For the second blocking, several system events appeared that allow you to return this functionality, and even more, with the help of third-party modules.
The blog module has added support for SQLite in the blog module.
A patch has been added over the already used wp-cli/wp-cli-tools
package that implements an HTML-like syntax for formatting answers in the CLI interface (designed in the form of PR 100 , but somehow the developers did not rush to accept the patch, I decided not to wait any longer).
The patch allows instead of:
%gCleverStyle Framework%n version %y$version%n, CLI interface
Write this:
<g>CleverStyle Framework</g> version <y>$version</y>, CLI interface
And even nested tags are supported, which is very painful to do without this patch.
When using server-prepared expressions, you can now pass more parameters than you need, the extra ones will be discarded. Sometimes it is convenient.
Added support for the template string from ES2015 to the JS minifiers (if you suddenly use this without conversion to ES5).
Translations are uploaded to the Transifex service , which should simplify translation into other languages ​​that I myself do not know :)
There are a lot more tests, they are much better and cover much of the code.
All system classes are covered with tests, the majority is 100%, many are 98-99%, some very slightly less.
Coverage of controllers began - the controllers responsible for user login / logout, password change / reset, user profile settings were covered first.
The real coverage is even more, because the APC cache driver is not tested (it runs in Travis CI, but I don’t have it locally), also in some packages build and installation tests, test coverage is disabled due to a bug in Xdebug , but the tests themselves chased away.
The quality of the code according to Scrutinizer has significantly increased (not only the kernel code, but all modules in the repository are taken into account), almost 75% of the code has an A / B rating and there is no code with F rating:
Always glad to new ideas and constructive comments.
» GitHub repository
Source: https://habr.com/ru/post/312164/
All Articles