Skip to Content

Planet Drupal

Syndicate content - aggregated feeds in category Planet Drupal
Updated: 1 day 15 hours ago

Drupal @ Penn State: Navigating your Entity Metadata Wrapper

9 November 2015 - 9:46am

For those of you who haven't worked with Entity Metadata Wrapper in Drupal before, drop the burrito visit the documentation page on

Entity Metadata Wrapper takes working with render arrays from blah, to "yeah!" in seconds.  For instance, remeber how painful it was to get the file url out of an image field before:

Categories: Drupal

Drupal @ Penn State: ELMSLN - Coming to a camp near you

9 November 2015 - 9:46am

I was made aware that it’s been close to a year since I actually did a demo of the reason that I contribute so many modules to drupal. org. For those that don’t know, the reason I exist is a project called ELMS Learning Network. It is a Drupal 7 based deployment methodology that takes the many parts of an LMS and fragments them across a series of drupal distributions.

Categories: Drupal

Drupal @ Penn State: One liner to install php 7, mysql 5.6, apache 2.4, drush and drupal on centos 7

9 November 2015 - 9:46am

It was a nice little saturday in happy valley. Since my son is forcing us to watch the Sponge Bob Square Pants movie over and over, I decided to multi-task. Bryan Ollendyke has been talking about PHP 7 a tad bit lately so I decided to whip up an instance. 

Granted this is not ready for prime-time just yet, however, it is extremely fast and everything that I have tested so far works fine. Turn on authcache and it is REALLY fast!

Categories: Drupal

Drupal Watchdog: Busting the Bottleneck

9 November 2015 - 9:28am

Any improvements made anywhere besides the bottleneck are an illusion. — Gene Kim

How To Identify And Resolve Your Pinch Points

Rush hour is a cruel juxtaposition between drivers ready, willing, and able to get to their destination as quickly as possible, only to find themselves creeping along (or at a dead stop) due to traffic jams caused by the roads being over capacity and the lack of coordination or optimization of the travel plans of each individual driver.

Most of those drivers also know that by consulting Google Maps and Waze, they can discover the cause of the jam-up, their distance to it, and estimated time of delay; they can then make the decision to stick it out or take the next exit and proceed through the streets.

How motor vehicles flow through a network of highways and byways is a good analogy of how work flows through an organization. When the volume of your company’s work ramps up, and there comes a moment when a single stage becomes the rate-limiting constraint for the entire system, your first step is to locate that damn bottleneck.

And Waze won’t help.

Making Work and Workflow Visible

While the system-wide constraint may be obvious in some organizations, it's not always apparent until the flow of work increases to the degree that the bottleneck is overloaded and potentially damaged, making things worse (e.g. a car accident causing traffic to back up even more). The following three exercises will help identify the problem area.

Exercise #1: Inventory the Four Types of Work

As organizations grow, so does the quantity and variety of projects that are being worked on simultaneously across different teams and divisions. Unfortunately, the net result is that it becomes more difficult to quantify and prioritize what is being done. Therefore, the first order of business is simply to locate this information. You can perform this exercise digitally, using a spreadsheet, but it's much more powerful if done against a wall with index cards. Either way you'll gain insight into your organization.

Categories: Drupal Default Search API Sorts Per View in Drupal 7

9 November 2015 - 8:46am

It's been a while since I've written a post here (especially, Drupal-related). But today I have something interesting to share.

There's a module called Search API sorts ( that provides custom sorts and a global sort block for Search API. The module itself is ok, but ...

Read now

Categories: Drupal

Wellnet Blog: Webprofiler meets Devel

9 November 2015 - 7:41am

Big news for all Drupal developers!
Some days ago the Webprofiler and Devel projects have been merged together.
This is a huge win for both: Devel gets a shiny new query logger and Webprofiler can reach way more developers.

Categories: Drupal

Drupalize.Me: Meet Project Manager Sean Lange

9 November 2015 - 6:01am

We asked Sean Lange what it means to be a project manager and for some advice from his experience. Sean is an advocate for developers and project manager at Lullabot, a fully distributed digital agency. Read more about Sean's approach to his role as a project manager in this Drupalize.Me interview, part of our Drupal roles series.

Categories: Drupal

Janez Urevc: When will media be ready for Drupal 8?

9 November 2015 - 5:00am

Disclaimer: This post ended up being quite long and I apologize for that. Media is a complex problem and there is a lot to be said. If you have better things to do in your life skip directly to the most important part: list of modules in D8 media space and their status. Would you like to help? See what is our current focus. Would you like to get in touch? We will be happy to talk to you!

OK. Now we're ready to start!

With Drupal 8 around the corner a lot of people started asking me when will media be ready. It was quite reasonable to expect this to start happening. Unfortunately there is no simple answer to this question. Shortest would be: "It depends.... What exactly do you need?". I know what you're thinking now... "Are you joking with me!?"

First things first

Your web browser doesn't support playing this WebM screencast.

Screencast displays WYSIWYG embedding in D8 core.

Quite some things happened since Drupal 8 release cycle started. Initially we focused on improving core itself. Improvements that were added to core are not many, but some of them are still very nice. Most noticeable for a day to day user are WYSIWYG embedding of images, multi-upload with drag'n drop support and listing of files in the system.

Your web browser doesn't support playing this WebM screencast. TODO - add multi upload screencasr

Screencast displays multi upload in Drupal 8.

Good stuff, you have to admit that. :) I hope that you already feel better... While those won't cover every possible use case are still nice improvements that most of sites will leverage from.

Drupal 8 file listing.

At some point during the D8 cycle it became clear that we won't be able to include any more major improvements in core. It was necessary to start thinking about contrib space. Discussions were started. We tried to identify what went wrong in the past and proposed ideas to make things better.

Categories: Drupal

OSTraining: New Video Class: Drupal 7 Security

9 November 2015 - 2:04am

This week's new video class is "Drupal 7 Security".

In this class, Robert gives a comprehensive overview of what you need to do to keep your Drupal 7 website secure.

Robert explains the importance of user permissions and the User 1 account. He talks about how to safely allow people to add content to your site.

Robert also discuesses the technical steps you need to keep your Drupal installation secure, how to store important but private files, SSLs and much more.

Categories: Drupal

Web Omelette: Overriding Queues in Drupal 7. Or How Not to Create Duplicate Queue Items

9 November 2015 - 12:02am

Have you ever needed to override a Queue in Drupal 7? For example, the reliable database SystemQueue? It's actually quite easy and very flexible as well. Let me first tell you the use case we are going to work with in this article.

Let's say that we want to make sure that when adding items to a queue, those items don't already exist in the queue table. That's actually a fair request in my opinion. An option would be to make a query and see if the item already exists before delegating its creation to the responsible Queue class. However, we'd have to deal with querying for serialised data and is just not performant.

A better way is to use our own DrupalQueueInterface implementation:

/** * Custom implementation of the DrupalQueueInterface */ class MyCustomQueue extends SystemQueue { /** * Overriding the method to make sure no duplicate queue items get created * but that the items are updated if the exist. */ public function createItem($data) { $serialized = serialize($data); $query = db_merge('queue') ->key(array('name' => $this->name, 'data' => $serialized)) ->fields(array( 'name' => $this->name, 'data' => $serialized, 'created' => time(), )); return (bool) $query->execute(); } }

As you can see, we are extending from the good ol' SystemQueue but overriding it's createItem() method. Instead of the db_insert() statement with which items were persisted, we are using a db_merge() statement to UPSERT the items. This means that if the items already exit, they get updated. If not, they get created. Which is exactly what we want.

Lastly, we need to make sure this class is being used for our queue. Again the solution is simple. Let's say our queue name is my_custom_queue. When requesting it like so:


... Drupal looks in the variables table for a variable called queue_class_my_custom_queue. If it finds it, it will try to instantiate a class that has the name specified as the variable value (if it also implements DrupalQueueInterface). If there is no such variable, it falls back to the default one which is SystemQueue.

So this means that our module needs to create that variable so that when we are requesting this particular queue, we get an instance of our own class. We can do this inside install and uninstall hooks:

/** * Implements hook_install(). */ function my_module_install() { variable_set('queue_class_my_custom_queue', 'MyCustomQueue'); } /** * Implements hook_uninstall(). */ function my_module_uninstall() { variable_del('queue_class_my_custom_queue'); }

And that is pretty much it. Now our queue will use the custom class we wrote and we can make sure no items are duplicated.

Hope this helps.

Categories: Drupal

Larry Garfield: Why I speak

7 November 2015 - 2:51pm

A few weeks ago I gave a keynote presentation at PNW PHP in Seattle. It was the second time I'd given that particular talk, Eating ElePHPants, a quasi-history and lessons-learned of the process of rebuilding Drupal 7 to Drupal 8.

Overall reception was good, and afterward I was appraoched by a woman who was trying to push for better development practices and refactoring a legacy code base at her company. We've exchanged a few emails since, as she goes about trying to subvert her company's development process for its own good to introduce testing, refactoring legacy code, decoupling, and other concepts that many of us on the conference circuit take for granted.

In the course of that email conversation, she had this to say:

When I first started with this entire effort about 2 months ago, I thought I will never succeed, and I thought I had set myself up to failure - until I heard you speak about your experience. Your talk was highly inspiring and got me excited to invest more time into what I was doing and I believed in myself for the reasons I chose this effort.

And later...

All the tech talks helped me realize that I can get somewhere, made it seem within reach, but you and Adam Culp [who also gave a session on refactoring] left me inspired.

read more

Categories: Drupal

Drupal Association News: What’s new on - October 2015

6 November 2015 - 2:33pm

Look for links to our Strategic Roadmap highlighting how this work falls into our priorities set by the Drupal Association Board and Working Groups.

Drupal 8 will be released on November 19th!

Drupal 8 is finally on its way and no-one is more excited than we are. The Association plays a critical role in providing the supporting infrastructure and developer tools that make the release of Drupal possible. In September we focused hard on making sure was ready for the Release Candidate, and now we have a final release date for Drupal 8.0.0 of November 19th!

Releasing the next major version of Drupal is no small endeavor. In October we focused hard on ensuring there will be no infrastructure blockers for the release of Drupal 8. We also spent time designing the release page and improvements to the download experience which we will implement before release day.

What better reason than the release of Drupal 8 to celebrate? We've added a category for Drupal 8 release parties to - so please post your events there, or look there for one to attend!

Drupal Association Membership Campaign

With the imminent launch of Drupal 8, now is a better time than ever to become a member of the Drupal Association. In mid-October we launched a membership campaign with the goal of adding an additional 1,000 members to our current base of 3,200 and raising an additional $100,000.

To support this campaign we placed a banner on asking for your support, and asking existing members to share the campaign. The campaign will end on December 30th, and with your help we can sustainably fund ongoing improvements to like the ones you see here every month.

The Roadmap Content Strategy Documentation Section

Overhauling documentation on continues to be a top priority coming out of our Content Strategy work. As we continue to build out the features that will be the building blocks of the new Sections on, we want to gather feedback about how our existing users are using the Documentation pages and what improvements are needed.

We've added a survey in the lower right hand corner of every documentation page so that users can provide that feedback before our next round of implementation work.

About - Breadcrumbs in Beta

We're also prototyping some of the new features that will be part of the toolbox for Sections on A small feature, but a welcome improvement, is the addition of breadcrumb navigation in the new Section content types. Right now you can see a beta of this in the About section.

Search Improvements

In October we continued our efforts to improve the utility of search on Just in time for the release of Drupal 8, developers can now search for api functions through the search box and receive results from


In October we enabled DrupalCI testing for Drupal 7 and Drupal 6. We are now in the process of validating that testing for these legacy versions is functioning correctly before disabling legacy testbots and statically archiving Drupal 8 testing on the legacy system has already been disabled.

We are also focusing on tuning DrupalCI to economize the testing process. Each Drupal 8 core test job runs over 12,000 tests containing approximately 100,000 code assertions. From September to October we have reduced the average time to complete a core test from 40 minutes to 30 minutes and the average cost of a full test job from $0.37 to $0.24. However, with around 12,000 test jobs run in the past month alone (that's 14,400,000,000,000 assertions!) we will continue to look for ways to manage this expense while providing a better, faster testing service for Drupal code.

Spam Fighting
From Wikimedia Commons
by user Qwertyxp2000

The announcement of Drupal 8's release candidate lead to a surge in spam activities on, and the Drupal Association pivoted to respond, both by fighting the spam directly and by developing new tools for reporting, blocking, and preventing spam for ourselves and the community volunteers who help to fight spam on every day. We made the following changes:

  • We upgraded Flag module to version 3.
  • Our report spam links on now use Flag.
  • We built new views for spam fighters to manage content reported as spam.
  • We increased our rate limiting to prevent bulk submissions.
  • We removed automatic granting of higher user roles - there are now enough Community level users on to confirm new users manually.
  • We eliminated spam targets by fixing content filtering to rel="nofollow" user submitted links in more places.

Going into November we are hoping to implement some new tools from our Technology Supporter Distil Networks to help prevent spam registrations before they occur.

Revenue Related Projects (Funding our work)

Beyond the membership campaign we're continuing our regular work on upcoming DrupalCons. Registration for DrupalCon Asia—the FIRST DrupalCon after the release of Drupal 8!—will open soon. We're very excited to celebrate Drupal 8's release with the local community in Mumbai and with the wider community in Asia.

Design work for DrupalCon Dublin is ongoing in anticipation of the full site launch. In consultation with the local community we have some great design concepts that will really tell the story of Drupal in Dublin. We think you'll really enjoy it!

Sustaining support and maintenance Faster Development Environments

Deploying a hosted development environment for contributing to is one of the critical services provided by the Drupal Association. These environments are used both by our internal staff and by community volunteers who are creating features for As recently as a year ago it has taken up to 3 hours to spin up a new development environment. As recently as September it took around an hour and twenty minutes.

By providing our sanitized nightly snapshot of the database as a docker container we're now able to provide new development environments for in approximately 10 minutes. Even in a short time this has improved our feature development velocity.

Upgrades and Improvements

In addition to improving our development environments, we've focused on upgrading our the operating system on many of our servers to CentOS 6.7, and making sure that our Solr infrastructure is highly-available.


As always, we'd like to say thanks to all volunteers who are working with us and to the Drupal Association Supporters, who made it possible for us to work on these projects.

Follow us on Twitter for regular updates: @drupal_org, @drupal_infra

Personal blog tags: whats new on
Categories: Drupal

Drupal core announcements: Drupal 8.0.0-rc4 on Thursday, November 12, 2015

6 November 2015 - 1:22pm
Start:  2015-11-12 16:00 - 17:00 America/Chicago Organizers:  xjm catch Event type:  Online meeting (eg. IRC meeting)

In preparation for the scheduled release of Drupal 8.0.0 on Thursday, November 19, we will create the final release candidate for Drupal 8.0.x, Drupal 8.0.0-rc4, on Thursday, November 12. We have added this release candidate in addition to the scheduled release windows to provide a final testing target for changes during the RC phase. (Unlike other release candidates, this release window will not include a 24-hour code freeze.) Plan to help test this final release candidate for bugs and regressions during the final week before 8.0.0's release!

Following RC4, we will further restrict the patches we commit to severe bugs or regressions and documentation fixes only, at committer discretion. So, if you have any allowed RC changes underway, plan to complete them by November 12.

There will not be a separate release candidate on November 18. (The November 19 release date is an extension of the November 18 release window.)

Categories: Drupal

DrupalCon News: Session Submissions In Review

6 November 2015 - 11:50am

Thank you for all of the session submissions for DrupalCon Asia! In true Drupal fashion, we had a huge surge in the last few days/hours of session submissions to bring us to a total of 349! We are already busy working to make our selections, but check out some stats about the process in the meantime.


Categories: Drupal

Pantheon Blog: Easily Install Drush with a Phar

6 November 2015 - 10:45am
Composer has helped quite a lot in the area of installation and dependency management for Drupal and Drush; however, users who want to get a quick start with Drush are sometimes put off by the Composer-based install.  As of the Drush 8.0.0-rc3 release, it is now possible to install Drush using a phar. This requires fewer steps than the previous method. First, navigate to the Drush project page at
Categories: Drupal

Advomatic: Upgrading to Drupal 8: through the client’s eyes

6 November 2015 - 10:17am

The Northwest Atlantic Marine Alliance (NAMA) advocates for healthy marine ecosystems. Through their site,, they organize and promote a movement toward a thriving ocean and a just seafood system. Having helped create the original Drupal 6 site for NAMA in 2008, it’s been a rewarding experience re-architecting it in Drupal 8 (beta). The main purpose... Read more »

The post Upgrading to Drupal 8: through the client’s eyes appeared first on Advomatic.

Categories: Drupal

Acquia Developer Center Blog: Drupal and the Raspberry Pi

6 November 2015 - 9:37am
Jeff Geerling

For the past few years, I've been fascinated with credit card-sized budget computers, most especially the one that started the current revolution in hardware hacking, the Raspberry Pi.

Tags: acquia drupal planetdrupal 8internet of thingsraspberry piansibledevops
Categories: Drupal

InternetDevels: Drupal 8 release: great parties are on the way!

6 November 2015 - 7:39am

Great news about the "great 8" brought to you by InternetDevels Drupal team ;)

Drupalers, hold your breath and count to 8! This moment is approaching! “The great 8” A.K.A Drupal 8 will be finally released on November 19. Yes, officially! Yes, for sure! :)

Read more
Categories: Drupal

Zengenuity: October's Most Interesting New Drupal Modules and Themes

6 November 2015 - 5:05am

Some of the most interesting new modules and themes I saw posted to in October:

Views Manager [sandbox]

Gives you vertical tabs on the Views admin page, separating Views by their tags.


Allows for speedier page loads for authenticated users. First you send the fast, cached parts of the page, then fill in the expensive parts when they are ready.

Accelerated Mobile Pages (AMP)

Make your Drupal site ready for Accelerated Mobile Pages. Right now, it only adds the AMP javascript library, but the plan is to serve AMP pages directly from Drupal.

OG Multiple Paths [sandbox]

This module creates multiple paths for the same node using Organic Groups and Pathauto. It’s not best practice for SEO, but it’s nice in situations where content is posted to multiple groups, and you want the node path to reflect the group context the user is currently in.

Menu Link Field

Provides a field similar to the menu link form on node forms but for any entity type.

Human Behavior

An anti-bot technology that looks for mouse movement and mobile device touch events to determine if a bot is filling out a form.

Views Numeric Range Filter [sandbox]

It gives you a numeric filter for Views that includes a +/- tolerance. So you can say 100 +/- 10%, and it will give you results between 90 and 110. Neat!

Address Field Lookup [sandbox]

Integrates the Address Field module with validation services to correct address formatting issues.

Features Export Explode

Breaks your features into a bunch of different files, which makes it easier to see what changed when you review a git commit. For example, it breaks each view out into its own file.


An example theme for Drupal 8 that shows you how to use the new features of the D8 theme system. Heavily commented to explain your options.

Commerce Cart Link

Provides a new field formatter for Add to Cart fields attached to Commerce products and product displays that is a simple link, rather than a form. This way users can buy a product without invoking the full Form API on each product item.

CRUD log

Captures and logs all node CRUD operations, “create”, “read”, “update” and “delete”. This module logs the events in a custom table and exposes the data to Views. It allows you to select which operations will be captured, so you can turn off read events if that is too verbose.

User Moderation [sandbox]

A user moderation system that uses votes from other users to decide if a user is a spammer or not.

Responsive Menu Combined

Allows you to combine multiple menus into the responsive hamburger menu with tabs in it.

Mailsuite [sandbox]

Provides a unified administration interface for managing the templates of all the emails you send from your Drupal site.

Twig PHP Filter

Ha! If you love doing everything wrong and putting PHP code in your template files, this is the Drupal 8 module for you. If you’re slightly less crazy and only want to query the DB from your twig files, then the new Little Bobby Tables module may be a “better” choice.

Categories: Drupal

Microserve: Drupal Migration Tips

6 November 2015 - 1:32am
Drupal Migration TipsNov 6th 2015

As part of our recent work on, we performed a large data migration and transformation of hundreds of thousands of rows of data into their new Drupal 7 site, including users, taxonomy terms, nodes and comments. We did this using a combination of the migrate, migrate_d2d and migrate_extras modules, as well as a custom module to house all of our own migration code. During this process, I’ve collated some tips and tricks that I found useful.

Use Drush

I’d suggest tha tyou use Drush to run the migrate commands rather than using the Migrate UI. I’ve found it to be more robust because I’ve had migrations fail when being run via the migrate UI, only to run successfully when executed via Drush.

There are the main Drush migrate commands that you can run:

$ drush migrate-import (mi) $ drush migrate-stop (mst) $ drush migrate-reset-status (mrs) $ drush migrate-rollback (mr)

To see a full list of the available Drush Migrate commands, run $ drush --filter=migrate.

Use prepareRow() and drush_print_r()

If you’re used to using functions like dpm(), dsm() or kpr() in your module code to find out a value of a variable, or what properties an array or object has, there's a similar function in Drush - drush_print_r(). This outputs data to the screen in the same way that PHP’s print_r() function does.

I tend to use it within the prepareRow() method to see what data is available within the $row object.

protected function prepareRow($row) { drush_print_r($row); }

If you are using migrate_d2d or extending another class, remember to use parent::prepareRow() to add to the preparations in the parent class rather than overridding them, and also to skip the row if was skipped in the parent class.

class RoadccPageNodeMigration { ... protected function prepareRow($row) { if (parent::prepareRow($row) === FALSE) { return FALSE; } } } Limit the Number of Items that You Are Importing

Rather than waiting for an entire migration to run to confirm if your latest script amend or addition worked, you can run a migration on a reduced number of items by using the --limit option.

drush mi RoadccPageNode --limit=”10 items”

You can limit by the number of items, such as "10 items", or by the amount of time, such as "60 seconds".

Update, not Rollback

You can also save time by using the --update option to update any already-imported rows, rather than rolling back and removing them, then re-importing.

drush mi RoadccPageNode --limit="10 items" --update Use addSimpleMappings()

As part of each migration, you need to map the source values to the approprate destination using the addFieldMapping() method. For example:

$this->addFieldMapping('destination', 'source');

If, however, the source and destination names are the same, you can use the addSimpleMappings() method. This just takes a list of property names in an array and automatically uses each one as both the source and the destination.

$this->addSimpleMappings( array( 'uid', 'created', 'changed', 'field_foo', ... ) );

If you are using migrate_d2d then some of the common properties - e.g. uid, created, changed - will already be mapped in this way in the parent class.

Use addUnmigratedSources() and addUnmigratedDestinations()

If you use the Migrate UI, then you may see messages like the one in this image. In this example, there are 108 unmapped destination properties, although the same can happen for sources (properties attached to the data being imported). These may be intentionally not mapped, a newer source database has added more sources following a schema update, or a new module has been installed and has added more destinations.

If you do mean to intentionally not map a source or a destination, then use the addUnmigratedSources() and/or the addUnmigratedDestinations() method within your constructor after declaring your field mappings.

Both methods take an array of property names to declare as unmigrated, and will therefore mark them as mapped and remove the error.

public function __construct(array $arguments = array()) { ... // These fields are not being migrated, so mark them as such. $this->addUnmigratedDestinations( array( 'field_one', 'field_two', 'field_three, ) ); }

This makes it much clearer when you or a colleague re-visits this migration at a later date that these were intentionally not mapped and not forgotten about or were not present when the migration class was written.

Write your own base Migration Classes

Because migrate is based on object-oriented classes, these can be extended and customised as needed, making them extremely flexible. I’ve found this to be very useful when I needed to do something that needed to apply to all migrations, such as getting the database connection, or something affected all migrated nodes, such as replacing full URLs with relative ones so that they work on different environments, or mapping the source node ID values to the destination ones.

This is done by writing our own abstract classes that extend the default ones such as Migration or DrupalNode6Migration. Because we’re using the abstract keyword before the class name, we ensure that these classes cannot be instantiated directly, and must be extended by another class.

Extending a Normal Migration Class class RoadccMigration extends DrupalMigration { protected function getConnection($connection = 'migrate') { return Database::getConnection('default', $connection); } }

In this example, we can use $query = $this->getConnection() as the starting point for any classes that extend RoadccMigration, and then continue building the query using the db_select() syntax. This means that there is less duplication within our custom classes, and it makes it easy to update if needed as it’s only declared once.

Extending a migrate_d2d Class abstract class RoadccNodeMigration extends DrupalNode6Migration { public function __construct(array $arguments = array()) { parent::__construct($arguments); } protected function prepareRow($row) { // Update any absolute URLs. foreach (array('body', 'teaser') as $property) { if (isset($row->{$property})) { if (strpos($row->{$property}, '')) { $row->{$property} = str_replace('', '', $row->{$property}); } if (strpos($row->{$property}, '')) { $row->{$property} = str_replace('', '', $row->{$property}); } } } } }

In this example, we’ve extended the DrupalNode6Migration class from the migrate_d2d module, and are performing some transformations on the body and teaser values - removing the full URL so that users aren’t redirected back to the original production site rather than to their intended destination.

As all of our node migrations extend RoadccNodeMigration, this automatically applies to all nodes imported via the migration.

Limit your Result Set

If you need to test something, like if all of your field mappings are working, I found it beneficial to find a small collection of examples that would cover all use cases, and then limit the query so that the migration would only affect those nodes, rather than reguarly searching for the right examples to test against.

If you’re writing normal migrations you can do this in your __construct() method as part of your query. If you’re extending a migrate_d2d class, then you’ll need to add your own query() method and add the additional conditions to the query from the parent class.

For example:

class RoadccPageNodeMigration extends RoadccNodeMigration { ... protected function query() { // Get the query from the parent class. $query = parent::query(); // Add any new conditions. In this case, just filter on this single node. $query->condition('n.nid', 123456); // Return the new, full query. return $query; } }

This means that you can quickly re-run that migration and see how your changes affected the result, if at all, rather than waiting for the entire migration to be re-run on of hundreds or thousands of nodes.

Just remember to remove the test conditions when they are no longer needed. If you use Git for version control, I’d suggest using git add -p to interactively add chunks of code to the staging area, allowing you to review each one and keep your code repository clean of any test conditions.

Written by: Oliver Davies, Senior Drupal Developer

Microserve is a Drupal Agency based in Bristol, UK. We specialise in Drupal Development, Drupal Site Audits and Health Checks, and Drupal Support and Maintenance. Contact us for for further information.

Categories: Drupal

about seo