Tuesday, June 25, 2013

PHP-Mysql tuning for Drupal projects

Hi Guys,

If we installed a lot of number of modules in Drupal project, we see some heavy weight process(CCK field creation, clear performance, saving views , enabling/disabling modules etc.) takes so much time to be executed. Please follow some tips and then enjoy the magic in speed :).

Note: Please take backup of these files before to implement these steps.


" Drupal" settings

  1. Disable the "update" module to check status of installed modules.
  2. Disable unused modules

" php.ini" settings

  1. memory_limit = 512M 
  2. max_execution_time = 180s
  3. realpath_cache_size = 2M

" my.ini" settings

  1. innodb_flush_log_at_trx_commit = 0
  2. key_buffer = 160M
  3. max_allowed_packet = 20M
  4. table_cache = 64 
  5. sort_buffer_size = 5120K
  6. net_buffer_length = 80K 
  7. read_buffer_size = 2560K
  8. read_rnd_buffer_size = 5120K 
  9. myisam_sort_buffer_size = 80M

Drupal 7 content translation


  • Enable the "Locale" Module
  • Enable the "Translation" Module
  • Put all translating strings with t(). Example. t('Hello, my name is %name.', array('%name' => 'John');
  • String Overrides in settings.php. Example:
    $conf['locale_custom_strings_en'] = array(
                'forum' => 'Discussion board',
                '@count min' => '@count minutes',
                ‘home’ => ‘Sweet Home’,
    );
  • Generate .pot Files with translation template extractor (http://drupal.org/project/potx))
  • Put all strings and relevant translation in .po file
  • Install this .po file on the existing Site

Thursday, June 20, 2013

Drupal 7 major database differences

I found some major differences in Drupal 7 database with Drupal 6 as described below in short:

Database 

  • Master/slave concept may be used for more than one databases
  • By default engine: Innodb

Cache 

  • There are more tables like cache_bootstrap, cache_field, cache_image, cache_update.

Comment 

  • New column "language"
  • Field API concept has been used

Field

  • field_config - The field_config table stores field configuration information.
  • field_config_instance -The field_config_instance table stores field configuration information.
  • field_data_body - The field_data_body table stores details about the body field of an entity.
  • field_revision_body - The field_revision_body table stores information about revisions to body fields.

Flood 

  • flood - The flood table controls the threshold of events, such as the number of contact attempts.
  • expiration int - New column  "Expiration timestamp, expired events are purged on cron run.

Files

  • files_managed - The files_managed table stores information about uploaded files.
  • file_usage - The file_usage table stores information for tracking where a file is used.

Images

  • image_styles  - The image_styles table stores configuration options for image styles.
  • image_effects  - The table stores configuration options for image effects.

Node

  • node - node table is almost same
  • field api concept has been used.

Session

  • ssid - New column in "session" table : Secure session ID; the value is generated by PHP’s Session API.
Taxonomy
  • Some difference in name of tables only 
  • field api concept has been used.

User

  • init - A field in "users" table saves E-mail address used for initial account creation
  • field api concept has been used.

Request: If any developer find any other major difference, please comment. 

Saturday, June 15, 2013

Steps to migrates a website Drupal 6 to Drupal 7

First steps and definitions:

  •   Make a full backup of all files, directories, and your database(s) before   starting, and save it outside your Drupal installation directory.  
  •    It is wise to try an update or upgrade on a test copy of your site before applying it to your live site. Even minor updates can cause your site's  behavior to change.

UPGRADE PROBLEMS

If you encounter errors during this process,
  •   Note any error messages you see.
  •   Restore your site to its previous state, using the file and database backups you created before you started the upgrade process. Do not attempt to do further upgrades on a site that had update problems.

UPGRADE STEPS

To upgrade from a previous major version of Drupal to Drupal 7.x, after
following the instructions in the INTRODUCTION section at the top of this file:
 
1. Check on the Drupal 7 status of your contributed and custom modules and
   themes. See http://drupal.org/node/948216 for information on upgrading
   contributed modules and themes. See http://drupal.org/node/895314 for a list
   of modules that have been moved into core for Drupal 7, and instructions on
   how to update them. See http://drupal.org/update/modules for information on
   how to update your custom modules, and http://drupal.org/update/theme for
   custom themes. 
   You may decide at this point that you cannot upgrade your site, because
   needed modules or themes are not ready for Drupal 7.
 
2. Update to the latest available version of Drupal 6.x (if your current version
   is Drupal 5.x, you have to upgrade to 6.x first). If you need to update,
   download Drupal 6.x and follow the instructions in its UPGRADE.txt. This
   document only applies for upgrades from 6.x to 7.x.
 
3. In addition to updating to the latest available version of Drupal 6.x core,
   you must also upgrade all of your contributed modules for Drupal to their
   latest Drupal 6.x versions.
 
4. Log in as user ID 1 (the site maintenance user).
 
5. Go to Administer > Site configuration > Site maintenance. Select
   "Off-line" and save the configuration.
 
6. Go to Administer > Site building > Themes. Enable "Garland" and select it as
   the default theme.
 
7. Go to Administer > Site building > Modules. Disable all modules that are not
   listed under "Core - required" or "Core - optional". It is possible that some
   modules cannot be disabled, because others depend on them. Repeat this step
   until all non-core modules are disabled.
 
   If you know that you will not re-enable some modules for Drupal 7.x and you
   no longer need their data, then you can uninstall them under the Uninstall
   tab after disabling them.
 
8. On the command line or in your FTP client, remove the file 
     sites/default/default.settings.php
 
9. Remove all old core files and directories, except for the 'sites' directory
   and any custom files you added elsewhere.
 
   If you made modifications to files like .htaccess or robots.txt, you will
   need to re-apply them from your backup, after the new files are in place.
 
10. If you uninstalled any modules, remove them from the sites/all/modules and
   other sites/*/modules directories. Leave other modules in place, even though
   they are incompatible with Drupal 7.x.
 
11. Download the latest Drupal 7.x release from http://drupal.org to a
   directory outside of your web root. Extract the archive and copy the files
   into your Drupal directory.   
 
12. Re-apply any modifications to files such as .htaccess or robots.txt.
 
13. Make your settings.php file writeable, so that the update process can
   convert it to the format of Drupal 7.x. settings.php is usually located in
 
     sites/default/settings.php
 
14. Run update.php by visiting http://www.example.com/update.php (replace
   www.example.com with your domain name). This will update the core database
   tables. 
   If you are unable to access update.php do the following:
 
   - Open settings.php with a text editor.
 
   - Find the line that says:
     $update_free_access = FALSE;
 
   - Change it into:
     $update_free_access = TRUE;
 
   - Once the upgrade is done, $update_free_access must be reverted to FALSE.
 
15. Backup your database after the core upgrade has run.
 
16. Replace and update your non-core modules and themes, following the
   procedures at http://drupal.org/node/948216
 
17. Go to Administration > Reports > Status report. Verify that everything is
   working as expected.
 
18. Ensure that $update_free_access is FALSE in settings.php.
 
19. Go to Administration > Configuration > Development > Maintenance mode.
   Disable the "Put site into maintenance mode" checkbox and save the
   configuration. 

To get started with Drupal 7 administration, visit

http://drupal.org/getting-started/7/admin

New features in Drupal 7


Database:

  • Database layer utilizing PHP 5's PDO abstraction layer
  • Added query builders for INSERT, UPDATE, DELETE, MERGE, and SELECT queries
  • Added support for the SQLite database engine.
  • Default to InnoDB engine, rather than MyISAM, on MySQL when available for greater scalability and data integrity. 

Security:  

  • Protected cron.php -- cron will only run if the proper key is provided
  • Much stronger password hashes
  • Rate limited login attempts to prevent brute-force password guessing

Usability:

·         Added contextual links (a.k.a. local tasks) to page elements, such as blocks, nodes, or comments, which allows to perform the most common tasks with a single click only.
·         Improved installer requirements check.
·         Improved support for integration of WYSIWYG editors.
·         Implemented drag-and-drop positioning for input format listings.
·         Implemented drag-and-drop positioning for language listing.
·         Implemented drag-and-drop positioning for poll options.
·         Provided descriptions and human-readable names for user permissions.
·         Removed comment controls for users.
·         Removed display order settings for comment module. Comment display order can now be customized using the Views module.
·         Removed the 'related terms' feature from taxonomy module since this can now be achieved with Field API.
·         Added additional features to the default install profile, and implemented a "slimmed down" install profile designed for developers.
·         Added a built-in, automated cron run feature, which is triggered by site visitors.
·         Added an administrator role which is assigned all permissions for installed modules automatically.
·         Image toolkits are now provided by modules (rather than requiring a manual file copy to the includes directory).
·         Added an edit tab to taxonomy term pages.
·         Redesigned password strength validator.
·         Redesigned the add content type screen.
·         Highlight duplicate URL aliases.
·         Renamed "input formats" to "text formats".
·         Moved text format permissions to the main permissions page.
·         Added configurable ability for users to cancel their own accounts.
·         Added "vertical tabs", a reusable interface component that features automatic summaries and increases usability.
·         Replaced fieldsets on node edit and add pages with vertical tabs. 

Performance:

  • Improved performance on uncached page views by loading multiple core objects in a single database query.
  • Improved performance for logged-in users by reducing queries for path
alias lookups"

Search:

·         Added support for language-aware searches.

Testing:

·         Added test framework and tests.

Theme system:

·         Removed the Bluemarine, Chameleon and Pushbutton themes. These themes live on as contributed themes
·         Added "Bartik" theme as the default user interface theme.
·         Added "Seven" theme as the default administration interface theme.
·         Added "Stark" theme to make analyzing Drupal's default HTML and CSS easier.

File handling:

  • Files are now first class Drupal objects with file_load(), file_save(),
    and file_validate() functions and corresponding hooks.
  • Files use PHP stream wrappers to enable support for both public and private files and to support pluggable storage mechanisms and access to remote resources (e.g. S3 storage or Flickr photos).
  • Added a field specifically for uploading files, previously provided by
    the contributed module FileField.

Image handling:

  • Improved image handling, including better support for add-on image
    libraries.
  • Added a field specifically for uploading images, previously provided by the contributed module ImageField.

Windows 7 Keyboard Shortcuts


  • Win + Up – Maximizes the active Window
  • Win + Down – Minimizes the active Window
  • Win + Left – Docks the active Window to the left half of the screen
  • Alt + Tab – Switch between Windows with the basic interface
  • Win + Right – Docks the active Window to the right half of the screen
  • Win + Number – Launch any pinned program on the Taskbar by using the number of its location from left to right.
  • Win + Space – Makes all Windows transparent allowing you to see the desktop
  • Win + Pause/Break – System Information
  • Win + Tab – Switch between Windows with Aero 3D
  • Win + D – Show the desktop
  • Win + E – Launch Windows Explorer
  • Win + F – Launch the Search Window
  • Win + G – Show your gadgets
  • Win + L – Lock your computer
  • Win + M – Minimizes all Windows
  • Win + P – Launches the projection options Window
  • Win + R – Launches the “Run” Window
  • Win + T – Displays thumbnail preview of active applications in the Taskbar without mouse over
  • Ctrl + Arrow + Spacebar – Selects multiple items on the desktop or in a Window
  • Ctrl + Shift + Esc – Launches the Windows Task Manager
  • Ctrl + Shift + N – Creates a new folder
  • Win + X – Mobility Center
  • Win + = – Launches the Magnifier tool
  • Win + (+ or -) – Launches the Magnifier tool and zooms in/out
  • Win + Shift + Up – Maximizes vertical size for the active Window
  • Win + Shift + Down – Restores vertical window size
  • Win + Shift + Right – Jump to right monitor
  • Win + Shift + M – Launches all minimized Windows

Eclipse shortcuts

  • Make Format:  ESc +Ctrl+F
  • Mroper indentation :  ctrl+I
  • Add block comment: SHIFT + CTRL+ /
  • Remove block comment: SHIFT + CTRL+ \
  • Matching tag: Shift + Ctrl+ >
  • Matching Bracket: Shift + Ctrl+ P
  • Open declaration: F3 or Ctrl+ left-click
  • Last edit location: Ctrl+Q
  • Back : Alt + left arrow
  • Next : Alt + right arrow
  • Key Assist: Ctrl+Alt+L