Hacking Drupal Core: Why and How<br />Ashok Modi – June 28, 2011<br />
Why? What about “Don’t Hack Core!”<br />Contrary to what some people say, Drupal is not a one size fits all Swiss Army kni...
Examples<br />User Module<br />On user registration, wanted a way to generate simpler random passwords.<br />Drupal (core ...
Best practices<br />Check the issue queue!<br />If its in there, try and work towards a patch.<br />Use that patch until i...
Best Practices (cont’d)<br />Very simple<br />Copy the module you want to override into your sites/all directory.<br />Rec...
DEMO<br />Going to go over image module change<br />http://drupal.org/node/1015916<br />If you try to enter data longer th...
Questions?<br />Have fun hacking Drupal Core and Contrib! ^_~<br />
Upcoming SlideShare
Loading in...5
×

Hacking core

4,145

Published on

Published in: Technology, News & Politics
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
4,145
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Hacking core"

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

    Clipping is a handy way to collect important slides you want to go back to later.

×