SlideShare a Scribd company logo
1 of 7
Hacking Drupal Core: Why and How Ashok Modi – June 28, 2011
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.
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.
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.
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.
DEMO Going to go over image module change http://drupal.org/node/1015916 If you try to enter data longer than 128 characters, site dies. Don’t know if the patch will get accepted. Lets dive in.
Questions? Have fun hacking Drupal Core and Contrib! ^_~

More Related Content

Similar to Hacking core

Contributing to Drupal
Contributing to DrupalContributing to Drupal
Contributing to Drupal
Chris Skene
 
Drupalcamp Simpletest
Drupalcamp SimpletestDrupalcamp Simpletest
Drupalcamp Simpletest
lyricnz
 
Creating Drupal A Module
Creating Drupal A ModuleCreating Drupal A Module
Creating Drupal A Module
arcaneadam
 
Drupal theming training
Drupal theming trainingDrupal theming training
Drupal theming training
dropsolid
 

Similar to Hacking core (20)

Drupal
DrupalDrupal
Drupal
 
Contributing to Drupal
Contributing to DrupalContributing to Drupal
Contributing to Drupal
 
October 2016 - USG Rock Eagle - Everything You Need to Know to Plan Your Drup...
October 2016 - USG Rock Eagle - Everything You Need to Know to Plan Your Drup...October 2016 - USG Rock Eagle - Everything You Need to Know to Plan Your Drup...
October 2016 - USG Rock Eagle - Everything You Need to Know to Plan Your Drup...
 
Making The Drupal Pill Easier To Swallow
Making The Drupal Pill Easier To SwallowMaking The Drupal Pill Easier To Swallow
Making The Drupal Pill Easier To Swallow
 
The Drupal 7 Worst Practices Catalogue
The Drupal 7 Worst Practices CatalogueThe Drupal 7 Worst Practices Catalogue
The Drupal 7 Worst Practices Catalogue
 
Drupal - Introduction to Drupal Creating Modules
Drupal - Introduction to Drupal Creating ModulesDrupal - Introduction to Drupal Creating Modules
Drupal - Introduction to Drupal Creating Modules
 
Entity cache
Entity cacheEntity cache
Entity cache
 
Architecture of Drupal - Drupal Camp
Architecture of Drupal - Drupal CampArchitecture of Drupal - Drupal Camp
Architecture of Drupal - Drupal Camp
 
Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8
Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8
Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8
 
Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8
Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8
Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8
 
Drupal distribution
Drupal distributionDrupal distribution
Drupal distribution
 
Rapid site production with Drupal
Rapid site production with DrupalRapid site production with Drupal
Rapid site production with Drupal
 
Recipes for Drupal distributions
Recipes for Drupal distributionsRecipes for Drupal distributions
Recipes for Drupal distributions
 
DDAY2014 - Features per Drupal 8
DDAY2014 - Features per Drupal 8DDAY2014 - Features per Drupal 8
DDAY2014 - Features per Drupal 8
 
Drupalcamp Simpletest
Drupalcamp SimpletestDrupalcamp Simpletest
Drupalcamp Simpletest
 
Testing In Drupal
Testing In DrupalTesting In Drupal
Testing In Drupal
 
Creating Drupal A Module
Creating Drupal A ModuleCreating Drupal A Module
Creating Drupal A Module
 
Drupal theming training
Drupal theming trainingDrupal theming training
Drupal theming training
 
Intro to drupal_7_architecture
Intro to drupal_7_architectureIntro to drupal_7_architecture
Intro to drupal_7_architecture
 
Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend development
 

More from Ashok Modi

Drupal Camp LA 2010: Moderating Content in Drupal
Drupal Camp LA 2010: Moderating Content in DrupalDrupal Camp LA 2010: Moderating Content in Drupal
Drupal Camp LA 2010: Moderating Content in Drupal
Ashok Modi
 
Drupal Backend Performance and Scalability
Drupal Backend Performance and ScalabilityDrupal Backend Performance and Scalability
Drupal Backend Performance and Scalability
Ashok Modi
 
Drupal Frontend Performance and Scalability
Drupal Frontend Performance and ScalabilityDrupal Frontend Performance and Scalability
Drupal Frontend Performance and Scalability
Ashok Modi
 
Zimmertwins Presentation
Zimmertwins PresentationZimmertwins Presentation
Zimmertwins Presentation
Ashok Modi
 

More from Ashok Modi (9)

Drupal Camp LA 2011: Typography modules for Drupal
Drupal Camp LA 2011: Typography modules for DrupalDrupal Camp LA 2011: Typography modules for Drupal
Drupal Camp LA 2011: Typography modules for Drupal
 
DrupalCampLA 2011: Drupal backend-performance
DrupalCampLA 2011: Drupal backend-performanceDrupalCampLA 2011: Drupal backend-performance
DrupalCampLA 2011: Drupal backend-performance
 
DrupalCampLA 2011 - Drupal frontend-optimizing
DrupalCampLA 2011 - Drupal frontend-optimizingDrupalCampLA 2011 - Drupal frontend-optimizing
DrupalCampLA 2011 - Drupal frontend-optimizing
 
Drupal content-migration
Drupal content-migrationDrupal content-migration
Drupal content-migration
 
CalArts presentation
CalArts presentationCalArts presentation
CalArts presentation
 
Drupal Camp LA 2010: Moderating Content in Drupal
Drupal Camp LA 2010: Moderating Content in DrupalDrupal Camp LA 2010: Moderating Content in Drupal
Drupal Camp LA 2010: Moderating Content in Drupal
 
Drupal Backend Performance and Scalability
Drupal Backend Performance and ScalabilityDrupal Backend Performance and Scalability
Drupal Backend Performance and Scalability
 
Drupal Frontend Performance and Scalability
Drupal Frontend Performance and ScalabilityDrupal Frontend Performance and Scalability
Drupal Frontend Performance and Scalability
 
Zimmertwins Presentation
Zimmertwins PresentationZimmertwins Presentation
Zimmertwins Presentation
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

Hacking core

  • 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 http://drupal.org/node/1015916 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! ^_~