Skip to content

@ambroisemaupate ambroisemaupate released this Jul 8, 2019 · 40 commits to master since this release

🏝
Dear fellow followers,

Here is our Roadiz summer update with great new features and improvements. But before, just a quick reminder with some useful links to bookmark:

Changelog

  • Use standard oEmbed to fetch medias from Youtube, Vimeo, Dailymotion, Soundcloud, Mixcloud, TED, Spotify and Twitch. No more need for an API key to fetch Youtube videos and Soundcloud embeds.
  • Using Symfony Workflow to handle Node status from draft to deletion using guarded transitions. Node::setStatus() method is now @internal. Use $this->get('workflow.registry')->get($node)->apply($node, 'publish') to publish a node. Roadiz workflow registry can be extended with your own entities state machine.
  • New Attributes entities. Basically, it's kind of Tag with values. You can create a weight attribute then set it to 30 kg for one node, and to 15 kg for another one. Attribute system is very handy if your customer wants some flexibility in its node schema without updating node-types and your Twig template for each new field. Just add new attributes, then loop over them in your templates. Ok, so why can't we use only attributes and no more node-types fields? Because attributes are for scalar values only (no relations) and not queryable (yet…). But we still index them in your Solr index.
  • Image documents size are now stored in database to avoid Roadiz loading image in memory each time you need width and height information.
  • AppController::getRoot and Theme::getRoot were deprecated and have been removed now.
  • Added password creation policies: minimum 6 characters long, at least one uppercase and one digit.
  • New NSEntities::xxxxSources methods to fetch NodesSources instead of Nodes in your Controllers and templates. For example, use {{ nodeSource.referencePageSources[0] }} instead of {{ nodeSource.referencePage[0].nodeSources.first }} to fetch your referencePage field in Twig. xxxxSources methods are optimized when referenced nodes are only from one type, avoiding left join on every node-types. Execute bin/roadiz generate:nsentities to get these new proxy methods.
  • New ttl field on node and defaultTtl field on node-types to make HTTP cache TTL editable from back-office (if your theme use these new fields). 0 TTL means no cache. Node TTL is in minutes, not seconds.
  • DefaultController for easier theme development, no more need to create a PHP controller for each node-type, just a Twig template. Don’t worry, you’ll still need controllers for custom template assignation or logic, but avoiding Controller creation for basic pages will speed up development…
  • Centralized and extensible serializer (jms/serializer) for all Roadiz entities : $this->get('serializer'). We added normalization annotations on each Roadiz entities to prepare full JSON API in your themes.
    • URL serializer listener to inject node-source and document URL in JSON responses.
    • New import/export methods based on JMS Serializer for Node-types, Roles, Settings, Attributes and Tags. We are keeping Node import for later 😇. Export files are now plain JSON files. Normalization and denormalization processes are handled seamlessly by JMS for a better support when we add or remove fields from entities.
  • Added description field to Setting, because a bit of documentation never hurted anyone (except for the one who writes it).
  • makeResponseCachable is now using event dispatcher to alter Response cache headers and to remove headers set by active session.
  • Use Events to generate node-source paths. Useful to vary {{ path() }} results according to NodeType. For example, a Link node path should not be generated as a real node but it should be generated against its linked node URL instead.
    • Improved NodeSource path generation event with parameters and completion support for generated path (a complete path does not need Router to prepend baseUri).
  • Fixed Kernel dispatcher early awakening. Moved initEvents method call to boot allowing register method to be overridden in your AppKernel class.
  • Get rid of Google Maps in back-office to use Leaflet + OpenStreepMap. Tile rendering can be slower, but it’s open-source data and no more need to setup Google API key to view maps in back-office 🤘.
  • Added FirewallEntry::firewallAfterLogout parameter to customize path after user logged out (available since v1.1.19) instead of redirecting on firewall’ entry point.
  • New themes:migrate command to combine themes:install --data, generate:nsentities and orm:schema-tool:update commands.
  • New Composer ScriptHandler::rotateSecret script to generate a new security.secret at each composer install and update.

Deprecations

Roadiz v1.2 is compatible with PHP 7.2 minimum. It’s time to upgrade…

  • Deprecated validateAccessForRole() method to use Symfony standard denyAccessUnlessGranted() method in order to enable complex Voters
  • |url twig filter was deprecated for NodeSource and Node and has been removed now
  • Deprecated all findByXXXXAndFieldName repository methods (custom-forms, node-sources, nodes, documents) because they are not safe when multiple fields exist with the same name.
  • Additional service providers and console commands should be registered in your app/AppKernel instead of your configuration (which can be volatile between different environments).
additionalServiceProviders: {  }
additionalCommands: {  }

Migrations

This update need many SQL changes then some migrations to populate missing new data. Make sure to backup your database before migrating!bin/roadiz database:dump -c

Database

  • New ttl field on node and new defaultTtl on node-type
  • New attributes feature needs several tables to work and new document fields :
CREATE TABLE attribute_values (id INT AUTO_INCREMENT NOT NULL, attribute_id INT DEFAULT NULL, node_id INT DEFAULT NULL, position DOUBLE PRECISION NOT NULL, INDEX IDX_184662BCB6E62EFA (attribute_id), INDEX IDX_184662BC460D9FD7 (node_id), INDEX IDX_184662BC462CE4F5 (position), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB;
CREATE TABLE attributes (id INT AUTO_INCREMENT NOT NULL, code VARCHAR(255) NOT NULL, searchable TINYINT(1) DEFAULT '0' NOT NULL, type INT NOT NULL, UNIQUE INDEX UNIQ_319B9E7077153098 (code), INDEX IDX_319B9E7077153098 (code), INDEX IDX_319B9E708CDE5729 (type), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB;
CREATE TABLE attribute_value_translations (id INT AUTO_INCREMENT NOT NULL, translation_id INT DEFAULT NULL, value VARCHAR(255) DEFAULT NULL, attributeValue_id INT DEFAULT NULL, INDEX IDX_1293849B9CAA2B25 (translation_id), INDEX IDX_1293849BFF82614D (attributeValue_id), INDEX IDX_1293849B1D775834 (value), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB;
CREATE TABLE attribute_translations (id INT AUTO_INCREMENT NOT NULL, attribute_id INT DEFAULT NULL, translation_id INT DEFAULT NULL, label VARCHAR(255) NOT NULL, options LONGTEXT DEFAULT NULL COMMENT '(DC2Type:simple_array)', INDEX IDX_4059D4A0B6E62EFA (attribute_id), INDEX IDX_4059D4A09CAA2B25 (translation_id), INDEX IDX_4059D4A0EA750E8 (label), UNIQUE INDEX UNIQ_4059D4A0B6E62EFA9CAA2B25 (attribute_id, translation_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB;
ALTER TABLE attribute_values ADD CONSTRAINT FK_184662BCB6E62EFA FOREIGN KEY (attribute_id) REFERENCES attributes (id) ON DELETE CASCADE;
ALTER TABLE attribute_values ADD CONSTRAINT FK_184662BC460D9FD7 FOREIGN KEY (node_id) REFERENCES nodes (id) ON DELETE CASCADE;
ALTER TABLE attribute_value_translations ADD CONSTRAINT FK_1293849B9CAA2B25 FOREIGN KEY (translation_id) REFERENCES translations (id) ON DELETE CASCADE;
ALTER TABLE attribute_value_translations ADD CONSTRAINT FK_1293849BFF82614D FOREIGN KEY (attributeValue_id) REFERENCES attribute_values (id) ON DELETE CASCADE;
ALTER TABLE attribute_translations ADD CONSTRAINT FK_4059D4A0B6E62EFA FOREIGN KEY (attribute_id) REFERENCES attributes (id) ON DELETE CASCADE;
ALTER TABLE attribute_translations ADD CONSTRAINT FK_4059D4A09CAA2B25 FOREIGN KEY (translation_id) REFERENCES translations (id) ON DELETE CASCADE;
ALTER TABLE settings DROP FOREIGN KEY FK_E545A0C550DDE1BD;
ALTER TABLE settings ADD description LONGTEXT DEFAULT NULL;
ALTER TABLE settings ADD CONSTRAINT FK_E545A0C550DDE1BD FOREIGN KEY (setting_group_id) REFERENCES settings_groups (id) ON DELETE SET NULL;
CREATE INDEX IDX_E545A0C58CDE5729 ON settings (type);
CREATE INDEX IDX_E545A0C55E237E06 ON settings (name);
CREATE INDEX IDX_E545A0C57AB0E859 ON settings (visible);
ALTER TABLE nodes ADD ttl INT DEFAULT 0 NOT NULL;
ALTER TABLE documents ADD imageWidth INT DEFAULT 0 NOT NULL, ADD imageHeight INT DEFAULT 0 NOT NULL;
CREATE INDEX IDX_A2B072882100AA2E ON documents (mime_type);
ALTER TABLE node_types ADD default_ttl INT DEFAULT 0 NOT NULL;
CREATE INDEX IDX_7C7DED6D2B36786B ON nodes_sources (title);

Roles

  • Existing Roadiz sites should add ROLE_ACCESS_ATTRIBUTES in order to access new Attributes admin sections.

Documents

  • Need to perform bin/roadiz documents:size command to migrate all documents images size to database if you want Twig filters imageSize, imageRatio and imageOrientation to keep on working.

NodeSource Entities

  • Execute bin/roadiz generate:nsentities to update your NS classes and benefit from new proxy methods.

More than Roadiz…

Assets 2
You can’t perform that action at this time.