目录 / backdrop-update-hook
backdrop-update-hook
```php /** * @file * Update hooks for mymodule. */ /** * Add new field to existing table. */ function mymodule_update_10001() { // Mirror of hook_install() schema change. db_add_field('mymodule_table', 'new_field', array( 'type' => 'varchar', 'length' => 255, 'not null' => FALSE, 'description' => 'New field added for feature X.', )); } /** * Set default config value for existing sites. */ function mymodule_update_10002() { // Mirror of hook_install() config default. config_set('mymodule.settings', 'default_value', 'example'); } /** * Add new permission to existing sites. */ function mymodule_update_10003() { // Mirror of hook_install() permission. user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access mymodule feature')); } /** * Seed taxonomy terms on existing sites. */ function mymodule_update_10004() { // Mirror of hook_install() taxonomy seeding. $terms = array('Term 1', 'Term 2', 'Term 3'); foreach ($terms as $term_name) { $term = new stdClass(); $term->vid = 1; // Vocabulary ID. $term->name = $term_name; taxonomy_term_save($term); } } /** * Add menu link to existing sites. */ function mymodule_update_10005() { // Mirror of hook_install() menu link. $item = array( 'link_path' => 'mymodule/page', 'link_title' => 'My Module Page', 'menu_name' => 'main-menu', 'weight' => 0, ); menu_link_save($item); } /** * Change field type in existing table. */ function mymodule_update_10006() { // Mirror of hook_install() schema change. db_change_field('mymodule_table', 'old_field', 'old_field', array( 'type' => 'text', 'size' => 'big', 'not null' => FALSE, 'description' => 'Updated field type.', )); } /** * Create new table on existing sites. */ function mymodule_update_10007() { // Mirror of hook_install() table creation. $schema['mymodule_new_table'] = array( 'fields' => array( 'id' => array( 'type' => 'serial', ...
这是模型对公开材料的总结,不是官方声明,请以原链内容为准。
存档时间线
| 版本 | 存档时间 | 内容哈希 | 内容 |
|---|---|---|---|
| v1 | 2026-11-15 12:11 | 10dd74ec | 可取 |
版本索引永久保留;内容副本只保留最新 1 份,更早版本仅留索引与哈希(存档时间线的证据链不会因此断裂)。
提交举报 / 纠错
侵权举报经核验成立后,我们会即时下线该条目并删除已存的内容副本。