Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough
Oct 07 2020
Oct 07

There are several stable contrib modules available that offer redirecting users - often as one of many functionalities. In some cases however, you might want to write your own module in order to precisely control what it does. Or perhaps you would like to combine this code with other specific requirements into a custom module. 

Whatever your particular reason, here’s how redirect users the proper way in Drupal 8:

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;

 * Implements hook_form_FORM_ID_alter().
function MYCUSTOMMODULE_form_user_login_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $form['#submit'][] = 'MYCUSTOMMODULE_user_login_form_submit';

 * Custom submit handler for the login form.
function MYCUSTOMMODULE_user_login_form_submit($form, FormStateInterface $form_state) {
  $url = Url::fromRoute('/your/destination/path');

For Drupal 8 in particular, it is important to note that we no longer use hook_user_login(), because it would stop other implementations of that hook to be invoked. Instead, we’re adding a custom submit handler to the user login form.

Of course this is just a starting point. You could add certain conditions or redirect users to different paths depending on their user role. 


Hope this helps! Please don't be afraid to reach out if you need any help with your Drupal project. Our experts are always happy to help!

Sep 23 2020
Sep 23

The main reason for the global arg() function to be deprecated in Drupal 8 and onwards is that it no longer served any specific need. Besides that, using the arg() function needed some extra care to avoid getting unexpected results. Say that you wanted to load a node on the path 'article/123', executing arg(1) would return '123' with which you could load the node. Using the '123' returned by arg(1) did not in any way guarantee that the path was valid or even that a node with ID 123 existed.

In Drupal 8 and onwards things are done differently. Consider the following:

$node = \Drupal::routeMatch()->getParameter('node');
if ($node instanceof \Drupal\node\NodeInterface) {
  $nid = $node->id();
  // Do whatever you need to do with the node ID here...

Getting the node ID this way is far more robust than doing so the old way using the arg() function. We know for sure the node exists and the path is valid because routeMatch() would not return a node object otherwise. As a bonus you can easily do some extra validation because you already have the node object loaded. You could, for instance, check that the node is of type 'article' by adding:

if ($node->bundle() == 'article') {

Getting the node ID this way may seem like a lot more work than using the deprecated arg() function, but it certainly guarantees a way more robust way of working which in turn will make your code better and more stable.


Need help developing your Drupal website? Our team of expert Drupal developers would be more than happy to help you out!

Jun 17 2020
Jun 17

This is not a migration

Previously, a major version update for Drupal implied a time-consuming migration process. It usually involved content migrations, configuration changes and porting modules to enable them to work properly. In some cases, migrating took nearly as much effort as rebuilding a site from scratch. 

This time however, upgrading will most probably have none of that. In fact, according to the founder of the Drupal project, a key target when developing Drupal 9 was ease of upgrade (https://dri.es/making-drupal-upgrades-easy-forever). Version 8 was all about dealing with technical debt so that future releases would be like they are in WordPress: painless, fast, and fun. With Drupal 9, this has finally been accomplished.

There’s plenty more shiny new stuff under the hood that propels Drupal into this new era of digital experience frameworks.

What’s great about Drupal 9

Ease of upgrade is not the only new feature in Drupal 9. There’s plenty more shiny new stuff under the hood that propels Drupal into this new era of digital experience frameworks. What we are most excited about is its API-first development. Drupal now includes JSONAPI in core. This means Drupal is no longer the traditional monolithic cms we’ve come to know. Instead, it is now built to support headless applications, third-party data integrations and pretty much any modern innovative use cases for the open web. Furthermore, editorial flexibility and content management experience both took huge leaps forward.

Upgrading from Drupal 8

Drupal site owners who have been keeping their Drupal install up-to-date are in for the smoothest ride. The only differences between Drupal 8.9.0 and Drupal 9 is the removal of some deprecated APIs and the inclusion of updated third-party dependencies, such as Symfony and Twig. As long as the modules you have in use do not rely on deprecated code or libraries, you should be good to go.

This how our Drupal experts prepare for a smooth operation when upgrading a Drupal 8 site to Drupal 9: 

  • Ensure that a site is running the latest stable version of Drupal 8 and any contributed modules installed
  • Install and run the Upgrade Status module. This tool integrates into the site’s status update to check system requirements and contrib module compatibility for Drupal 9.
  • If we run into contrib modules with compatibility issues, scan the respective module’s Drupal.org page and issue queue to find out about their Drupal 9 readiness and possible solutions or workarounds.
  • Check custom modules for use of deprecated libraries or APIs. The Rector module is often very helpful. It automates PHP code upgrades by renaming classes, methods, properties, namespaces and constants.
  • Check the hosting environment and make necessary changes if needed. The Upgrade Status module should point out the system requirements for Drupal 9.

After completing these steps, we are ready to update the Drupal core to version 9.

Upgrading from Drupal 7

For Drupal 7 site owners, there is no clear upgrade path. Upgrading from Drupal 7 usually involves rebuilding the site in the new version and migrating all content and configuration to the new site. This may require more resources, but it is a great opportunity to rethink the site structure and implement some major improvements.

We’re here to help

Whatever your current situation, we are here to help. We combine strategy, design and development on a daily basis to help our clients solve complex business challenges. And our Drupal migration experts are more than comfortable upgrading or migrating any complex website to Drupal 9. 

Send us an email or give us a call to discuss your project with us! We’re happy to help.

Jan 03 2020
Jan 03

That’s nice, now why are you telling me this?

In you role as a project- or site owner you might not be aware of the implications the “End of Life” announcement has if your site is running on Drupal 7 right now. There are two things you should be aware of:

1. Active development of Drupal 7 stops on the EOL date.

This does certainly not mean that your site will come to a grinding halt on that day, but it does mean that Drupal’s strong points will start to fade going forward. The Drupal Association will no longer provide security releases for Drupal 7, no further development on the core framework will be done and development on the Drupal 7 version of most contributed modules will stop.

Security, flexibility and scalability are often reasons why Drupal was chosen for a project and this clearly has an impact. I knowingly say ”impact” because the robustness of the Drupal project prevents a full stop of support even after the EOL date. A number of partners will be selected to provide paid security support for several years and there will always be members of the community who are prepared to do some work on unsupported contributed modules.

2. Upgrading means migrating.

Upgrading your site from Drupal 7 to Drupal 8 means that you have to also migrate all content that is present in your site. The theme that is used to display the content on the site will also have to be re-developed. This only holds true for this specific upgrade and not for later upgrades from Drupal 8 to Drupal 9 for instance, more on that later... The massive structural changes of the inner workings of Drupal are the cause of this, highly inconvenient but certainly necessary to keep Drupal the modern framework we all need it to be.

Performing a migration and re-developing the theme mean that this needs to be discussed and planned well in advance. Depending on the size of your site the time needed may vary, but to wait until the EOL date arrives is obviously not a good idea.

I see, so what should I do?

The sensible thing to do is to start thinking about what steps are necessary to perform an upgrade to Drupal 8. Drupal 8 was released in November 2015, so it has been in production use for over 4 years now. It is a very stable and mature piece of software with a wide adoption worldwide.

As mentioned earlier, “under-the-hood” Drupal 8 changed significantly compared to Drupal 7. Upgrading therefore provides a chance to perform structural and visual changes to your site that you have in mind anyway. It doesn’t make sense to make big changes to your Drupal 7 site when you know that it’s official life will come to an end in 2021. If you now start to plan for incorporating these changes into the Drupal 8 version of the site, you still have plenty of time to thoroughly discuss these changes and efficiently spend your budget when the time comes to actually perform the upgrade.

The same goes for migrating your content. The upgrade provides an opportunity to think about what content you want to keep and how you can put it to it’s best use!

Drupal 9 will be released in 2020, do I have to do all this again? Should I postpone?

Drupal 9 will be released on June 3rd 2020. Since that is less than half a year away, it might seem better to wait a bit and move from Drupal 7 to Drupal 9 directly. That’s where the big “under-the-hood” structural changes in Drupal 8 come in, upgrading from Drupal 8 to later versions will be extremely easy and not require a full migration! This makes the move from Drupal 7 to 8 an exception, once you are on Drupal 8 upgrading can more or less be done with the click of a button!

So migrating to Drupal 8 first makes a lot of sense because you can start incorporating changes into your site directly, without having to wait for a move away from Drupal 7. This way you benefit from being on the new version of Drupal right away and are future proof from that moment on.

Ok let’s do this, how do we perform the migration?

There are 3 parts relevant to the migration from Drupal 7 to Drupal 8: upgrading code, rebuilding the theme and migrating content. To perform a successful migration we first need to understand where you want to go, so we first discuss what the Drupal 8 site will look like before we do anything else. We have extensive project management experience in house that will lead to a clearly defined product to deliver.

Once we know where we are going, it is time to look at the Drupal 7 site we are coming from. For projects we have not built ourselves this usually means we perform an assessment that tells us how the site is built and what we can expect from its content. The assessment’s outcome tells us how much work the migration will entail and forms the basis for an estimated budget and time needed to complete the project.

Do you want us to help you migrate your Drupal website? Contact us for an introductory meeting and get started right away!

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web