Skip to Content

Planet Drupal

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

Wunderkraut blog: Bernt & co’s Drupal Gotchas Second Edition

3 July 2014 - 6:47am

Half a year ago I wrote a blog post about various stumble blocks I had run into in my first year as a Drupal developer. I called them gotchas because they were not necessarily bugs - they might just be Drupal’s way of doing things which may confuse people new to or experienced with Drupal. Sometimes they are annoyances - they could be called paper cuts too. The post got some attention - which was great because people started sending me tips about things they ran into. Now there is time for a new round!

Half a year ago I wrote a blog post about various stumble blocks I had run into in my first year as a Drupal developer. I called them gotchas because they were not necessarily bugs - they might just be Drupal’s way of doing things which may confuse people new to or experienced with Drupal. Sometimes they are annoyances - they could be called papercuts too. 

The post got some attention - which was great because people started sending me tips about things they ran into. Now there is time for a new round! 

First I’d like to start with an update to my previous post - good news! 

Outdated gotcha: Features module and taxonomy

In the comments Damien McKenna pointed out

Features v2 now uses the machine name and labels for permissions, roles and vocabularies, making exporting those much easier than it used to be.

Which is true. It was just that we were using the “Taxonomy Access Fix” module in that project, and it was not using the machine names. But that module has been updated to also use vocabulary names. Things do get better in Drupal! 

New gotchas I have foundGOTCHA 1: Trying to be consistent about naming? Not too fast! 

I can’t believe that I didn’t stumble into this one before, I have a feeling it hits a lot of people new to Drupal: When starting a new project, you might want to be consistent about naming, and give a custom project module and theme the same name. 

Well, buddy, that is asking for trouble! And different trouble every time to confuse you even more - a search of any error message that pops up might not give you the cause as the first result in Google. 

This duplicate naming problem can of course happen between your own custom modules and contrib projects you add from 

Andreas also adds that you will also run into trouble if give your site profile the same name as your theme (and possibly also module names). 

This is documented in Drupal's documentation, which you of course have read thoroughly:

Tips for best practice in naming:

Gotcha 2: Where was that module again? 

In a direct response to the original blogpost, reddit user tranam mentioned: 

The biggest gotcha in Drupal, as far as I'm concerned, is having a modules folder, and a sites/all/modules folder.

Gotcha 3: Updating a module doesn’t 

Lauri mentioned this:

You're trying to update a module and it doesn't update. drush up, drush updb, disable, enable, delete, download, etc.. and it's still the same! Then a colleague points out the obvious: You have the module installed in more than one place, like /sites/all/modules and /sites/all/modules/contrib or even a submodule of another module.

To find out if this is your problem, you can run SELECT * FROM system  to see the actual path that drupal has associated with a specific module. 

Gotcha 4: The pesky feature that won’t revert (multilingual sites)

So you just pushed a git commit to a server, and you’re trying to revert the feature, but it just won’t happen. You have tried the magic cache-clearing/php-fpm reloading/cache-clearing incantation several times already, but no no no no go. 

Then you look at the feature diff, and you notice that .. you were looking at the feature page in a different language from it was made in. Aargh! 

Gotcha 5: Browser based language detection is killed by page caching

Florian told me abot this one: If you have page caching enabled the browser based language detection will not work due to a bug in core.

This dropbucket snippet might work for you though:

Gotcha 6: Dragging and dropping around in panels don't work

Juho V tipped me about this one - and Sampo provided the workaround: 

[11.57.59] Sampo: Sulla on exposed formi tossa. Disabloi se view, draggaa toi paikalleen ja toimii.

Decrypted from Finnish it reads: You have an exposed form in there. Disable that view, drag it to it’s position and it will work. The exposed form is what breaks the drag and drop, so you better just disable that display. 

Gotcha 7: Administer Content permission is powerful but not that powerful

Mario notified me about this one: 

Administer Content permission sounds all powerful: But if you're not user 1 you can still not access unpublished content if it is not edited by yourself. 

You also need "Bypass content access control" permission - or you could use the “view_unpublished” module. 

Gotcha 8: Multiple meanings of “vid” in the database

This has baffled me, at least, when poking around in the database trying to figure out how to solve a case. And I am not the only one:

marcvangend at Drupal Answers writes in :

Unfortunately, vid can mean multiple things. That's not ideal, but I have not seen it causing problems (other than mild confusion now and then).

In the context of nodes, it means 'version id'. For every node in the node table, Drupal can save multiple versions in the node_revisions table. The version id is the unique identifier in the node_revisions table. (This is the vid you see in your query.)

In the context of taxonomy, vid means 'vocabulary id'. A vocabulary is a collection of related terms. Every vocabulary has a unique id.

In the context of the Views module, vid means 'view id'.

Gotcha 9: EntityFieldQuery executed from cron checks access right

Teemu reported this one: If you are running EntityFieldQueries from cron, you might not get the expected results because EFQ does indeed add it’s own access checks. 


$query = new EntityFieldQuery(); $query->entityCondition('entity_type', 'node') ->fieldCondition('field_something_id', 'value', $something_id) ->addMetaData('account', user_load(1));

The last line makes it sure its loaded as Dries. 

An alternative is apparently to use this one (which was added in Drupal 7.15):    

->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT') Gotcha 10: Blocking users does not block immediately

Reigo reported this experience: 

I once discovered a blocked user who had logged in before he was blocked, and he was still active! So after blocking, empty the session table.

Note: Emptying the session table will also log out ALL the site’s users - so you might think twice about that. One option is to remove the session for that specific user id. 

Gotcha 11: Want to disable the query pager? We’ll trip you up

If you have a query object and wish to return all items, you might try and set the limit to null or false to disable the pager. No go:

public function PagerDefault::limit


Specify the maximum number of elements per page for this query. The default if not specified is 10 items per page. $limit: An integer specifying the number of elements per page. If passed a false value (FALSE, 0, NULL), the pager is disabled.

Did you think that a disabled pager would return all results? Sorry, daften states this

I would expect disabling the pager would mean everything is shown, instead nothing is returned.

Gotcha :) 

Gotcha 12: Views with date filter not returning what you want

I was struggling with a view with filters for a date field, that did not return what I wanted. I suppose the following conversation speaks for itself: 

[15:08:17] Ilmari: ha! [15:08:19] Ilmari: I got it [15:08:26] Ilmari: Guess what, its the granularity [15:08:32] Ilmari: It is set to "day" [15:08:38] Ilmari: instead of seconds [15:08:56] Ilmari: In the "settings" part of the filter (separate settings) [15:09:16] Ilmari: Filter granularity => Day [15:09:21] Ilmari: should be => Second [15:10:36] Ilmari: Did you find "Filter granularity" under "Settings" for the filter? [15:11:08] Bernt: I didn't find that [15:11:09] Ilmari: Pretty annoying that the default is a day [15:11:18] Ilmari: Content: Date - end date:value2 (yesterday) | Settings [15:11:25] Ilmari: --> "Settings" [15:11:32] Bernt: Oh hah there!! GRRRRRRR hitting my head in the wall [15:11:36] Ilmari: :D [15:11:36] Bernt: or on the desk, it is closer [15:12:02] Ilmari: I've encountered that exact problem several times, i always forgot to check those settings.. [15:12:22] Ilmari: ..and the default "day" granularity doesn’t really make sense, usually [15:12:56] Bernt: Thanks man [15:13:45] Ilmari: heh [15:13:50] Ilmari: Glad I could help this time [15:13:50] Bernt: Well, another GOTCHA for my list

So when you are working with a date field in views, remember to check what the granularity setting of the field is. Date defaults to day, which doesn’t work too well if you are more interested in now! 

Gotcha 13: Site name in a feature that depends on .. 

Florian reported this find: 

Don't export the site name in a feature that's a dependency of an installation profile, or you won't be able to install. 

It just happens that the installer checks the site name to test if Drupal has already been installed or not, so if you add that variable to a feature, then it thinks that the installation has already been done.

In the meantime, you can just set the title during an install task (that runs later in the process). 

Categories: Drupal

Deeson Online: Google Webmaster Tools - Part 3: Getting Results

3 July 2014 - 2:48am

In part one of this series I gave an overview of Google Webmaster Tools.

In part two I had a look at a bit more detail at some of the areas that I have found useful to understand when reviewing a site's listings in Google. In part three, I am going to look at how, having analysed this data, you can help to improve your site's listing in Google.

As mentioned in part one I am not an SEO expert, so this shouldn’t replace consulting/using SEO experts, but it will hopefully help you to be able to cover the basics without having to spend loads of money.

Search Traffic

This section wasn’t covered in part two of this series, but is hopefully fairly self explanatory and will help you analyse where to perhaps focus your SEO. Search Queries: This shows the list of most searched terms that have driven traffic to your site. This can help you target various key pages etc, and help you think more about the wording of your pages, to try and help you get more natural listings in Google.

Crawl details

Having had a look at the various data within the crawl details sections, you should then be able to understand pages that are generating errors on your site and look at what needs to be done to fix them. Key errors that you should concentrate on are ‘Server errors’, ‘Soft 404 errors’ and ’Not found’ pages.


Looking at the sitemaps section can be slightly addictive as you watch the graph (hopefully) increase as Google indexes more and more of your content. Sometimes you take a look at it (thinking that everything is working alright) and see a problem with the number of pages being indexed. We had a client that I was working with a while ago and when we looked at their sitemap in Google Webmaster Tools, the number of pages being indexed fell well short of the number of pages being sent to Google. Their sitemap.xml file contained around 240,000 URLs, but only around 10,000 were actually indexed. Looking at the site, it was set up to send Google a new sitemap.xml every day. By changing this to send it to them weekly, this increased to a regularly indexing of around 225,000 URLs. It seems that Google wasn’t able to index all the pages in just one day and kept starting again each day, so was never getting to the end of the list. Google says that they can’t guarantee to index all of your site, but to have over 90% over the pages indexed was a lot better than only 4%.

That's all folks!

Although I haven't covered Google Webmaster tools in great detail, hopefully you will now feel more confident looking through and using it. It is a great tool for analysing your sites to see how you can get better performance from them in terms of user experience and for your search rankings.

Read moreGoogle Webmaster Tools - Part 3: Getting ResultsBy Mike Davis | 3rd July 2014
Categories: Drupal

Károly Négyesi: Double theta to compute delta

3 July 2014 - 2:46am

We are denormalizing into a field past migration; while usually I freak out writing directly to the field tables in this case it's justified because it's a custom module (never do this in contrib) and also because we are well aware of what does not happen when you do that. With that said, we have a query that roughly looks like this:
INSERT INTO {field_data_field_denorm_data}
(entity_type, bundle, deleted, entity_id, revision_id, language, delta, field_denorm_data_target_id)
SELECT 'user', 'user', 0, field1, field1, 'und', ????????????, field2
FROM table1
.... long complex query where a single field1 has several field2.

So yeah. But delta... delta is a problem. MSSQL has ROW_NUMBER(), MySQL does not and the usual replacement (user variables, @x:=@x+1) is documented to be incorrect and not reliable. There's a lesser known trick that can be used, however:
SELECT DISTINCT field1, field2
.... long complex query repeated

now, ALTER TABLE tmp ADD KEY(field1) in preparation, and then:

INSERT INTO {field_data_field_denorm_data}
(entity_type, bundle, deleted, entity_id, revision_id, language, delta, field_denorm_data_target_id)
SELECT 'user', 'user', 0, t1.field1, t1.field1, 'und', COUNT(*) - 1, field2
FROM tmp t1
INNER JOIN tmp t2 ON t1.field1=t2.field1 AND t1.field2 >= t2.field2
GROUP BY t1.field1,t1.field2

Double theta for the win.

Explanation (numbers copied from real data):
| t1.field1   |t1.field2 | group_concat(t2.field2)         |
|        4440 |      427 | 427                             |
|        4440 |      428 | 427,428                         |
|        4440 |      429 | 427,428,429                     |
|        4440 |      433 | 427,428,429,433                 |
|        4440 |      435 | 427,428,429,433,435             |
|        4440 |      436 | 427,428,429,433,435,436         |
|        4440 |      438 | 427,428,429,433,435,436,438     |
|        4440 |      439 | 427,428,429,433,435,436,438,439 |

Consider the user 4440. When t1.field2 is 427, when joining with t2, there's only itself when joined, so the count is 1 , delta is 0. When t1.field2 is 428 now we have two, namely 428 and 428, so the count is 2 and the delta is 1. And so on. The unsaid, implicit trick is that MySQL orders on what you group.

Categories: Drupal

Don't Panic: A blog about Drupal: More reliable Drupal statistics?

3 July 2014 - 2:23am

Fact: Using the Update module for collecting data has been the standard since Drupal 6.0.
Another fact: Sites not using that module aren't submitting usage statistics to
Yet another fact: Third-party monitoring services are rendering the Update module rather useless.
Result: Misleading statistics on Drupal core and module usage.

When Drupal 6.0 was released the Update module started submitting statistics to, a great initiative. Though, you can disable this module for different reasons, thus creating misleading statistics on The same goes for Drupal 7, you can disable the module there as well.

Categories: Drupal

DrupalCon Amsterdam: Symfony Community: Come to Amsterdam!

3 July 2014 - 1:00am

Symfony components have a significant presence in Drupal 8, and for those in the Symfony wanting to make themselves even more knowledgeable and marketable, DrupalCon Amsterdam is a great opportunity to learn new skills and make great new friends.

Just a few weeks before SymfonyCon in Madrid, DrupalCon Amsterdam runs from 29 September to 3 October and will have its own Symfony track. It will be a great opportunity to learn Drupal 8: with Symfony2 components included in core, parts of Drupal 8 will look very familiar to developers who currently use Symfony, as will the object oriented programming methodology.

If you’re considering coming to DrupalCon Amsterdam, you probably know that Drupal skills have been in high demand for years. That trend is only expected to continue and perhaps even accelerate with the release of Drupal 8— and Symfony developers are uniquely equipped to learn the platform quickly and hit the ground running.

DrupalCon is the best place to learn Drupal 8

If you’re interested in learning more about Drupal 8, DrupalCon Amsterdam will be a fantastic opportunity. The world’s foremost experts on Drupal and Drupal 8 will be in attendance, giving interested developers plenty of opportunities to learn.

Every DrupalCon is attended by more than just developers: the Drupal community includes web professionals of all stripes. From project managers to designers, back-end experts and even UX gurus, DrupalCon Amsterdam is a great chance to learn from the people who are working on websites at every point in a site’s lifecycle.

Plus, DrupalCon is always a good time. Expect a lot of smiles, laughs and even a few hugs (OK, maybe a lot of hugs).

If you’re interested in Drupal or Symfony, come to DrupalCon Amsterdam. You will be glad you did!

Categories: Drupal

about seo