Maintenance mode flag variable should be always 0 or 1

Variable `maintenance_mode` originally has value `0` or `1`. In update scripts, it has values `FALSE` or `TRUE`, which causes error using Features module: after running Drupal update `maintenance_mode` variable is always overridden and can't be reset back by Features.
Check added to the user_role_grant_permissions

Without this check module that uses Features can fail to update permissions, as module can be disabled, but permissions exist in the feature.
Ensure that $entity is an object

For some reasons it may not be an object, causing problems
Ensure menu item weight is defined

If it's not, we'll get warnings
Look up profiles in sites/all/profiles

By default Drupal looks up profiles only in `profiles` directory, but not in `sites/all`
PHP 5.4 error reporting fix
Check isset() first

It's much faster in foreach loops
Global $environment variable added

Global $environment variable can be used in settings.php to override $conf (Drupal variables) values.
Memcache default settings added
Allow field names longer than 32 chars
Added hook_user_access_extend()

Hook allows modules to add their own permissions without registering them via hook_permission().
Composer.json added