Kirby v3.4.0 Release Notes

Release Date: 2020-07-07 // almost 4 years ago
  • πŸ†• New Features

    🍱 Search for files in the Panel πŸŽ‰

    Our global search in the Panel now also searches for files.

    Screen-Recording-2020-06-30-at-15 26 36

    Extensible search

    The Panel search is now also a core component and can be overwritten with your own search logic (#2368):

    Kirby::plugin('distantnative/fuzzy-search', ['components' =\> [ 'search' =\> function (Kirby $kirby, Collection $collection, string $query = null, $params = []) { // ...return $collection; } ] ]);
    

    🍱 Big hook improvements & wildcard hooks πŸ”₯

    • Hook arguments are now named and magically provided as requested (like in controllers). So it's now possible to just request the arguments the hook needs and in any order. Arguments that are not available will be set to null.
    • Support for wildcard hooks (e.g. page.*:before or page.create:* or *.create:* – all variations are supported!) that will be triggered for all event actions of the given type.
    • πŸ†• New $event object provided as argument for all hooks that contains all information about the triggered event. The $event argument can be used instead of or in addition to the individual hook arguments.

      return ['hooks' => [ 'page.*:before' => function ($page, $event) { var_dump($page); // $pagevar_dump($event->name()); // 'page.create:before'var_dump($event->type()); // 'page'var_dump($event->action()); // 'create'var_dump($event->state()); // 'before'var_dump($event->page()); // $pagevar_dump($event->input()); // $input }] ];

    πŸ’₯ Breaking-changes:

    • ⚑️ The method signature of $app->apply() and $app->trigger() has changed. Instead of a list of arguments, they now receive an associative array with named arguments. $app->apply() now also requires a third argument that tells the method which argument should be modified by the hooks. As both methods are marked for internal use and also not very useful in sites, the only use-case for them so far was hooks defined in plugins. Plugin authors who depend on any of the two changed methods need to update their plugins to support the new signature.
    • πŸ”Œ As the hook arguments are now detected by name and not by order, any hooks that don't use the variable naming as documented in the reference will receive null for those arguments instead.

    πŸ”Œ Hook migration checker plugin

    πŸš€ @lukasbestle has developed a migration checker plugin to help check for broken hooks in your installations. You can find the plugin attached to this release (as an "Asset") or download it from GitHub Gist. Please place the PHP file in site/plugins/migration/index.php and visit any frontend page of your Kirby site to check if you need to migrate some of your hooks. Make sure to delete the plugin again after the migration.

    πŸ†• New Structure Field features

    Duplicate option

    Duplicate option
    0️⃣ Duplicating is enabled by default. To disable, use the following syntax:

    fields: addresses: type: structureduplicate: falsefields: ......
    

    Prepend new entries

    With the new prepend option for structure fields, you can now add new entries to the top of the list instead of the bottom (getkirby/ideas#203)

    fields: addresses: type: structureprepend: truefields: ......
    

    πŸ†• New confirmation dialog to revert unsaved changes

    To prevent that unsaved changes can be accidentally deleted with the click of a button, we introduced a new confirmation dialog:
    βͺ Revert unsaved changes

    πŸ‘Œ Support for parentheses in KirbyTags (finally!)

    You can finally write parentheses in KirbyTags. For example:

    (image: my-image.jpg caption: A nice picture (by Ansel Adams))
    

    A huge Thank-you to @afbora for his StackOverflow hunt in order to find a proper solution.

    πŸ†• New collection filters for dates

    There are now date-specific collection filters that can be used like this:

    $collection-\>filterBy('date', 'date \>=', 'today');
    

    βœ… The advantage of these filters is that all date formats that can be parsed by PHP are supported (both in the fields and in the test string).

    The added filters are:

    • date ==
    • date !=
    • date >
    • date >=
    • date <
    • date <=
    • date between (or date ..)

    This feature is built on top of our enhanced V::date() validator. You can now also do the following validations with it:

    V::date($dateA, '==', $dateB);V::date($dateA, '!=', $dateB);V::date($dateA, '\>', $dateB);V::date($dateA, '\>=', $dateB);V::date($dateA, '\<', $dateB);V::date($dateA, '\<=', $dateB);
    

    πŸ‘ $kirby->impersonate(): Support for action function

    It is now possible to pass an action function to $kirby->impersonate(), which will run with the permissions of the impersonated user. The impersonated user is reset after the function has returned:

    $result = $kirby-\>impersonate('kirby', function ($user) { // $this is the $kirby object$email = $user-\>email(); // '[email protected]'return 'this will be returned to $result above'; });
    

    πŸ†• New files.read permission

    It is now possible to hide files of a specific template from users with a specific role (or to hide files in general) (getkirby/ideas#554)

    πŸ†• New search settings for the multiselect field

    You can now fine-tune the search experience in multiselect fields. This is especially useful if you are providing long lists of options and the result list gets unusable.

    fields: categories: label: Categoriestype: multiselectsearch: # The search starts after entering at least 2 charactersmin: 2# The result list has a limit of 5 entries but can be expandeddisplay: 5options: panel: Paneltemplating: Templatingseo: SEOsecurity: Securityperformance: Performanceanalytics: Analyticsassets: Assetstext: Textforms: Formsutilities: Utilitiesintegrations: Integrationssocial: Social
    

    πŸ†• New callback method for fields

    It's sometimes useful to modify a field directly in a controller or template. This can now be done with the new callback field method.

    echo $page-\>title()-\>callback(function ($field) { $field-\>value = 'Title: ' . $field-\>value; return $field; });
    

    (getkirby/ideas#475)

    πŸ†• New global collectionMethods extension

    Kirby::plugin('your-name/collectionMethods', ['collectionMethods' =\> [ 'toCSV' =\> function () { // write some code to convert the entire // collection to CSV }] ]);
    

    πŸ”Œ The new toCSV method in this plugin example will now be available for all collections in Kirby (pages, files, users, etc.)
    (getkirby/ideas#352)

    πŸ†• New servers option

    πŸ‘ To overwrite Kirby's server check you can now set the servers option in your config. This can be used to run the Panel, even though the server setup might not officially be supported by us. It's at your own risk though.

    return ['servers' =\> ['apache', 'nginx', 'symfony'] ];
    

    πŸ†• New way to access native component handlers

    πŸ“œ When creating your own core components – to manipulate URLs, create thumbnails, parse markdown or more – you can now easily access the native behaviour of Kirby's components with the new $kirby->nativeComponent($componentName) method.

    Kirby::plugin('your-name/url-handler', ['components' =\> [ 'url' =\> function (Kirby $kirby, string $path = null, $options = null) { if (Str::startsWith($path, '@forum')) { return 'https://forum.mydomain.com/' . str\_replace('@forum/', '', $path); } return $kirby-\>nativeComponent('url')($kirby, $path, $options); }] ]);
    

    There's more…

    • πŸ†• New image: icon and image: false options for items in pages or files sections.
    • βž• Added support for embedding YouTube playlists in the youtube and video KirbyTags as well as in Html::youtube() and Html::video() (getkirby/ideas#532)
    • βž• Added support for YouTube options (customizable player) in the youtube and video KirbyTags as well as in Html::video() and Html::youtube() (getkirby/ideas#437)
    • πŸ‘ Form fields now support a simple string as validation rule.
    • πŸ”Œ Permissions: You can now set your own actions in user blueprints and use them in your plugins to check for custom permissions.
    • πŸ†• New Kirby\Data\Xml class and support for XML in Data::encode($data, 'xml') and Data::decode($xml, 'xml')
    • βž• Added .. as an alias for the between collection filter
    • πŸ†• New $page->go() method, which automatically triggers a redirect to the page.
    • πŸ†• New global $kirby->contentToken() method (getkirby/ideas#554)
    • More complex tokens for page drafts and media URLs with the new content.salt option (#2612, getkirby/ideas#554)
    • πŸ†• New F::loadOnce() method (#2394)
    • πŸ‘ F::load(): Support for data variables (#2394)
    • A::nest(): New $ignore parameter
    • πŸ”§ The Remote class can now be configured in your site config with the remote option array.
    • Collection: New case-sensitive mode for custom collections
    • πŸ†• New $allowImpersonation argument for $kirby->user() (#2616)
    • πŸ†• New $props argument for Response::file() & Response::download() to support overrides (e.g. for headers)
    • System: The version and license key are now only available for authenticated users (with permissions if necessary)
    • πŸ†• New $lazy argument for App::instance(). This allows getting the app instance only if the app is already initialized.
    • πŸ‘ modified() methods now support specifying language for file, page and user models:

      $page->modified('c', 'date', 'de');

    • πŸ”Œ Kirby now accepts custom plugin types. This can be used to create plugins for plugins. E.g. the block plugins for the editor. (#2443)

    ✨ Enhancements

    πŸ”¨ Refactored Html and Xml classes

    • Made relevant methods from the Kirby\Toolkit\Html class available in the Kirby\Toolkit\Xml class
    • πŸ”¨ Full refactoring of the Html and Xml classes including tests with 100 % code coverage
      • Improve reliability and consistency of XML parsing and creation (the previous implementation lacked many features and didn't generate correct indentation)
      • Html now inherits from Xml to enable code sharing and access to the parsing and document creation methods in the Html class
      • Correct and improve information in doc blocks
      • Fix email and tel link generation in Html::a()
      • Html::email(): Fix link generation when called without text (the email address was previously not made the link text even though that is what was supposed to happen)
      • Html::tag(): Support for passing null as the $content to explicitly generate a void tag (was already documented like this but not supported)
      • Xml::value(): Proper CDATA support including edge-cases
      • Improve consistency of method arguments

    πŸ”¨ Refactored Database classes

    πŸ”‹ Features

    • πŸ‘ The $database->createTable() method now supports columns with a UNIQUE constraint
    • πŸ‘ The Db::column() and $query->column() database methods now support custom ORDER clauses so that you can order the results by any column and not just by the primary key
    • Database results can now be fetched using a custom callback:

      // prepare a query with the options you need$query = $database->table('simpsons')->fetch(function ($data, $key) { return new Simpson($data); });// this line now executes the query and returns an// array with the return values from your callback$results = $query->all();

    πŸ› Bug fixes

    • The creation of database tables with primary keys using $database->createTable() now works reliably with SQLite (#2234)
    • The Database fail mode is now no longer reset after each query, which makes it more predictable as you can't know how many queries an operation needs internally. You can now enable the fail mode once for the database connection and it will stay that way until it is manually disabled again.
    • Database: The insert ID is now only fetched from the database when an INSERT query was executed to improve compatibility with some database servers (#2347)
    • ⚑️ Database: The internal cache of valid table names is now immediately updated after tables are created or dropped, which enables further queries in the same request

    πŸ”¨ Refactoring

    • πŸ”¨ The Database\Db class and parts of the Database\Sql classes have been refactored, which has changed some internal method signatures.
    • πŸ”¨ We have added a lot of unit tests to the Database classes and will further refactor and improve the classes with 3.5.0.

    πŸ‘ Options: Full support for the dot notation

    πŸ”Œ Options for Kirby and for plugins can be defined as nested arrays or using the dot notation:

    return [// dot notation with a bit of nesting'superwoman.superplugin' =\> [ 'my.option' =\> 'with a value'], // nested arrays'superwoman' =\> ['superplugin' =\> [ 'my' =\> [ 'option' =\> 'with a value'] ] ], ];
    

    Both variants can now be used fully interchangeably and in any combination.

    πŸ’₯ Breaking-change:

    0️⃣ To ensure proper nesting, Kirby relies on the plugin option default values defined in the plugin using the options extension. If your plugin uses a nested structure in the option defaults, the defaults need to be changed to use the dot notation.

    πŸ”Œ Only options registered in that way can be set in all supported ways (dot notation, fully or partially nested) in the site config. You can read more about this in the reference.


    Whoops facelift

    Whoops


    More enhancements

    • Url::isAbsolute() now also checks for the geo protocol (#2536)
    • Cards: more sensible min-width for size: tiny.
    • You can now replace files with a different mime type but the same extension. (#2519)
    • The options API for fields (checkboxes, radio, multiselect, tags) now uses cURL instead of file_get_contents for enhanced reliability and better error handling (#2330)
    • πŸ‘Œ Improved error handling in our Exif camera class
    • πŸ‘Œ Improved performance of Page::find()
    • πŸ”¨ Refactored error handling with Whoops to handle errors more efficiently and earlier in the app flow.
    • The ready callback is now able to overwrite more options (whoops, debug, home, error, slugs)
    • πŸ‘Œ Improved I18n::translateCount() method (#2430 & #2431)
    • πŸ‘ Cookie: Support for SameSite cookies (#2601)
    • Session: SameSite=Lax for session cookies (#2601)
    • F::load(): Prevent overwriting $fallback (#2394)
    • πŸ‘ Query: Better error handling
    • πŸ‘ Query: Support quote escaping in strings
    • πŸ‘ Query: Full support for nested methods (#2511)
    • πŸ”€ Controller data is now merged safely with with original data (#2559)
    • Bubble up KirbyTag exceptions in debug mode (#2625)
    • βž• Additional Japanese slug rules
    • Field validation is now passed on empty fields (#2592)
    • πŸ“œ Markdown and SmartyPants parsers now accept empty/null values
    • The Remote class now checks for valid TLS certificates in case of HTTPS requests.
    • The Data::decode() and Data::encode() methods are now used throughout Kirby instead of i.e. Yaml::encode(). This allows to create your own data handlers and decoders, which will then be used everywhere.
    • ⚑️ Updated translations
    • ⚑️ Updated PHP version check: Kirby 3.4.0+ supports PHP 7.2 to 7.4. Versions below 7.2 or above 7.4 (= 7.5.0 or greater) are not supported.
    • πŸ‘Œ Improved setup guide in Panel README.md
    • πŸ‘ Better error handling when the Panel cannot be installed
    • Str::template() keeps placeholders in the result string if no value or fallback was passed (#2307)
    • Str::excerpt() allows to pass a $rep that gets added without an additional space to the end of the excerpt. (getkirby/ideas#525)

    πŸ›  Fixes

    • πŸ‘‰ Useless action buttons are no longer displayed in the upload dialog (#2327)
    • πŸ›  Fixed page duplicating issues (#2514 & #2515)
    • Downloads are no longer cached in Chrome (#2513)
    • πŸ‘‰ Use correct page model when creating new pages
    • ⚑️ Models no longer keep old content in memory cache after updates (#2569)
    • πŸ›  Fixed bug in $page->changeTemplate() (#2567)
    • πŸ›  Fixed zero value bug in range field (#2549)
    • The referrer is no longer submitted when clicking on external links in the Panel
    • F::niceSize(): kB is now KB (#2607)
    • πŸ›  File sorting is now fixed for files sections that use "parent" (#2617)
    • route:after is no longer called on $routeβ†’next() (#2418)
    • 0️⃣ Impersonation in API routes is now blocked by default (#2616)
    • πŸ›  Fixed conflicting pagination in files and pages sections
    • πŸ‘‰ User role switching is now more reliable (#2380)
    • The change title dialog no longer closes on mouseup (#2557)
    • πŸ›  Fixed typo in date picker field: Feburary (#2591)

    Stats

    • 201 commits
    • 39 closed tickets
    • πŸ”€ 80 merged PRs
    • πŸš€ Days since last release: ~2 months

    Contributors (in alphabetical order)