Hacking core
Upcoming SlideShare
Loading in...5

Like this? Share it with your network


Hacking core






Total Views
Views on SlideShare
Embed Views



5 Embeds 1,077

http://btmash.com 1070
http://drupal.org 4
http://dashboard.bloglines.com 1
http://www.ninjacloak.com 1
http://webcache.googleusercontent.com 1


Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

Hacking core Presentation Transcript

  • 1. Hacking Drupal Core: Why and How
    Ashok Modi – June 28, 2011
  • 2. Why? What about “Don’t Hack Core!”
    Contrary to what some people say, Drupal is not a one size fits all Swiss Army knife.
    Not all uses cases can be accounted for.
    Flexibility does come at a cost.
    Usually performance.
    Have you used Pressflow?
    Some very popular modules justdon’t get maintained.
  • 3. Examples
    User Module
    On user registration, wanted a way to generate simpler random passwords.
    Drupal (core or otherwise) does not provide any way to override the complex passwords it generates.
    No choice but to ‘alter’ (hack) core.
    Another issue involved bad performance on user login (without a patch – Pressflow has a variant but Drupal 6.x still slow).
    Comment module
    No index on the user id.
    Another module using the comment module referencing the user id made it very slow.
    No choice but to ‘alter’ (hack) the indexes made by core.
  • 4. Best practices
    Check the issue queue!
    If its in there, try and work towards a patch.
    Use that patch until its part of the project.
    Otherwise, create an issue if its something that could benefit rest of Drupal and work towards a patch.
  • 5. Best Practices (cont’d)
    Very simple
    Copy the module you want to override into your sites/all directory.
    Recommend creating a new directory called ‘core_modified’.
    Similarly for contrib, have a directory called ‘contrib_modified’.
    Add any changes you make into a patch file.
    Use diff on the command line or a program like Diffmerge (OSX) or winmerge (Windows) or Guiffy (all).
    Commit the patch file to your codebase.
    Will allow you to merge your changes anytime module gets updated.
    Once things in the affected module are officially fixed, you can move back to the core version.
  • 6. DEMO
    Going to go over image module change
    If you try to enter data longer than 128 characters, site dies.
    Don’t know if the patch will get accepted.
    Lets dive in.
  • 7. Questions?
    Have fun hacking Drupal Core and Contrib! ^_~