This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Enable modules. | |
* Normally we'd use master module for this but sometimes you can't run anything other than updb in production. | |
*/ | |
function mymodule_update_7001(&$sandbox) { | |
$modules = array( | |
'mymodule_one', | |
'mymodule_two', | |
'mymodule_three', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Rebuild node access permissions. | |
* node_access_rebuild(TRUE) claims to be able to do this in batch mode but all it does is set a | |
* batch. There is no way to process the batch from within an update hook. You could do it using | |
* a separate drush command but if you only have access to run updb on your production env | |
* then you need to do all the processing from within the update hook. This gem allows complete | |
* safe permission rebuild, batched, from within a single update hook. | |
*/ | |
function mymodule_update_7001(&$sandbox) { | |
_node_access_rebuild_batch_operation($sandbox); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_form_FORM_ID_alter(). | |
*/ | |
function mymodule_form_file_entity_add_upload_alter(&$form) { | |
_mymodule_media_form_alter($form); | |
} | |
/** | |
* Implements hook_form_FORM_ID_alter(). | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Move all data in one field to another. | |
* In the example below we replace a multi cardinality field (field_old_field) | |
* with a single cardinality field (field_new_field). | |
* The data in the first element of the old field becomes the only data in the new field. | |
* | |
* @requires entity module | |
*/ | |
function mymodule_update_7001(&$sandbox) { | |
if (!isset($sandbox['progress'])) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Disable the media browser view. | |
*/ | |
function mymodule_update_7001() { | |
$view = views_get_view('media_default'); // media_default is the machine name of the view. | |
if (!empty($view)) { | |
ctools_include('export'); | |
ctools_export_crud_set_status('views_view', $view, TRUE); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Delete a field instance. | |
*/ | |
function mymodule_update_7001() { | |
$instance = field_info_instance('entity_type', 'field_name', 'bundle'); | |
if (!empty($instance)) { | |
field_delete_instance($instance, FALSE); | |
} | |
} |
NewerOlder