AGILEDROP: Agiledrop going to the nearest Drupal Camp

Posted by Blog - 11 May 2017 at 04:57 UTC
After a long travel to Baltimore, where two of our team members (Commercial and Operations director to be precise) attended DrupalCon Baltimore, we will have a much shorter distance to overcome this time. In fact, we'll be going to the nearest Drupal Camp possible. That's in Zagreb, where our development team will attend Drupal Heart Camp Zagreb. Since we are located in Ljubljana, Slovenia, our nearest destination would be our coast, where there was once a Drupal Camp Alpe-Adria. But since the Camp is not taking place there anymore – we discussed that with one of its organizers Janez Urevc… READ MORE

A Week of Learning & Growth at DrupalCon Baltimore

Posted by FFW Agency - 10 May 2017 at 19:40 UTC
A Week of Learning & Growth at DrupalCon Baltimore leigh.anderson Wed, 05/10/2017 - 19:40

It’s hard to believe that another DrupalCon has come and gone — it feels like just yesterday when we were mourning the passing of Drupal 6 in New Orleans and unveiling our new branding in Los Angeles. DrupalCon Baltimore was a success for us, and we wanted to share some of our memories from the event.

Our Week at DrupalCon

It was an honor to introduce Dries on Tuesday morning at DrupalCon. We were grateful that we had the opportunity to discuss two projects that are near and dear to our hearts: The Open Y Drupal distribution, and Drupal Global Training Days.

We were also thrilled to have so many visitors drop by our booth. It was great seeing so many old friends and making new ones, and we’d like to say congratulations again to our raffle winners: Mark (pictured below) & Dennis, who won Apple Watches, and Patrick, who won an Amazon Echo.

FFW Session Recordings

We had a great time sharing our knowledge in trainings, sessions, and BOFs. If you didn’t catch the FFW crew in action, you can watch recordings of our sessions here:

  1. Anti-Crash Course: How to Avoid Drupal’s Most Common Pitfalls
  2. Using Drupal to Power the YMCA
  3. Scaling and Sharing: Building Custom Drupal Distributions for Federated Organizations
  4. Less Is More: What Modules, Features or API's Should We Cut From Core?
  5. Docksal: Better than VMs
Mark Bennet claiming his Apple Watch at the boothAdam Leighton at the FFW booth Farewell, Baltimore; Hello, Vienna!

As always, we stayed for the community. We were heartened to see so many people working together to grow the project, navigate new territory, and have thoughtful conversations about the future of the Drupal software and the community’s governance. We’re looking forward to the continued discussions about the community’s structure and future; if you’d like to participate, you can find future meeting information here.

It was a pleasure to sponsor such a great event. We’re looking forward to seeing who we meet and what great conversations we have across the pond at DrupalCon Vienna this September.

DrupalCon group shot credit to Michael Cannon on Flickr.

Group shot from Driesnote at DrupalCon Baltimore Comments

Getting Started With Drupal Commerce 2.x - Part 2

Posted by Valuebound - 10 May 2017 at 17:36 UTC

In the previous article, Getting Started With Drupal Commerce 2.x (Part - I) we have set up the Drupal commerce module 2.x and build the store. The next step to finish the basic commerce 2.x setup is to create Products.

Let’s have a detailed summary of e-commerce products creation in commerce 2.x.

1. Products :

Here we should note the main difference of Drupal Commerce 2.x (for Drupal 8) from Drupal Commerce 1.x (for Drupal 7). In Commerce 2.x, we now have such entities as Product and Product Variation. The product replaces product display of Commerce 1.x (node type, which has been linked to the…

Set Required and Optional Address Inputs for Address Field in Drupal 8

Posted by - 10 May 2017 at 17:34 UTC

This one is dedicated to all my fellow Drupalers. There’s no better exercise for a brain than reading ancient chinese poetry taming Drupal 8. When I’m bored, I turn to Drupal!

Recently I got my Drupal 8 Address module updated and it turned out that from now on street address ...

Read now

Drupal 6 security update for Webform Multifile

Posted by - 10 May 2017 at 17:05 UTC

As you may know, Drupal 6 has reached End-of-Life (EOL) which means the Drupal Security Team is no longer doing Security Advisories or working on security patches for Drupal 6 core or contrib modules - but the Drupal 6 LTS vendors are and we're one of them!

Today, there is a Moderately Critical security release for the Webform Multifile module to fix an Access Bypass vulnerability.

This module enables you to upload multiple files at once in a Webform, but it didn't sufficiently check access to file deletion URLs.

This vulnerability is mitigated by the fact that an attacker must have a role with the permission to edit all or their own webform submissions.

See the security advisory for Drupal 7 for more information.

Here you can download the Drupal 6 patch.

If you have a Drupal 6 site using the Webform Multifile module, we recommend you update immediately.

If you'd like all your Drupal 6 modules to receive security updates and have the fixes deployed the same day they're released, please check out our D6LTS plans.

Note: if you use the myDropWizard module (totally free!), you'll be alerted to these and any future security updates, and will be able to use drush to install them (even though they won't necessarily have a release on

Drupal Association April 26, 2017 Board Meeting Update

Posted by Drupal Association blog - 10 May 2017 at 13:52 UTC

After board meetings, I publish a blog post to provide an overview of the meeting along with the board packet, meeting minutes, and a video of the meeting. Since we just had a board meeting at DrupalCon Baltimore, I want to share details about that meeting as well as pull the lens back to give the community more insight into board meetings and our 2017 schedule. I hope this additional information gives better insight into the Drupal Association’s board activities.

Drupal Association Board Meetings

The Drupal Association board has two different meeting types: Executive Session and Board Meeting. They take place throughout the year to create The Drupal Association’s strategic direction, ensure financial health, engage with the community, and more. This post goes into more details about each meeting type.  

Executive Session

The executive session is usually a two-day meeting that includes board members and the executive director. At times, it can also be a shorter virtual meeting. Topics typically include an Executive and Financial update, financial approvals, committee work, and strategic planning for the Association.

There are four executive sessions a year. All meetings are private to create a safe space for brainstorming strategic direction and discussing confidential matters such as the executive director’s performance and compensation. For this reason, meeting minutes are not shared publicly. However, we will let the community know when we are meeting and what is on the agenda.

The 2017 executive session schedule is: 23 & 24 February, 22 & 23 April, 26 June,  23 & 24 September, and 29 November. The February, April, and September sessions are two day meetings while June and November are two hour virtual meetings. As needed, the board may schedule additional executive sessions to handle business that is time sensitive and best done via a meeting.

The 23 & 24 February executive session agenda covered the following:

  • Executive and Financial Update

  • Getting grounded in DrupalCon Europe survey data (Michael Schmid was present since he was part of the task force)

  • Discuss the future of DrupalCon Europe focusing on sustainability and delivering meaningful value

  • Thank you and goodbye to community-elected board member, Addison Berry.

The 23 & 24 April executive session agenda included the following items:

  • Executive and Financial Update

  • Approve Q3 2016 financial statements

  • Welcome Ryan Szrama - new community-elected board member

  • Understanding community governance needs and identifying community governance gaps

  • Meet and greet with Drupal Association staff / Congratulations on upcoming DrupalCon

Board Meetings

The Drupal Association holds four board meetings each year so the community can observe the board proceedings and participate in a Question and Answer session. Typically, board meetings include operational updates from staff, committee updates, and question and answer time for both the board and the community.

On 26 April, 2017, the Drupal Association held its first board meeting of the year. The board materials and meeting minutes can be found here. All board members were in attendance except Annie Miller, Steve Francia, and Donna Benjamin. Also in attendance were myself, Drupal Association Staff, and about 30 community members.

Dries Buytaert kicked off the board meeting and I reviewed the board packet, which included the meeting’s agenda as well as a scorecard for the key operational projects that staff work on. Next, staff gave operational updates. Tim Lehnen, Director of Engineering, gave an update on Project Application Process, Contribution Credits, and the Infrastructure RFP. Next, Carrie Lacina, Director of Revenue, shared an update on the industry pages. This was followed by Rebecca Pilcher, Marketing & Communications Manager, who gave insight into the new DrupalCon branding.

Lastly, I gave an update related to recent community challenges. I explained that a key way to understand the community’s needs and help them talk about a new community governance model is by hosting mediated Community Discussions. Whitney Hess, the mediator, introduced herself to the board and gave a brief update of the themes she heard in the recent Community Discussions onsite at DrupalCon.

The Board had 10 minutes to ask questions which covered topics such as branding and the infrastructure RFP. While the community had 10 minutes to ask questions, the meeting was extended, giving the community 30 minutes to ask questions. Their questions touched on DrupalCon branding and Project Application Process. There were also several questions related to the learnings gained by the recent community challenges.

You can watch the video of the board meeting here as well as read the meeting minutes and board packet. All materials are found here. The next board meeting will take place on 26 June, 2017 at 12:00 EDT/17:00 BST. It will be a virtual meeting via Zoom. You can go here for login information.

Revert configuration from file based to database based

Posted by Berliners blog - 10 May 2017 at 13:19 UTC

The D8 project I'm currently working on used the file-system based workflow for configuration management. As our deployment workflow improved and got slightly more complex, we started to run into issues with file permissions during deployments and wanted to revert back to the database based workflow that is the default for a new D8 installation.

Unfortunately, though there are a lot of resources on the web that explain how to go from the database to the file system approach, I couldn't find anything explaining how to revert back to the database based configuration workflow. All there is, is this kind of information:

You should do this before installing Drupal, as it is complex to revert back to database-based configuration management setup once you switch to file-based.

So I did some digging and came up with this:

Step 1: Backup

Make a backup of your database and your codebase including all configuration files and your settings and services yaml files. The following actions have the potential to break your site. Do everything on a non-production site, preferabbly hosted on your local machine so that recovery is easy.

Step 2: Export your current configuration

Run this drush command to export your configuration:

drush cex sync
Step 3: Revert your settings and services

Put the following in your services.yml:

    class: Drupal\Core\Config\CachedStorage
    arguments: ['', '@cache.config']
    class: Drupal\Core\Config\DatabaseStorage
    arguments: ['@database', 'config']
    public: false
      - { name: backend_overridable }

And comment out the config storage setting in your settings.php:

// $settings['bootstrap_config_storage'] = array('Drupal\Core\Config\BootstrapConfigStorageFactory', 'getFileStorage');
Step 4: Clear caches

Clear your caches using these drush commands:

drush ev "drupal_flush_all_caches();"
drush cr
Step 5: Re-import your configuration

Run this drush commands to import your configuration:

drush cim sync

This step failed for me at first, due to interdependency between different configuration sets. In my case there had been changes to fields that where attached to some custom ECK entities, and the configuration import wanted to import these before the definition of the actual entity. I was able to work around that by moving the conflicting field configuration out of my configuration sync directory, run the import, moved the files back into the sync directory and run the import again. But you might need to tinkle a bit more with that if you have a complex setup.


Running these 5 steps allowed me to move the site back to use the database based configuration workflow. Let's see if that also helps us with our deployment problems.

Category: Drupal Planet8.xTags: configdevsystem

What's keeping us busy this spring

Posted by Drop Guard - 10 May 2017 at 12:00 UTC
What's keeping us busy this spring

We, at Drop Guard, never stop thinking what else can we do to help Drupalistas around the world to get aboard of the continuous update process ship (as we call it) as soon as possible. More and more threats are being discovered every day, and it's absolutely imperative to stay alerted all around the clock either with help of automation platforms like Drop Guard or doing things your own way.

Drupal Planet Drop Guard features

What Are Experimental Modules in Drupal?

Posted by OSTraining - 10 May 2017 at 10:22 UTC
What Are Experimental Modules in Drupal?

Drupal 8 introduced an interesting new approach called "experimental modules".

These experimental modules are included in the Drupal core, and have inspired several questions from OSTraining members. What are these experimental modules, and is it safe to use then?

Yes, experimental modules are shipped with the Drupal 8 core, but they are not yet fully supported. Here's the official explanation:

Experimental modules allow core contributors to iterate quickly on functionality that may be supported in an upcoming minor release and receive feedback, without needing to conform to the rigorous requirements for production versions of Drupal core. Like other features, new experimental modules can only be added in minor releases, but unlike other features, they may change between patch releases while they are still experimental.

Creating comments via email in Drupal 7

Posted by Morpht - 10 May 2017 at 03:36 UTC

Learn how to create content via email and have it imported into Drupal using Mail Comment.

Creating comments via email in Drupal 7

Posted by Morpht - 10 May 2017 at 00:00 UTC

For a recent project we needed to allow users to comment on content via email. The idea was that when new comments were created, Drupal would send out notification emails that could be replied to. The system had to be able to handle long email chains and a few edge cases. Email is tricky and we learned a lot about the wild world of email. We are sharing our experiences here.

Mail Comment lets you reply via email to notifications from your website. In this article we’ll show you how to reply to content via email and outline the mechanisms that make it work. There are quite a few modules involved in the process and they all have an important role to play.


You will need the following modules installed:

The Workflow

Here’s a typical workflow and how each module fits into the process:

  1. User creates a comment
  2. Drupal sends a notification email to recipients (Rules + Mail Comment Message Notify)
  3. A recipient replies to this notification email via their email client
  4. The reply email is sent to the “From” header which goes to our mailbox (Mailhandler)
  5. Drupal imports the email from this mailbox (Feeds importer)
  6. Drupal validates the email’s authenticity (Mail Comment)
  7. Drupal maps the email’s metadata to comment fields (Feeds + Mail Comment)
  8. Drupal creates a comment (Feeds Comment Processor)
The Steps

With the basic concepts in hand – let’s build out this functionality.

Create a Message type

The Message framework provides an entity type designed specifically for dealing with messages. Messages are great for creating and sending notifications. Create a message type via Structure -> Message types -> Add message type. This message type will represent a notification that occurs when someone posts a comment.

In the “Description” field label your message “New Comment”. The mandatory “Message text” field will become the notification email subject. The form requires a save before correctly displaying “Message text” fields and their associated view modes (a UI bug). Put any value in this field as we’ll be changing it after saving this form.

If you’ve previously enabled Mail Comment then you will see a very important checkbox “Allow users to reply to this message by email”. This has to be ticked.

Save the form and edit the newly created message type. Now you will see two special view modes which will be displayed as the notification email’s Subject and Body.

In “Message text -> View modes: Notify - Email subject” enter a subject:

New comment created on [nid]

In “Message text -> View modes: Notify - Email” enter a body:

[comment:user:mail] says:



Save the form and then click “Manage fields”. Create two fields:

  • field_message_rendered_subject (Text field)
  • field_message_rendered_body (Text area)

These fields are used by Message Notify to save the output of the Subject and Body view modes for use with email.

Create a notification rule

Now that the message type is set up we can create a notification rule that is triggered whenever someone creates a comment.

  1. Create a rule that reacts on the event “After saving a new comment”.
  2. Add the action “Send Message with Message Notify”.
  3. In the “Data selector” select the comment that triggered this rule.
  4. Set “Rendered subject field” to “Rendered subject” and “Rendered body field” to “Rendered body”.
  5. Set the “The recipient of the email” to any email address you’d like.

Configure Mail Comment

Mail Comment works its magic on both sides. It modifies outgoing emails so that they can be replied to, and authenticates incoming emails and extracts metadata. Mail Comment does this by embedding a unique string in the outgoing email that contains email metadata and a hash, which we will go into more detail later.

Go to Configuration -> System -> Mail Comment (/admin/config/system/mailcomment).

Set “Reply-To address“ to the email account that the Feeds importer will be importing from.
“Insert reply to text” is a handy option to have enabled. It will help Mail Comment seperate the latest content in an email from the email’s thread. Other settings are fine to leave at their defaults.

Create a Mailhandler Mailbox

Email replies will be sent to a mailbox that you control. Mailhandler allows you to create a connection to this mailbox. A Feeds importer will then be importing emails from this mailbox via Mailhandler.

Create a mailbox via Structure -> Mailhandler Mailboxes -> Add (admin/structure/mailhandler/add).
The “Username” is likely the same value as Mail Comment’s “Reply-To” email address.

Create a Feeds importer

Drupal feeds importer

The Feeds importer extracts the email via Mailhandler's mailbox. It runs via cron.

Create a Feeds importer via Structure -> Feeds importers -> Add importer. (/admin/structure/feeds/create)
Label it “New Comments”.


Configure the fetcher’s “Message filter” to “Comments only”. This filter works by checking if an email’s In-Reply-To header is set. At this time of writing the filter doesn’t handle all email situations correctly. Please see this comment for a solution.


Select “Mailhandler IMAP stream parser” with the “Authentication plugin” as “Mail Comment Authentication”. Mail Comment authenticates and validates the incoming email to ensure that it was originally sent from the website and replied to by a valid user.


Feeds’ importer processor creates the comment. Select “Comment processor” as your processor. For our particular project at Morpht we created messages instead of comments with “Message entity processor” and a custom module – but that’s another story.

The Mapping configuration here is where all the magic happens. Metadata is pulled from the email and exposed as a source value. The following source values need to be mapped from source to target:

  • Message ID (message_id) -> GUID (guid)
  • Parent NID (parent_nid) -> Node id (nid)
  • User ID (authenticated_uid) -> User ID (uid)
  • Subject (subject) -> Title (subject)
  • Body (Text) (body_text) -> Comment (comment_body)

Message ID and Parent NID are source values created by Mail Comment from the email’s metadata.


The steps above detail how to reply to notifications sent when someone create a comment. Similar steps can be used to send notifications when someone creates a node. Create a new message type called “new_node” and follow the steps above, replacing the comment specific configuration with node config.


Test the system by creating a comment on a node through your website’s UI. A notification email should be sent out to recipients, including your testing email address. Reply to this email, run cron and the comment should be imported. To assist your debugging checkout Content -> Messages and the Maillog module.

Dealing with email clients

If you’d like to know what’s going on under the hood feel free to read below. There’s a reward for reading on. This section will also show you how to reply to long email chains and still have the email imported by Drupal. It also fixes a few bugs with the current version of Mail Comment at the time of this writing.

The Message-ID


Mail Comment stores important information in an email by creating a custom string full of metadata about the original comment. This string is sent in the email inside the Message-ID header. Message-ID is a standard email header that email clients use to insert identifying information about the email. Usually it’s a big hash but in our case it’s a dot separated string of values containing:

  • Node ID
  • Comment ID
  • User ID
  • Timestamp
  • Hash

The format is four digits and one hash divided by dots, an @ symbol and finally the domain that the email was sent from.

Long email chains

Mail Comment’s metadata in the Message-ID header will be lost as soon as someone replies to an email. The email client replying to the email will overwrite Message-ID with its own value. Thankfully there is another email header specifically designed to store a history of all Message-IDs used in the email chain’s lifetime: References. The References header stores each Message-ID in chronological order like so:


As you can see the original Message-ID is on the first line.

Email clients send emails in unexpected formats and can sometimes break the Message-ID metadata. This is especially true with Microsoft Outlook/Exchange, which inserts a seemingly random value at the beginning of the References header (which is actually the third value of the dot separated string).


Our Patch

We have created a patch to better detail with oddly-formatted References headers and long email chains. Feel free to apply.

HTML being sent as plain text

Microsoft Outlook/Exchange occasionally sends out badly formatted HTML in the plain text version of the email. There’s no silver bullet solution. We came up with a simple fix that just strips out all the bad HTML leaving you the plain text.

In your custom module create the following function:

 * Implements hook_feeds_after_parse()
function mymodule_feeds_after_parse(FeedsSource $source, FeedsParserResult $result) {
  foreach ($result->items as &$email) {
    // Filter html
    $email['body_text'] = _mymodule_filter_html($email['body_text']);
    $email['body_html'] = _mymodule_filter_html($email['body_html']);

This hook will run just after feeds has parsed in values, and call the filter html function below:

 * Strip html
function _mymodule_filter_html($text) {
  // remove all tags
  $text_remove = strip_tags($text);
  // decode html special characters
  $text_remove = html_entity_decode($text_remove, ENT_QUOTES);
  // replace multiple empty lines with on
  $text_remove = preg_replace('/\n(\s*\n)+/', "\n\n", $text_remove);
  return $text_remove;


Once these two functions are pasted in, clear Drupal’s cache (drush cc all).


Now you know how to create content in Drupal from email! The basic ingredients are Mail Comment, Feeds importer and a few modules gluing it all together.

You can use similar techniques to create nodes from email too. Just be mindful that there are security implications doing this as you can’t always trust the sender and contents of an email. Mail Comment authenticates incoming mail by creating a hash and this is harder to do when importing an email without a Mail Comment generated Message-ID.

As Drupal heads more and more towards being a REST based backend it’s easy to forget the more traditional means of inputting data. Email is ancient on the technology timeline, but its convenience coupled with Drupal’s well defined data structure can be a great combo. Happy mailing!

The Lowdown on DrupalCon Baltimore

Posted by Palantir - 9 May 2017 at 21:33 UTC
The Lowdown on DrupalCon Baltimore brandt Tue, 05/09/2017 - 16:33 Alex Brandt May 10, 2017photo of Palantir swag

Our favorite parts of DrupalCon Baltimore.

In this post we will cover...
  • Our favorite events from DrupalCon

  • Links to Palantir sessions

Stay connected with the latest news on web strategy, design, and development.

Sign up for our newsletter.

DrupalCon is always a positive experience for the Palantir team, largely because of the Drupal community itself. Our week in Baltimore was filled with engaged conversations, thoughtful sessions, and much appreciated down time with friends we don’t get to see often enough.

DrupalCon by the Numbers

  • Palantiri in attendance: 14
  • Palantiri sessions: 3
  • Client meetings: 7
  • Coffees consumed: at least 2 dozen
  • Newsletter sign-ups: 240
  • Podcasts recorded: 2
  • Late nights: 2 many

“It was a wonderful first DrupalCon experience because of a great community that is so supportive and accepting of newcomers, regardless of their level of Drupal knowledge.” - Annie Schow

Highlights by Day

Monday: We ate all the crabs.
Following the opening reception in the exhibit hall, we ate dinner as a team at Riptide by the Bay In historic Fells Point. An impressive amount of crabs were consumed.

photo of Palantiri at dinner

photo of crabs at dinner

Tuesday: #PMTheMusical!
We witnessed another standing ovation for Joe Allen-Black and Allison Manley and their performance of Project Management: The Musical! There were quite a few crowd favorites, and Joe and Allison were both happy to share their final performance of this presentation in front of an energetic DrupalCon crowd.

photo of Joe Allen-Black and Allison Manley

Wednesday: Inclusion Initiative
We partnered with another Chicago-based agency, Digital Bridge, to coordinate a Drupal training session for five students local to Baltimore who were unfamiliar with Drupal. We’re looking forward to expanding the program in the future. Keep an eye out for more details on that later this month!

photo of students

Thursday: #ContentBeforeCode, #DevTeamCollab and Trivia Night
If you missed them at MidCamp, Megh Plunkett, Michelle Jackson, and Bec White did round two of their sessions on Thursday (recordings linked above). Michelle and Bec’s session will also be available via a webinar later this summer, so stay tuned for your chance to sign up in case you missed it at DrupalCon.

Palantir also hosted Trivia Night at Baltimore Soundstage. We’re not sure the wait staff knew what was happening as over 400 people were tasked with answering some fairly obtuse and nerdy questions about this mysterious Drupal thing, but they kept everyone hydrated so we could enjoy the fun. Jeff Eaton killed yet again as the emcee for the evening. 

photo of Megh Plunkett

photo of Allison Manley

Friday: Exploring Baltimore
As people shuffled to the airport, a few Palantiri were able to squeeze in a last minute trip to the Baltimore National Aquarium. Thankfully not one Palantir was lost to sharks.

photo of group at aquarium

Thanks for a great week Baltimore. We’ll see you next time, DrupalCon!

We want to make your project a success.

Let's Chat.

How to Improve Drupal 8 Website Performance

Posted by Ben's SEO Blog - 9 May 2017 at 16:30 UTC
Cheetah Racing Across Open Grass

Getting faster page load speeds isn’t just about increasing your Google rankings. It’s about improving customer satisfaction and gaining new revenue. Using tools specific to Drupal along with other universal actions, you can reach your marketing goals faster than ever.

It’s no secret that page loading speed matters to Google rankings. Speed became a ranking factor in 2010 and since that time, developers and marketers have been looking for ways to increase it. Google cares about page speed because the search engine is focused on delivering the best onsite user experience possible. As a result, Google rewards fast-loading websites with better rankings. (The converse is not always true. Slow page loading times will only negatively impact your site rankings if it is very slow.)... Read the full article: How to Improve Drupal 8 Website Performance

Testing for the Brave and True: Part One

Posted by Aten Design Group - 9 May 2017 at 15:16 UTC

This is the second part of a series of blog posts about automated testing for Drupal. Its mission is to take you from zero testing experience to confidence in testing your custom Drupal work, from the ground up. Last time, in Testing for the Brave and True: Part Zero we defined exactly what automated testing is and discussed some of the common vocabulary of testing. It also introduced the two primary tools used by the Drupal community to test their work, PHPUnit and Behat.

Why Automated Testing Will Save You Time and Treasure

Now that we know a little about what automated testing is, I'm going to make the case that it can be a net positive to your everyday workflow and actually make you a better programmer.

Everybody Tests

If you came to this blog post with the idea that you've never done any testing or that you've tried to test and didn't succeed, you'd be wrong. Every developer tests their code. Some developers just throw that work away.

Consider what you're doing every time you clear cache and go refresh your browser. You're testing your work. You've made some change to your code and now you're asserting that your work functions as you expect. Perhaps you put a dpm() or kint() in your new code to inspect some part of your code or a variable, or maybe you're using XDebug (if not, I'd encourage you to start) to step through your code. This process is testing.

While these informal tests can be incredibly valuable, you can't commit them; you can't run them the next day and you cannot run all the tests you've ever written with just one command. Writing automated tests is simply writing code that can do some of that testing for you. It's making those informal tests you already do, explicit and formalized.

Context, context, context

Whenever you write code to do specific things, you make assumptions. Assumptions are the foundation of abstraction and abstraction is the foundation of progress. You can't write code that does anything useful without making assumptions. Especially in Drupal. Entities themselves are an abstraction writ large. But, wrong or hidden assumptions are also the root of most bugs.

Therefore, when we write code, we ought to be very aware of the assumptions we make. We ought to record those assumptions in some way, for future maintainers or simply to help us remember that we made them in the first place. Unfortunately, when we only do informal testing, we bake our wrong assumptions into our code without leaving a record of them. We can't re-assert our assumptions later without digging through code or comments or taking the time to figure out what something was actually supposed to do.

This is the first place where formal tests can be a boon to you, future you, and your successors. The act of writing formal, automated tests by its very nature is recording your assumptions for posterity. When you return to your code an hour, day, week, or year later, all the assumptions you made can be tested again. If you have a strange if/else in your code because of some edge case you discovered when you were doing your initial development, a test can ensure that that code isn't deleted when you're cleaning up or refactoring later (at least without explicitly deleting the test).

In short, you make your assumptions explicit. This reduces the cognitive burden of "getting back up to speed" whenever you need to come back to some piece of code.


This is where I first really fell in love with testing. Having formal tests for the code I was working with gave me confidence as I made changes. That can sound strange to someone who's never tested before. It sounded strange to me, too.

The confidence I'm talking about is not the confidence I have in my abilities (Lord knows I could learn a little more about being humble), it's my confidence in the codebase itself and the relative safety I have when I incorporate a change.

If you've ever been in an old, large, legacy codebase, you might recognize that feeling of mild anxiety when you've made a change and there's just no feasible way to know if you've broken something else in some obscure place of "the beast". The only thing you can do is click around and cross your fingers. This is where a well-tested codebase can create real confidence. Having a suite of automated tests means I can isolate my changes and then run all the tests ever written for that codebase and ensure that my changes haven't broken something, somewhere.

Better tests, better code

If you've been interested in the art of programming itself (and I think you must be to be reading this), then you might have heard of the SOLID design principles. Or, at least, things like "write small functions" and "do one thing and one thing well." Maybe you've heard about "dependency injection," "separation of concerns," or "encapsulation." All these words are names for the concepts that, when applied to the way we write code, make the likelihood of our code being robust, flexible, extensible, and maintainable (all good things, right?) go up.

The art and practice of testing itself can help you apply all of these concepts to your code. If you recall the term "unit testing" from the last post in this series, I said, "[unit] tests isolate very small bits of functionality." The process of identifying the one small thing that your code achieves in order to test it, helps you apply the Single Responsibility Principle. Put another way, when your tests become large and unwieldy, they're saying to you, "this code does too much and it should be refactored."

When you're testing code that has dependencies on other code or configuration, like access to the database, another service, or some credentials, it can become difficult to write useful tests. For example, if you're writing code that runs an entity query and you'd like to test how the code works when there are no results, five results or 500 results, you would have a hard time doing so with a real entity query and database connection. This is where "inversion of dependencies" or "dependency injection" come into play. Instead of running an entity query and doing processing on the results all in one function or within a single class, pass the entity query or its results into the function, method or class. This allows you to test the function with fake results, which you can then set up in your test (we'll go over the methods for doing exactly that in a later part of this series).

That inability to test code with implicit dependencies is a good thing™—it forces you to do dependency injection, whereas it's simply a ritual that you have to practice without tests (I should note, the reason inversion of dependencies is a good thing™ is because it makes your code modular and helps ensure it only "does one thing well").

What's next?

I hope I've made a convincing case that writing automated tests for Drupal can save you time and treasure. In the next part of this series, we're going to begin our descent into the art of testing itself. We'll go over writing our first unit test and getting it running on the command line. Until then, feel free to comment or tweet @gabesullice if you've got questions!

Creating comments via email in Drupal 7

Posted by Morpht - 9 May 2017 at 14:40 UTC
Creating comments via email in Drupal 7 admin Wed, 05/10/2017 - 00:40

Atomic Design

Posted by Code Positive - 9 May 2017 at 12:00 UTC
Atomic Design building blocks

The main idea behind Atomic Design is to think about components in their smallest, simplest elements (such as a menu item or a search button) first and building up from there - to design from element upwards rather than starting with page level wireframes.



AGILEDROP: Case Studies on DrupalCon Baltimore

Posted by Blog - 9 May 2017 at 05:44 UTC
There was an enormous amount of sessions in the past DrupalCon. They are available online. But to make things easier for you, we'll simply group them together and add a little overview, so you'll easily pick the ones that you like. We'll start with case studies on DrupalCon Baltimore.   Building on Drupal 8 by Tobby Hagler from Phase2 and Josh Mullikin from Turner A session gives an overview of, the reasons why Drupal 8 was chosen for the 2016-2017 season and how Drupal 8 interacts with other systems and stack components. Attendees learned what worked, what they should… READ MORE

7-Eleven using Drupal

Posted by Dries Buytaert - 9 May 2017 at 01:23 UTC

7-Eleven is the largest convenience store chain in the world with 60,000 locations around the globe. That is more than any other retailer or food service provider. In conjunction with the release of its updated 7-Rewards program, 7-Eleven also relaunched its website and mobile application using Drupal 8! Check it out at, and grab a Slurpee while you're at it!

7 eleven

7-Eleven using Drupal

Posted by Dries Buytaert - 9 May 2017 at 01:23 UTC

7-Eleven is the largest convenience store chain in the world with 60,000 locations around the globe. That is more than any other retailer or food service provider. In conjunction with the release of its updated 7-Rewards program, 7-Eleven also relaunched its website and mobile application using Drupal 8! Check it out at, and grab a Slurpee while you're at it!

Recap: Drupal Camp 2017 in Frankfurt

Posted by Cocomore - 8 May 2017 at 22:00 UTC

At this year's DrupalCamp in Frankfurt, we have not only been excited participants, but as part of the organization team we have also been responsible for the smooth running of the event, the coordination on site and the planning before the actual event took place. In this blog article our colleague Ela summarized which tasks we have undertaken and which topics have been on this weekend's Drupal agenda.


Subscribe with RSS Subscribe to aggregator - Planet Drupal