Latest Blog Posts

Deploy: How it'll work in D8

Submitted by Anonymous (not verified) on Tue, 20/10/2015 - 16:40

<p>Over the last 7+ years working with Drupal, one question always asked by clients is, how do I copy my content from staging to production? Generally the answer has been, “Don’t! Just add it on production”. Another option is to use the deploy module, which allows for the deployment of content between environments. </p><!-- more -->

<p>Drupal core has changed greatly in Drupal 8, the deploy module is following suit.</p><p><b><a href="https://www.drupal.org/project/multiversion&quot; target="_blank">Multiversion</a><br/></b>The multiversion module will be the foundation of all this change. It introduces three big changes to the way content is managed in Drupal.<br/>Workspaces - All content is associated with a workspace, you can have multiple workspaces and switch between them. Think of them much like branches in version control systems such as git.<br/>CRAP - Create, Read, Archive, and Purge. This is an alternative to CRUD (Create, Read, Update, and Delete). It means that in multiversion no content is deleted and everything is a new revision. Deleting an entity will just archive it, flagging it as deleted.<br/>Revisions for everything - All content entities are revisionable with multiversion module. This means blocks, user, comments etc all have revisions.</p><p><b><a href="https://www.drupal.org/project/relaxed&quot; target="_blank">Relaxed</a></b><br/>The relaxed module is a RESTful API which is aligned to the CouchDB API. It exposes each workspace as a Couch database. This allows it to be replicated to another Drupal site running relaxed, to a native CouchDB database, or to something else that uses the same API, such as PouchDB.</p><p><b><a href="https://www.drupal.org/project/deploy&quot; target="_blank">Deploy</a></b><br/>Finally the deploy module. This is now just a UI module as all the the content deployment is handed with external projects. The relaxed module exposes the API needed, a PHP based <a href="https://github.com/relaxedws/couchdb-replicator&quot; target="_blank">CouchDB replicator</a> uses a PHP based <a href="https://github.com/doctrine/couchdb-client&quot; target="_blank">CouchDB client</a> to replicate / deploy the content.</p><p>The current plan is to have a “Deploy” button in the Drupal toolbar, this will open a modal where you can choose which site you want to deploy to and which workspace you want to merge into. It will be possible to deploy to a workspace on the current site. For example, a staging site may have two content editors, both working on different workspaces, then can then deploy / merge their content to the default workspace. This default workspace can then be merged up to the production site’s default workspace.</p><p>Tagging is also an idea being worked on. It will allow you to tag a workspace at a current point in time, then continue to edit content. When deploying from a tag it will only merge up changed until the tag was created.</p><p>These are big changes for the deploy module, but something that will make the content workflow a lot easier.</p>

How can we know if a page in Drupal 8 has changed?

Submitted by Anonymous (not verified) on Fri, 02/10/2015 - 15:27

<p>This was a question I got from a client. So I set to work on finding a solution to alert the team who needed to know when a page has changed.</p><p><b>TL;DR</b>: <a href="https://www.drupal.org/developing/api/8/cache/tags&quot; target="_blank">CacheTags</a>.</p><!-- more --><p>Drupal has an awesome caching layer. It makes use of cache tags, these tags can be invalidated when something changes. For example if this is a view called “frontpage”, it would output the cache tag &ldquo;view:frontpage&rdquo;. This view lists a bunch of nodes, each with their own cache tag, &ldquo;node:1&rdquo;, &ldquo;node:2&rdquo; etc. When node 2 is edited, it’s cache tag and the frontpage view cache tag would be invalidated.</p><p>Taking this into account if we want to know what pages have changed, we need to know what cache tags the page has, then what cache tags have been invalidated.</p><p>The client already has a crawler to check their sites, this can look at the <code>X-Drupal-Cache-Tags</code> header and capture the cache tags the page has. So all we need now is a way of telling the crawler what cache tags have been invalidated.</p><p>Welcome to the <a href="https://www.drupal.org/project/cachetag_notify&quot; target="_blank">CacheTag Notify</a> module. This has a simple settings page where an endpoint URL can be added. Then every time a cache tag is invalidated it gets POSTed to the endpoint as a JSON string. The crawler will then need to to lookup which pages are using the invalidated cache tags, then it knows which have changed.</p><p>The CacheTag Notify module works by adding <code>CacheTagsInvalidator</code> service. The <code>invalidateTags</code> method is passed an array of invalited tags, this is then POSTed to the endpoint url using Guzzle. Overall a very, very simple, but effective solution.</p>