How to do Drupal core hack the right way

Of course, hacking Drupal core is not the right thing to do, because Drupal flexibility right now is very good with its APIs. But sometimes you can't live without a hack - there is some core routines not working as you wish.

Most of the problems after core hack are connected with updating Drupal core to the new version. I see three ways of partially solving them:

  1. Creating patch:
    1. Modify module as you wish.
    2. Create a patch with diff (or use other tool you prefer for this).
    3. When updating changes - apply your patch.
  2. Cloning core module. There are two ways of doing it:
    • Copy needed core module from /modules to /sites/all/modules (/sites/yourdomain.com/modules). This is the easiest way.
    • Rename needed module for not creating conflict with existing module. This way is better.
  3. When you'll update your system renamed folder will not be updated, so after updating you can move needed changes with patch or by hands.

  4. Commit your changes in CVS:
    • Modify module as you wish.
    • Create a patch with diff (or use other tool you prefer for this).
    • Put this patch in module issue queue on drupal.org.
      This is the best way to change core module and it is very good for Drupal improving. But make sure that your patch is tested and works ok, and the functionality it creates or fixes is general and useful for Drupal. Otherwise use previous methods of core hacking.

No comments

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.