Nette Framework 2.4 released

about a year ago

David Grudl
founder | 6692
+
+46
-

A time to celebrate, 2.4 is out! It has a lot of enhancements in every part of framework.

Note that dependencies in composer.json has been relaxed to ^2.4, so ZIP packages are now distinguished by date instead of patch version. Hence this release is “2.4 2016–06–30” instead of 2.4.0.

For the details you can have a look at the Application 2.4.0, Bootstrap 2.4.0, Caching 2.5.0, Component Model 2.3.0, Database 2.4.0, DI 2.4.0, Finder 2.4.0, Forms 2.4.0, Http 2.4.0, Latte 2.4.0, Mail 2.4.0, Neon 2.4.0, Php Generator 2.4.0, Reflection 2.4.0, Robot Loader 2.4.0, Security 2.4.0, Tracy 2.4.0, Utils 2.4.0

Application

  • PresenterComponent, Form: added $onAnchor
  • Route, SimpleRouter: by default keeps the currently used HTTP/HTTPS protocol (BC break) nette/nette#1196 nette/routing#14
  • Route: added support for scheme:// in mask
  • Route: add %host% variable
  • Route: Added variable for domain second level name (%sld%)
  • Route: support for optional [<module>]
  • RouteList: added warmupCache()
  • PresenterFactory: added possibility to configure mapping via array
  • PresenterComponent: added redirectPermanent()
  • Presenter: support for direct setting layout file
  • Presenter: don't mix GET & POST params in AJAX when form is submitted nette/forms#33 nette/nette#1061
  • Snippets: do not render snippets from a template which is included using includeblock macro
  • JsonResponse: sends utf-8 charset
  • UIMacros: {control} wrap arguments in array only when needed nette/nette#1206

deprecated, changed:

  • Presenter: argsToParams() and saveState() now distinguish between NULL and FALSE
  • PresenterComponentReflection::convertType() objects can be passed only to parameters without array or scalar type (without array / scalar default value) (BC break)
  • Form: uses underscored signal parameter _do only in POST forms
  • IRouter::SECURED is deprecated
  • Router::$defaultFlags and flag SECURED are deprecated nette/routing#13
  • PresenterComponent ⇒ Component
  • PresenterComponentReflection ⇒ ComponentReflection
  • Control::validateControl() & invalidateControl(), Presenter::backlink() and Template::registerHelper() trigger E_USER_DEPRECATED
  • Presenter: triggers notice when payload is send via terminate()
  • UIMacros: uses Latte providers uiControl and uiPresenter instead of $_control and $_presenter
  • composer: removed dependency on nette/security

Bootstrap

  • Configurator: removed ReflectionExtension
  • Configurator: extracted loadContainer() from createContainer()
  • Configurator: warns when deprecated ‘nette’ section is used
  • Configurator: removed parameter ‘environment’ (BC break)
  • Configurator: removed parameter ‘container’ (BC break)
  • Configurator::addConfig() sections are deprecated (BC break)

Caching

  • added bulk read support
  • removed FileJournal (note that successor SQLiteJournal requires pdo-sqlite extension)
  • CacheMacro: compatibility with Latte 2.4, uses Latte provider ‘cacheStorage’ (and ‘cacheStack’)
  • CacheMacro: improved dependency on files
  • added NewMemcachedStorage using memcached extension

Database

  • NDBT: Added alias support
  • NDBT: added new method whereOr
  • NDBT: Added ability to specify left join conditions
  • NDBT: performance, prevents multiple parse of query parts by regexp
  • NDBT: queries with limit/offset are automatically ordered by primary key
  • NDBT: page() for $page < 1 returns no rows
  • drivers: applyLimit throws exception for negative values (BC break)
  • Improved checking of unique table name
  • Helpers::detectType() uses more strict type patterns
  • SqlPreprocessor: detects modes inside SQL string, before ?
  • Selection: fixed columns cache in repeated use of same selection
  • SqlBuilder: The same conditions with different parameter is not skipped ,
  • PgSqlDriver::getTables() returns materialized views
  • SqlsrvDriver::formatDateTime(): format datetime by ISO 8601
  • Connection: fifth argument is deprecated

Dependency Injection

  • implemented Fine Grained Dependencies
  • new autowiring approach, option autowired can contain list of classes
  • added support for setup syntax $prop = value and '$prop[]' = value
  • Compiler: allows to overwrite single arguments
  • ContainerLoader::loadFile() invalidates opcache
  • ContainerBuilder: split into ContainerBuilder and PhpGenerator
  • DIExtension: debugger is enabled by default
  • Compiler::parseServices: added @extension syntax for referencing services from a same extension
  • Compiler: support for removing services via ‘name: no’

deprecated, changed:

  • Compiler: parseServices() and parseService() renamed to loadDefinition() and loadDefinitions()
  • di.accessors are deprecated
  • ServiceDefinition::setImplementType() and getImplementType() renamed to setImplementMode()getImplementMode()
  • ContainerLoader::load() swapped arguments (BC break)
  • ContainerBuilder: setClassName() & getClassName() moved to Compiler (BC break)
  • Statement::setEntity() is deprecated
  • Compiler: option ‘run’ is deprecated, should be used as tag
  • Compiler: deprecated section inheritance child < parent (BC break)

Forms

  • support for true optional controls via setRequired(FALSE) (BC break)
  • checks for missing setRequired(TRUE | FALSE)
  • Container: added addEmail() & addInteger()
  • Form: added isMethod(), beforeRender() & fireRenderEvents() and event $onRender
  • negative rules like ~$form::ABCD are deprecated. (Negatives for FILLED & EQUAL are BLANK & NOT_EQUAL)
  • controls: getOption(‘type’) for distinguishing between them
  • TextInput: validators EMAIL, URL, INTEGER automatically sets type to ‘email’, ‘url’ or ‘number’ (BC break)
  • SelectBox, MultiSelectBox: added addOptionAttributes()
  • SelectBox: added isOk()
  • UploadControl: when file is uploaded with error, automatically shows error and isFilled() returns TRUE (BC break)
  • UploadControl: added isOK()
  • CheckboxList: added containerPrototype
  • DefaultFormRenderer: adds class ‘text’ to input types ‘email’ and ‘number’ (for back compatibility after 72127b1e)
  • DefaultFormRenderer: wrapper for hidden fields changed from <div> to none
  • Form::addProtection() is always the first item
  • TextBase: added setNullable()
  • added BaseControl::enableAutoOptionalMode()

netteForms.js:

  • ability to show all error messages at once via Nette.showFormErrors()
  • displays all errors at once
  • removed support for IE =< 7
  • toggle handlers are added on body, uses addEventListener or attachEvent
  • forms are initialized on DOMContentLoaded instead of onload

Forms & Latte:

  • {label} is AUTO_EMPTY
  • <tag n:name> always uses getControlPart() and getLabelPart(), removed method_exists checking (BC break)
  • local $_form replaced with global $this->global->formsCurrent so it is not needed to pass $_form to included templates

HTTP

  • Implemented RFC 7239 – “Forwarded HTTP Extension”
  • Session: fixed error “Session object destruction failed”
  • RequestFactory: removes absolute URI from $_SERVER[‘REQUEST_URI’]
  • RequestFactory: correctly detects scheme and port if the server is behind a trusted proxy
  • IRequest: added OPTIONS and PATCH method constant
  • Response: do not send “Possible problem notice in CLI”
  • Response::setExpiration() removes header Pragma
  • RequestFactory: Fixed possible remoteAddr spoofing
  • FileUpload::move() do not suppress system warnings
  • HttpExtension, SessionExtension: added parameter $cliMode
  • Url: implements JsonSerializable nette/latte#78
  • HttpExtension: service http.context is deprecated
  • Session: use better detection for started session

Latte

  • requires PHP 5.4
  • generates pretty PHP code
  • implemented content type aware filters (triggers warning when mixing blocks/files in different contexts)
  • Implemented inline filters ($var|modifiers)
  • added operator in: $entry in [item1, item2]
  • {define} accepts parameters
  • added macro {import 'file'}
  • added macro {spaceless}
  • implemented {while} ... {/while $cond}
  • extremely fast filters
  • added |stripHtml
  • added |linebreaks
  • added |length for strings, arrays, Countable and Iterator
  • {syntax off} can be ended with {/syntax}
  • added Engine::addProvider(), runtime dependencies and options for macros
  • added SnippetDriver & ISnippetBridge, snippet refactoring
  • supports new operators <=> ** ...
  • {contentType} do not send header when is rendered to string or included
  • {capture} creates Latte\Runtime\Html in HTML content type (BC break)
  • new flags IMacro::AUTO_EMPTY and IMacro::AUTO_CLOSE
  • StringLoader: accepts array of strings
  • added |checkurl & |nocheck as aliases for |safeurl & |nosafeurl
  • added MacroNode::$innerContent nette/nette#1361
  • Engine::loadTemplate() invalidates opcode cache
  • Parser: exception ‘Template is not valid UTF-8 stream’ provides line number

deprecated, changed:

  • inline PHP <? ... ?> is deprecated
  • {includeblock} is deprecated
  • {? ...} is replaced with {php ...}
  • {use} and {status} are deprecated
  • |nl2br is deprecated
  • BlockMacros: <tag> in {snippet} is deprecated
  • {include |escape} and {block |escape} trigger warning about auto-escaping
  • {contentType} is allowed only in template header and in <script>
  • Latte\Template ⇒ Latte\Runtime\Template
  • Engine::getFilters() returns only name of filters
  • added ILoader::getUniqueId(), changed interface
  • MacroNode, HtmlNode: $isEmpty replaced with $empty
  • ILoader::getChildName()getReferredName() BC break, changed interface
  • uses $global accumulator instead of $_l and $_g
  • variable $template is deprecated
  • PhpWriter: deprecated support for constant names without underscore
  • Parser: removed support for ASP & Python syntax (BC break)

Mail

  • Message::setHtmlBody() added new syntax for embedded files [[image.gif]]
  • added FallbackMailer
  • Message: added addInlinePart()
  • SmtpMailer: allow set stream context

Neon

  • added support for multilines strings nette/nette#1375
  • Decoder: added support for octal 0o777 and binary 0b11001 numbers
  • Decoder: generates DateTimeImmutable instead of DateTime (BC break)
  • Decoder: refactoring, added some constants

Php Generator

  • deprecated addDocument(), setDocuments() and getDocuments() and replaced with addComment(), setComment() and getComment()

Tracy

  • requires PHP 5.4.4 or newer
  • Bar & BlueScreen: displays AJAX requests
  • saving & restoring of toggles
  • Bar: is loaded in separated HTTP requests
  • Bar: info bar show HTTP method & response code
  • Bar: panel height fits to the viewport
  • Bar: automatic labels hiding to conserve space
  • Bar: lazy rendering of panels
  • BlueScreen: added $maxDepth & $maxLength
  • BlueScreen: added panel with last muted error
  • BlueScreen: added renderToFile()
  • Bluescreen: rel=noopener for target=_blank
  • Debugger: added $editorMapping support
  • Debugger::$maxLen ⇒ $maxLength
  • Debugger::dispatch() starts session if is not started
  • Debugger: error exit code changed from 254 to 255 to be the same as native error code
  • added function bdump()
  • Helpers::getSource: shows PID in CLI logs
  • Tracy requires IE11+

Utils

  • added trait Nette\SmartObject, it differs from Nette\Object:
    • magic properties without @property annotation are deprecated
    • accessing methods as properties is deprecated
    • extension methods are deprecated
    • magic @methods are deprecated
    • getReflection is deprecated
    • invoking closure in property is deprecated
  • added trait Nette\StaticClass
  • Html: renamed add() to addHtml(); added addText()
  • Html: deprecated “expanded” attribute data
  • Html: added attribute public accessor methods
  • Image::place() preserves the alpha channel
  • Strings::random() renamed to Random::generate()
  • Random: uses random_bytes() on PHP 7
  • FileSystem: added read()
  • ArrayList: added prepend()
  • Json::encode() uses by default JSON_PRESERVE_ZERO_FRACTION (BC break)
  • DateTime: implements JsonSerializable, formats date in ISO 8601 format accepted by JavaScript's Date object (BC break)
  • Filter & RecursiveFilter are deprecated