Drupal

Drupal @ Penn State: Memory profiling in hooks

Drupal Planet - Tue, 2015-03-03 23:19
To start..

This tutorial involves hacking core. If you aren't comfortable with doing that, you're probably in the wrong place :).  I created a dropbucket.org drop called Memory profiling in hooks which has all the code details in case you want to dig in yourself.  You'll need to modify includes/module.inc and also have devel module enabled for this to work.

Categories: Drupal

Mediacurrent: Premature Optimization is (still) Bad

Drupal Planet - Tue, 2015-03-03 23:13
Knuth is a pretty smart person

A long time ago, in a galaxy right here, Donald Knuth wrote “premature optimization is the root of all evil”. This was in his 1974 paper “Structured Programming With Go To Statements”, yet this issue is still with us in various forms.

Categories: Drupal

Urban Insight: What to visit while at the Los Angeles DrupalCon

Drupal Planet - Tue, 2015-03-03 23:07

So you are planning to visit LA for DrupalCon? Want to site see or enjoy local flavors but not sure where to focus your efforts? I polled the team at Urban Insight, and we collected ected a few of our own favorites that will, hopefully, become some of your favorites as well.

#10 LA Metro

http://www.metro.net/

Categories: Drupal

Open Source Training: How Do I Get a Job in Drupal?

Drupal Planet - Tue, 2015-03-03 19:59

Are you looking for a job? Have you considered working in the Drupal world?

Several OSTraining members have. They wondered about the skills they would need and the income level they could expect.

To give you an overview of what it takes to make a living in the Drupal world, we spoke with Mike Anello. Mike is a long-time Drupal contributor, based near us in Orlando, Florida. If you've ever seen a Dries keynote address at a Drupal, Mike is often the person asking Dries questions at the end.

One of my key takeaways from talking with Mike -  the Drupal jobs are out there, but companies are now expecting applicants to bring more than just Drupal knowledge.

Categories: Drupal

Drupal Association News: Thank you for a great Global Training Day

Drupal Planet - Tue, 2015-03-03 19:31

As many of you know, Global Training Day was this weekend, and it was a great one. We had 29 trainings in 20 countries around the world, showing once again that our community is second to none in passion and enthusiasm.

It's so exciting and humbling to help make GTD a reality. Watching the tweets pour in from around the world is truly awe-inspiring. Here's a selection of a few of our favorites from this year.

For those of you who didn't participate this time around but want to join in next quarter, check our Global Training Day page and sign up to host a training in your community. Again, thank you to everyone who helped make this GTD a reality.

150 new Drupalistas in the last #Drupal Global Trainind Day in Barcelona http://t.co/7nmqhtVPxC . Thanks @DrupalAssoc @lsheydrupal !

— Atenea tech (@ateneatech) March 2, 2015

 

After 8 hours of #Drupal_Global_Training Days at #EPI Sousse #Tunisia #Drupal #DrupalGTD @lsheydrupal pic.twitter.com/eNhx0g5Bih

— Ward Marzouki (@digitives4ward) February 28, 2015

 

 

Drupal Global Training Day concludes at @drupakpakistan #Peshawar #Pakistan #DrupalGTD @lsheydrupal pic.twitter.com/6oS9T1siFF

— Drupak (@drupakpakistan) February 28, 2015

 

Categories: Drupal

Another Drop in the Drupal Sea: Drupal + Udemy = Drudemy. Come join in the fun!

Drupal Planet - Tue, 2015-03-03 18:35

I have settled on using Udemy as my exclusive platform for delivering Drupal education. I'm so excited to start taking advantage of all the great tools the platform offers and I am laying the groundwork for engaging extensively with my students. I've got four challenges I'll be issuing to my students during the month of March, with a prize for each one as well as a Grand Prize at the end. It would be great to have you play along!

Join for free!

Categories: Drupal

Promet Source: Developing the Promet Way: Part III

Drupal Planet - Tue, 2015-03-03 18:30

 

Part I highlighted the challenges of deployments, defined good deployments, and introduced the tools for developing the Promet way. If you haven’t already, you should probably read Part I now.

Categories: Drupal

Drupal.org Featured Case Studies: The Roman Baths

Drupal Planet - Tue, 2015-03-03 18:01
Completed Drupal site or project URL: http://www.romanbaths.co.uk

The Roman Baths is the primary attraction of the six Bath & North East Somerset Council Heritage Services; the Roman Baths, the Fashion Museum, the Victoria Art Gallery, Bath Venues, the Bath Record Office and the World Heritage Site.

The Heritage Services team wished to migrate all six of the websites from Immediacy to Drupal, and included a full re-design as part of the project. The contract was won in open tender by Microserve and Torchbox against stiff competition nationwide.

Torchbox carried out the Design and UX Phase before passing responsibilities to Microserve for the Development Phase. By working to each organization's individual strengths, Microserve and Torchbox were able to provide an efficient and cost effective partnership whilst still keeping a collaborative and concise communication channel between all three parties throughout the project.

Key modules/theme/distribution used: FeedsSassonAdminimal - Responsive Administration ThemeCKEditor - WYSIWYG HTML editorDraggableViewsGatherContentHoneypotStyle GuideFeaturesEntity Construction Kit (ECK)Flex SliderOrganizations involved: MicroserveTorchbox
Categories: Drupal

Cheppers blog: Rebuilding the Cheppers website with Drupal 8: The Age of Innocence

Drupal Planet - Tue, 2015-03-03 17:50

After a lively meeting, the Cheppers team decided to make our new website with Drupal 8. You can read about how and why we made this decision in the previous post. The following series of posts will document our progress, share the important lessons we learn, and highlight any mistakes we make in order to help others as they set out to use Drupal 8. This post will focus on our initial work for this project.

Categories: Drupal

Modules Unraveled: Free Command Line Basics Series is Complete!

Drupal Planet - Tue, 2015-03-03 16:59

Command Line 00 - IntroductionWhen you're just getting started with a new operating system you have to learn how to get around and perform basic actions like navigating the file structure reading and writing files and creating and deleting files and directories. The command line (once you're familiar with its commands) can be used to navigate a computer's file structure much faster than through the GUI (Graphical User Interface). It is also very helpful when working with a remote machine, like a web server. One stumbling block for many first time command line users is the fact that when you first startup your command line, you're just given a blank screen with a prompt where you can type in your command. Since there isn't anything to indicate what you should do next you have to already know the commands before you get started. This series will lay out some of the most basic command line commands. These are the ones you'll likely use every time you start up the command line. We'll take a look at the pwd, ls and cd commands to see where you are in your file structure what files and folders are in your current directory and moving to other directories. We'll create and edit text files with the VI application and learn the basics of utilizing VI. We'll learn how to move, rename, copy and delete files and folders with the mv, cp and rm commands. There are plenty of other commands you might want to know but this is an introductory class and a quick Google search will give you all of the information you need.

TL;DR: Watch the full series here for FREE!

If you're serious about building your Drupal site right, you'll find yourself looking into command line tools like Git and Drush.

If you don't work in the command line on a regular basis, that might be intimidating. Well, not any more!

This series is designed to be a primer on the command line basics, to get you comfortable enough with the command line that you can utilize command line tools without hesitation.

Once you've watched the series, you can move on to the Drush series to improve your Drupal-fu, and will be ready for the upcoming Git series (which will be awesome, by the way!)

When you're ready, you can watch the entire series, for free.

When you do, let me know if you have any questions or comments!

Tags: Command LineBasicsplanet-drupal
Categories: Drupal

4Sitestudios.com Drupal Blog: Inside HubDub Part 1

Drupal Planet - Tue, 2015-03-03 16:07

As we announced previously, 4Site has just released HubDub, a Drupal module that leverages the jPlayer framework and Popcorn JS to overlay web content—such as social media, maps, or web forms—directly onto a video as it plays. So... how does it work?

Storing the Data

The Drupal end of HubDub is relatively straightforward. All of the information about a video is stored in a fieldable custom entity, called HubDub Video. Apart from the usual metadata like title, description, author and a unique identifier, what do we need to keep track of? First, we need the location of the video itself. HubDub needs direct access to an M4V video file (or a live RTMP stream), so we store its location in the URL field. A planned enhancement will let this URL be the actual Vimeo (and eventually YouTube) sharing URL, which is a lot easier for end users to find. The module would then parse out the actual video file location.

For each overlay, we need to track the start time, end time, and the content of the overlay. We could have used Drupal’s built-in field types inside a field group for this, but that can get messy for unlimited fields, so we decided to create a custom HubDub Overlay field type. As a former TV engineer, my first instinct was to use something like SMPTE timecode for the time fields. But jPlayer can’t place overlays with anything approaching frame accuracy, so we went with two simple integer fields, representing the elapsed time in seconds since the start of the video. To make it easier to deal with overlays in longer videos, especially now that HubDub supports live RTMP streaming, we’ll probably use a field formatter (such as the HMS Field module) to display these fields in hours:minutes:seconds.

The overlay field is a textarea, using Drupal core’s Filter module to format the text for display. Allowing custom CSS, Javascript, and jQuery inside overlays opens up some awesome possibilities… and also some not-insignificant security issues. So by default we allow only the Filtered HTML text format, but the administrator can change this for trusted users.

Finally, to declutter the edit form, we provide an administrative title for each overlay, and collapse the field by default.

Displaying a Video

Okay, we’ve now got all of the information about a video stored in Drupal’s database. Now how do we display a video? Well, first of all, where do we display it? By using Drupal’s Entity API we get a page display for each video (almost) for free, but we wanted to give site owners the flexibility to place videos wherever they wanted, so automatically creating a block for each video was a no-brainer.

I’ve created lots of blocks in code before, but I’d never done so dynamically for all instances of an entity type before. It was a lot easier than I expected, as I learned from looking through the Views module. In the hook_block_info() implementation I load all the HubDub Video entities, then iterate through them with a foreach and add each video to the array. Then, in the hook_block_view() implementation, it’s just a matter of calling the callback with the right delta. There are still a few to-dos here, namely dealing with entity titles longer than 32 characters, and adding some caching for performance.

The page callback and block callback are almost identical. Pages need a title, so the page callback sets it, then it and the block callback each call the same display function, hubdub_view_video(). That function loads the HubDub Video entity, then dumps all of the metadata fields for that entity into Drupal's Javascript Settings array. Next, it iterates through all the values of the Overlay field and adds each overlay to the Settings array. Then everything gets passed to a theme function, which loads the tpl.php file that contains the div structure that jPlayer needs, and creates a series of hidden divs with the contents of each overlay. Finally, we attach some CSS, and the Javascript, which is where all the real magic happens. Look for a follow-up post in the coming days on the Javascript side of HubDub.

What’s Next?

The initial release of HubDub is our “minimum viable product.” It works, but there’s so much more we have planned. A few of the things on our roadmap:

  • More granular access control for CRUD operations. Right now, all HubDub actions are controlled through one global “administer hubdub” permission. We’ll soon be adding the Drupal standard edit/delete own/any permissions.
  • Support for additional video providers, including YouTube, and non-m4v file formats.
  • Greater cross-browser HTML5 support.
  • Additional jPlayer options, configurable through the admin UI.
  • Media module support.
  • More user-friendly support for skipping to another point in the same video, or branching to another video, from within an overlay.
  • Better support for overlays on live streams. Right now, overlays are timed from the start of playback, but this doesn’t make sense for live streams. We’re considering just using the server time in hours:minutes:seconds, but we’d love to hear potential use cases and their requirements.
  • Eventually, a more user-friendly way of adding overlays. We’re considering a video player on the edit form, with a button in the player controls to add an overlay at the current playback point.

We're eager to hear your feedback! Please post bug reports, feature requests, and support questions in the HubDub issue queue.

We have even more details to share on how HubDub works under the hood, so stay tuned over the coming days. If you'll be attending the Nonprofit Technology Conference next week in Austin, stop by our booth (#214)! We'd love to chat and give you a demo. If you’re interested in a custom HubDub solution, integration with your CRM or AMS, or video production or editing services, please contact us.

Categories: Drupal

DrupalDare: Google Pagespeed Module and Drupal

Drupal Planet - Tue, 2015-03-03 12:27
Google is trying to make the web faster! Every site owner should be aware off the Google Pagespeed tool (and YSlow) to make sure that the website they are running is as fast as it can be. The optimization tools they offer are great for anyone working with Drupal. But Google have taken it one step further by introducing Google Pagespeed module for you webserver that does a lot of optimization on the fly. The question is - does it make sense for Drupal?
Categories: Drupal

InternetDevels: Drupal modules for social networks integration

Drupal Planet - Tue, 2015-03-03 10:55
1. Service links module

Service links module simplifies attaching additional social links or javascript buttons into the content. It grants advantages to the developers who can add more buttons and rearrange them. It is created on Drupal and for Drupal so that doesn’t include any commercials or spyware.

Read more
Categories: Drupal

Paul Rowell: Drupal Camp London 2015: Improving the CMS user experience

Drupal Planet - Tue, 2015-03-03 03:40

I gave a talk at Drupal Camp London this year, focusing on the UX of CMS users a.k.a the forgottten Drupal user. Below are the slides and a few notes to accompany them.

Categories: Drupal

Aten Design Group: OpenAid 2.0 - A Free, Open Source Website Starter Kit for Nonprofits

Drupal Planet - Tue, 2015-03-03 00:26

For cause-driven organizations, a website is a place to highlight impact, share resources, and build support. While a blog or brochure site can achieve some of these goals, it rarely does it all. Unfortunately, we all too often find organizations confined by the free and low-cost online platforms accessible to them. With that in mind, we’ve built OpenAid. It’s a free and open-source website starter kit developed for nonprofits and grassroots organizations. Its feature set is robust, its architecture flexible, and it can be installed in minutes.

We worked with activists, community organizers, and aid workers to build a platform that serves their organizations’ needs. Here are some of the features we’ve built to allow groups to inspire and connect with others on a scale that truly reflects their impact in the world.

  • Project mapping. Each project or program you add to the site is displayed on dynamic maps, allowing users to see the full scope of your work. Because OpenAid is flexible, you can easily adjust a project to instead be a city or chapter and still take advantage of all of the mapping features.
  • Blog and news. There are subtle but important differences between a News section and a blog, so we decided to build both for ultimate flexibility. Associate authors with your posts to create dynamic profile pages and allow users to track their favorite writer’s work. Reference a project with a post and it will display on a project’s page, creating almost a mini website for that project.
  • Resource library. Share the resources you’ve created with the rest of the world in an easy-to-find way. We’ve added metadata fields such as Resource Type and Topics and provided a filter set and search interface to allow users to quickly discover the tools and materials relevant to them, even if your library has grown to hundreds of documents.
  • Image galleries. Pictures are key to telling your stories and connecting with your supporters. Associate a gallery with one or more projects to highlight events, volunteers, and initiatives specific to that project’s work.
  • Beautiful, responsive design. Design is important and we want your website to look great regardless of device. A color picker allows you to easily adapt OpenAid to reflect your organization’s identity. We’ve also developed it with flexibility in mind so if you add new pages to the site or add fields to a content type, your site will retain that same great look and feel.

You can dig further into OpenAid’s feature set by spinning up a free sandbox site on Pantheon. Or download the distribution at https://drupal.org/project/openaid to install on any server. If you have further questions or would like assistance getting set up with OpenAid, feel free to reach out to me at openaid@atendesigngroup.com.

Categories: Drupal

Shomeya: When Success Starts to Feel like Failure

Drupal Planet - Mon, 2015-03-02 23:55

Last week was awesome, sort of. I hit all the numbers on my guide launch I was hoping for, and then promptly got the stomach flu. After two years (lots of running in circles) of working through this process of launching I did it!

Now it could have just been being sick, but I ended the launch wanting something more. And the reality is this isn't the first time I've been down after a success.

Does that ever happen to you? You get so excited about something and launch it? Then the next day you wonder if you could have done better, or you aren't sure where to go next. It's happened with our clients, we work so hard, we push the code, we launch on time, and then the question of "Now what?" lingers.

Read more
Categories: Drupal

DrupalCon News: Higher Ed Joins the Summit Lineup

Drupal Planet - Mon, 2015-03-02 23:27

This year in Los Angeles, the Higher Ed Summit will be part of the official DrupalCon program for the first time. Along with the Business and Community Summits, the Higher Ed Summit will meet on Monday, May 11.

Categories: Drupal

Drupal Association News: Get Ready to Vote: Elections Run 9 March - 20 March

Drupal Planet - Mon, 2015-03-02 20:51
Huh? What are we Electing?

In case you missed it, the Drupal community electing one candidate to serve a two-year term on the Drupal Association Board of Directors. There are two At-Large (community elected) seats on the Board. The other seat is currently held by Matthew Saunders. We've got a really global slate of candidates to consider, and we encourage you to get to know them by listening to the Meet the Candidates sessions and asking them questions on their candidate profile pages. 

Who can vote?

Voting is open to all individuals who have a Drupal.org account by the time nominations opened and who have logged in at least once in the past year. These individuals' accounts will be added to the voters list on association.drupal.org and they will have access to the voting.

To vote, you will rank candidates in order of your preference (1st, 2nd, 3rd, etc.). The results will be calculated using an "instant runoff" method. For an accessible explanation of how instant runoff vote tabulation works, see videos linked in this discussion.

Elections process

Voting will be held from 9 March, 2015 through 20 March, 2015. During this period, you can review and comment on candidate profiles on assoc.drupal.org and engage all candidates through posting to the Drupal Association group. We'll also be scheduling and announcing three phone-in all candidates meetings, where community members and candidates can ask questions and get to know each other.

Have questions? Please contact Drupal Association Executive Director Holly Ross. Many thanks to nedjo for pioneering this process and documenting it so well in the past!

Flickr photo: Kodak Views

Categories: Drupal

Phase2: How to Override Features

Drupal Planet - Mon, 2015-03-02 18:36

The Features module helps address the shortcoming in Drupal 7 of how to manage and deploy site configuration data.  There are times when you need to change a Feature.  The Features Override module can help with this, but sometimes doesn’t solve the problem completely.  In this article I will discuss all the different ways to override your Features and the common problems associated with that.  While this has been an issue for years, it’s become more common recently with the advent of Distributions such as Open Atrium and Panopoly which heavily use Features and which expect the users to upgrade to new versions.  Maintaining your site customizations when upgrading a distribution using Features Override has become a more common need.

The Problem

How do I override configuration from an existing Feature  within my site-specific project?

Solutions Cloning the base module (not recommended)

If you need to make extensive changes you might need to clone the base module and then customize it.  Disable the original module, uninstall it, then enable your site-specific module.

Pros Cons
  1. You have full control over all aspects of the original module.
  2. Keeps the overrides nicely separate in their own modules that can be enabled/disabled/deployed.
  3. The original Features will never be shown “overridden” (because the original is uninstalled!)
  1. Any future bug fixes, improvements, updates to the original module will not be available.
  2. Since future security patches to the original module won’t be available, this might add a security risk to the project or force maintainers to monitor the original module for updates and apply them to the cloned version.
Using settings.php

If you just need to change a variable (from variable_get) you can do this via the $conf[] array in your site settings.php file.  This method is typically used for environment-specific settings, such as databases, search servers, caching settings, etc.  You can also set the $conf[] array within a custom module if you need to deploy the change across all your environment.  Avoid using variable_set() to change the variable since that will update the database directly as mentioned below.

Pros Cons
  1. The original feature containing the variable (via Strongarm) won’t be marked as “overridden”
  1. Only works for Variables (Strongarm Features)
  2. settings.php not typically part of the code repo, so need to ensure it is version controlled some other way.
  3. Sometimes developers forget to check settings.php for variable overrides, making ongoing support tricky.
  4. Best for Environment variables rather than for any generic Drupal variable.
Update the Database directly

You can create an update hook, or other Drupal hook (hook_enable, hook_install) and update the database directly via SQL or other API functions.  For variables you can use variable_set() to save the new value to the database.  This is only recommended as the last resort for configuration not supported by Features Override.

If you must update the database directly, be sure to only do it once and not in a hook such as hook_init that runs with each page load.  Updating the database on each page load can kill the performance of your site.  With variable_set() you can do this by first calling variable_get() and only saving the value if it needs to be changed.

Pros Cons
  1. Sometimes it’s the only way.
  2. Can keep the overrides separate in their own modules
  3. Only applies specific changes and allows future updates to the base Feature to be used.
  1. Reverting the base feature will change the database back to it’s original value, forcing you to re-run whatever SQL is needed to override it. Can be alleviated by Locking the original base Feature to prevent any reverts.
  2. If the original feature is locked, future bug fixes or improvements might not be available.
  3. The original feature will always be marked as “overridden”.
  4. Some configuration is not stored in the DB, such as Views (or other ctools-based components like Panels) that exist purely in code.
Implement an “alter hook” in code

Most configuration has some sort of “alter” hook that allows it to be modified after it is loaded from the database.  For example, Views calls hook_views_default_views_alter(&$data) to allow you to change any part of a view, whether that view comes from the DB or is in code.  You can create a custom module that implements the desired alter hooks and override the data directly.

Pros Cons
  1. Base Feature will not be marked as “overridden”.
  2. Keeps the overrides nicely separate in their own modules that can be enabled/disabled/deployed.
  3. Only applies specific changes and allows future updates to the base Feature to be used.
  1. Not all configuration has the needed hooks.
  2. Each component has a different hook name and different data structure to modify.
Use Features Overrides module

Similar to the above “Implement alter hook” the Features Override module is designed to create the alter hook implementations for you and export those as new Features modules that you can enable, disable, deploy.

Pros Cons
  1. Base Feature will not be marked as “overridden”.
  2. Keeps the overrides nicely separate in their own modules.
  3. Only applies specific changes and allows future updates to the base Feature to be used.
  4. Features Overrides does the work of figuring out which alter hooks can be used and how to override the data.
  5. Provides a UI for inspecting overrides.
  6. Allows an entire component to be altered (e.g. entire view), or just a single change (e.g. just the title of a view)
  7. Works properly with Features. An Override is just another Feature module on the site.
  1. Not all configuration has the needed hooks.
  2. Can be tricky to “override an override”.
Typical Problems Feature is stuck at being “overridden”

The most common difficulty is a base Feature marked as “overridden” that does not go away when the feature is reverted.  ”Overridden” simply means that the value of the configuration stored in the DB is different from what is stored in the exported Feature code file.  Features literally re-generates the feature export internally from the DB and compares the code with what is stored on disk.  Doing a “drush fd featurename” simply shows the code diff between the code stored on disk (shown in red) with the code generated from the current database (shown in green).

To determine if a Feature is overridden, Features actually takes the generated code, sanitizes it, sorts it, executes it, and then does an md5 checksum on it.  If the two checksum values are different, the Feature is marked as “overridden”.  However, the “drush fd featurename” command shows the actual code difference regardless of if it’s marked as “overridden”.

This behavior means that “drush fd” might output code differences that actually don’t cause the feature to be overridden.  For example, if you change the order of dependencies in your module.info file and then run “drush fd” on the feature, you’ll see it display those changes, even though a “drush fl” won’t show the feature as overridden.

This makes it difficult sometimes to debug why a feature is overridden, since not all of the output of “drush fd” is relevant.  You need to look for actual value changes, rather than just re-ordering changes.

Adding a new module

Sometimes, just enabling a new contrib module will cause your Features (especially field features) to be “overridden”.  If the new module adds some new settings, formatters, widgets, etc then these settings will be active in the DB but not reflected in the code.  So the Feature will be shown overridden.  Reverting the feature won’t have any affect because there is no way to remove the new settings from the DB without uninstalling the new module.

These kinds of overrides are annoying, but not actually that important.  They don’t prevent the feature from being reverted when a new version of the base module is released.  They are not caused by any site-specific change that would be lost by a revert.  Typically it’s best to just document these cases and leave them as overridden.  Just be careful to not become complacent and make a site customization in the future to the same feature and then ignore that it’s overridden and lose your changes when you revert.  You should periodically do a “drush fd” on overridden features just to be sure what is shown is still just from the new module you installed.

A disabled module

Similar to the above, but the opposite case.  If you have disabled a module that was used when the original Feature was exported, then the code might have settings for that module that are no longer in your database.  Once again you won’t be able to remove this by reverting.  Again, you can just document these cases.  But make sure you really need to have the module disabled.  Having a module enabled that you are not using is not a big performance impact.  The time saved in long-term maintenance of the site it typically more important than worrying about an extra module.

A bad override

If you have used some of the not-recommended approaches for overriding a base Feature, such as writing directly to the DB, then you will end up with an overridden feature that cannot be reverted.  Or if the Feature is reverted, you might lose the change that was written to the DB and need to reapply it.  Even if the Feature is locked to prevent reverting, it will still be listed as overridden.

Another type of “bad override” is using the wrong kind of alter-hook to try to modify configuration.  If the alter hook is called in a way that makes it look like a DB change to Features, then Features is going to see a difference between the DB and code and mark it as overridden.

Overridden Views and Panels

Some modules, such as Views and Panels have their own “override” functionality.  These “pure” Features can exist purely in code with nothing in the DB.  When you make a UI change to a View, it gets copied from the code into the DB and your change is made to the DB.  The View is then marked as “overrides code” in the Views listing.  A View that came from code can be “reverted” within the Views UI.  This essentially just deletes the version of the view in the DB so that the code takes affect again.

Sometimes you can get a View stored in the DB that still matches the code.  For example, you change a View in the UI (causing it to be copied to the DB), then you edit the View and undo the change.  Now it matches the code again, but the view is still in the DB.  In this case, the View Feature will not be shown as “overridden”, but in the Views listing it will still say “overrides code”.

When changing a pure Feature like a View via code (like in an alter hook), your changes will take affect immediately, or possible after a cache clear.  No revert will be necessary because there is nothing in the DB to update.  However, in the above case where you have changed a view and then changed it back so it’s stored in the DB, changing the code will not affect the View until you revert the Feature to remove the DB copy of the old view.

In general, if you are having issues with Views, Panels, or other ctools-like pure Features, make sure they are not overridden in their respective UIs.  For example, click the Revert option for the View within the Views listing to ensure it’s actually using the View stored in code.

Wrong version of Features

If the code in the Feature was exported using a different version of Features than what is on your site, there might be changes that cause overrides.  Ensure your version of Features matches the version used to generate the export.  This usually only applies to major version numbers and is not normally a problem.  Normally updates to the Features module are made in backwards-compatible ways to prevent this.  But certainly be sure your version of Features on your site is not older than the version that generated the base code.  Always try the latest version of Features to see if it helps.

Nobody should be using the 1.x branch of Features anymore.  There is no reason for this.  All Drupal 7 sites should be on the 2.x branch.

Unsupported Component

As mentioned, not all configuration components support Features Override, or only support it partially.  For example, Panelizer works with Features, but doesn’t work well with Features Override because it still depends on the specific order of items in it’s config array and when the alter-hook generated by Features Override tries to change something, that array order might not be preserved.  Sometimes in this case you can create your own alter-hook implementation that overrides the code properly.

This might also be an opportunity to help improve Features Override or suggest patches to the module in charge of the configuration to better support Features Override.

Living with Overrides

What if you have tried all of this advice and your Feature is still marked as overridden?  And what if this override represents a specific site change that you need to maintain and ensure never gets reverted?  The solution to this is to “lock” your feature component.  Go to the Structure/Features page and select the Feature that is marked as overridden.  Click the small “lock” icon next to the overridden component in the right column.  The component will still be listed as “overridden” but when you revert your Features the locked component will be skipped, ensuring that your customization remains in place.

When locking your Features, try to only lock the specific component rather than locking the entire Feature.  The downside to locking a component is that any changes to that component from a new version of your distribution won’t take affect.  This is similar to the consequences of the “Update the Database directly” option listed above.  However, sometimes this is the only alternative.

Conclusion

Just keep in mind that both Features and Features Override are just implementing hooks (normal hooks for Features, alter-hooks for Features Override) that are exposed by Drupal or contrib module.  If those hooks don’t exist or don’t work properly there isn’t much Features or Features Override can do about it.  Drupal 7 doesn’t have any sort of configuration management in core, so every contrib module does it differently.  ctools-based modules have more of a standard framework, as does entity API.  Features itself tries to add code to handle core components such as Fields, Content Types, etc that don’t have the needed hooks.  But there is often a limit to how much Features can do and just patching stuff into the DB is not usually a good solution.

Don’t “hate” Features or Features Override.  Life was much worse without them.  They are the best solution to solving configuration management problems in Drupal 7.  They have been developed over years of experience.  Try to help improve them before trying to implement your own configuration or override architecture.

Drupal 8

Don’t count on Drupal 8 magically solving all of these issues.  The Configuration Management Initiative (CMI) within Drupal 8 was focused on handling site configuration, but not on “bundling functionality”.  It provides an API, storage mechanism, and framework for deploying configuration.  CMI helps a lot, but there are still issues around around component granularity and overriding configuration.  In Drupal 8, configuration is owned by the site rather than owned by a module.   This will make bundling functionality (ala Features original intent) more difficult.  We will be working on Features for D8 soon, but this is still mostly unknown territory.  For now, take a look at some existing modules such as config_packager and config_devel.

I’ve submitted a session to DrupalCon Los Angeles on Features in Drupal 8.  Add a comment and support!

Categories: Drupal

Drupal core announcements: No Drupal 6 or Drupal 7 core release on Wednesday, March 4

Drupal Planet - Mon, 2015-03-02 17:52

The monthly Drupal core bug fix/feature release window is scheduled for this Wednesday. Unfortunately, due to travel, work, and various other scheduling issues, I was not able to find the time to volunteer to get a Drupal 7 release together for this month. There are also a number of important Drupal 7 patches in development that could probably use another month before they are ready.

Since there hasn't been a bug fix/feature release of Drupal 7 since November, the hope is to get one out in the April release window instead.

Upcoming release windows include:

  • Wednesday, March 18 (security release window)
  • Wednesday, April 1 (bug fix/feature release window)

For more information on Drupal core release windows, see the documentation on release timing and security releases, and the discussion that led to this policy being implemented.

Categories: Drupal

Pages