content staging in drupal 8
DESCRIPTION
Drupal 8 has made significant improvements towards the ability to stage configuration. But what about content staging? Has it gotten easier in Drupal 8? This session is targeted towards site builders where we will continue to explore the content staging solution that is being built for Drupal 8 and that was initially presented in Austin. It's a solution that brings vast improvements to sites owners that need to stage or replicate content across sites. Further, site builders will learn how this solution also applies to broader and sometimes more exciting use cases - content sharing and filtered replication across networks of sites and applications. The recorded video is available here: https://amsterdam2014.drupal.org/session/content-staging-drupal-8-continuedTRANSCRIPT
![Page 1: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/1.jpg)
ADVANCED SITE BUILDING
CONTENT STAGINGIN DRUPAL 8
DICK OLSSON TWITTER: @dickolsson
![Page 2: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/2.jpg)
What is content staging?
What we want from the solution
How it's (being) built for Drupal 8
Reusable protocols
Headless Drupal
AGENDA
![Page 3: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/3.jpg)
Dick Olsson
Digital Engineering Manager at Pfizer
dixon_ on drupal.org
@dickolsson on Twitter
Web technologist
Drupal contributor
WHO AM I?
![Page 4: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/4.jpg)
WHAT ISCONTENT STAGING?
![Page 5: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/5.jpg)
SIMPLE WORKFLOW
ProdStage
![Page 6: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/6.jpg)
SECURE PUBLISHING
ProdStage
Corporate firewall
![Page 7: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/7.jpg)
MERGE WORKFLOW
Stage
Edit 1
Edit 2
Edit 3
Prod
![Page 8: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/8.jpg)
HUB/SPOKE WORKFLOW
Editorial BD
A
C
![Page 9: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/9.jpg)
RING MODEL
BD
A
C
![Page 10: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/10.jpg)
Content staging
Content sharing
Replication
Syndication
IT'S SORT OF...
![Page 11: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/11.jpg)
WHAT WE WANT
![Page 12: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/12.jpg)
We don't want to build just a “content staging” system.
We need a generic and loosely coupled “content replication” framework capable of arbitrarily moving content between system.
WHAT WE WANT
![Page 13: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/13.jpg)
Learning from the Drupal 7 implementations of UUID, Deploy and WF Tools modules.
WHAT WE WANT
![Page 14: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/14.jpg)
Revisions everywhere
Conflict detection
Easier dependency management
Ad-hoc / Continuous replication
Bi-directional replication
REST API
WHAT WE WANT
![Page 15: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/15.jpg)
HOW IT'S BUILT
![Page 16: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/16.jpg)
Contrib:
Multiversion
Relaxed Web Services
Deploy
Core:
Serialization
Restful Web Services
Entity API
HOW IT'S BUILT
![Page 17: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/17.jpg)
Tracks update sequences in order to make dependency management a lot easier.
Provides revision support for all content entities.
Tracks revision trees in a way similar to Git to support conflict detection.
multiversion.module
![Page 18: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/18.jpg)
Revisions are not tracked with a UUID. A hash calculated from the actual changes is better.
This way it's easier for each server to detect conflicts without deep inspection or asking the
network.<?php
md5($this->serialize(array( $deleted, $sequence_id, $old_rev, $normalized_entity), 'json'));
multiversion.module
![Page 19: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/19.jpg)
{ id: [{value: 1}], uuid: [{value: aabbcc}] _revs_info: [ {rev: 2-gghhii}, {rev: 1-ddeeff} ], _local_seq: 1, _deleted: 0,}
multiversion.module
![Page 20: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/20.jpg)
CRAP instead of CRUD.
Entities are never deleted. This is needed in order to replicate deletions while also being
able to handle conflicts. Much like Git.
A “compaction” job can be run on cron to purge old revisions if needed.
multiversion.module
![Page 21: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/21.jpg)
<?phpnamespace Drupal\multiversion\Entity;
class SqlContentEntityStorage extends [...] {
use SqlContentEntityTrait; //...}
multiversion.module
![Page 22: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/22.jpg)
<?phpnamespace Drupal\multiversion\Entity;
class SequenceIndex implements SequenceIndexInterface {
function _construct(KeyValueFactoryInterface $kv) {} // ...}
multiversion.module
![Page 23: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/23.jpg)
<?phpnamespace Drupal\multiversion\Entity;
class ConflictManager implements ConflictManagerIf { // ...}
class CompactionManager implements CompactionManagerIf { // ...}
multiversion.module
![Page 24: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/24.jpg)
Provides a Restful/Relaxed JSON API.
Endpoints for all content entities and file attachments.
Endpoints for comparing revisions, starting/stopping replications and other
administrative tasks.
Drush plugin for running replications.
relaxed.module
![Page 25: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/25.jpg)
<?phpnamespace Drupal\relaxed\Plugin\rest\resource;
/** * @RestResource( * id = “relaxed:doc” * ) */class DocResource extends ResourceBase { //...}
relaxed.module
![Page 26: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/26.jpg)
<?phpnamespace Drupal\relaxed\Plugin\rest\resource;
/** * @RestResource( * id = “relaxed:_bulk_docs” * ) */class BulkDocsResource extends ResourceBase { //...}
relaxed.module
![Page 27: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/27.jpg)
<?phpnamespace Drupal\relaxed\Plugin\rest\resource;
/** * @RestResource( * id = “relaxed:_changes” * ) */class ChangesResource extends ResourceBase { //...}
relaxed.module
![Page 28: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/28.jpg)
<?phpnamespace Drupal\relaxed\Plugin\rest\resource;
/** * @RestResource( * id = “relaxed:_revs_diff” * ) */class RevsDiffResource extends ResourceBase { //...}
relaxed.module
![Page 29: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/29.jpg)
A simple UI to manage replications and conflicts
deploy.module
![Page 30: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/30.jpg)
1. Identify source and target by UUID
2. Get the current checkpoint from target site
3. GET /_changes?since=N from source site
4. Pass result to /_revs_diff on target site
5. Collect all missing revisions from source site
6. POST /_bulk_docs on target
7. Save new checkpoint on target site
HOW REPLICATION WORKS
![Page 31: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/31.jpg)
DEMO
![Page 32: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/32.jpg)
DEMO
:-(
![Page 33: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/33.jpg)
The revision and conflict detection model is taken from both Git and CouchDB.
The replication protocol along with the API spec is taken from CouchDB.
REUSABLE PROTOCOLS
![Page 34: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/34.jpg)
Reusing API specifications lends the framework to unexpected use cases and
that otherwise would not be possible
(CouchDB, PouchDB, TouchDB etc).
REUSABLE PROTOCOLS
![Page 35: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/35.jpg)
HEADLESS DRUPAL
AngularJS
PouchDB Replication
![Page 36: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/36.jpg)
Not straight port of the Drupal 7 modules.
Loosely coupled system will cover more use cases and lend itself to unexpected
ones as well.
Implementing battle tested protocols.
CONCLUSIONS
![Page 37: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/37.jpg)
Andrei Jechiu (jeqq on drupal.org for working to these modules.
SPECIAL THANKS
![Page 38: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/38.jpg)
FRIDAY CODE SPRINT
Follow @drupalmentoringhttps://amsterdam2014.drupal.org/sprints
Help improve Drupal: Sprint with the community on Friday.
- We have tasks for every skill set. - Mentors are available for new contributors.- An optional Friday morning workshop will help you set up community tools.
![Page 39: Content Staging in Drupal 8](https://reader034.vdocument.in/reader034/viewer/2022052508/559457f11a28ab732f8b4755/html5/thumbnails/39.jpg)
WHAT DID YOU THINK?
EVAULATE THIS SESSION - AMSTERDAM2014.DRUPAL.ORG/SCHEDULE
THANK YOU!
DRUPAL: dixon_ TWITTER: @dickolsson