2007-10-05 16:07:22 +00:00
<?php
2009-05-13 19:42:18 +00:00
/**
* @file
* Install, update and uninstall functions for the node module.
*/
2007-10-05 16:07:22 +00:00
/**
2009-12-04 16:49:48 +00:00
* Implements hook_schema().
2007-10-05 16:07:22 +00:00
*/
function node_schema() {
$schema['node'] = array(
2008-11-15 13:01:11 +00:00
'description' => 'The base table for nodes.',
2007-10-05 16:07:22 +00:00
'fields' => array(
2007-10-10 11:39:35 +00:00
'nid' => array(
2008-11-15 13:01:11 +00:00
'description' => 'The primary identifier for a node.',
2007-10-10 11:39:35 +00:00
'type' => 'serial',
'unsigned' => TRUE,
2008-03-15 12:31:29 +00:00
'not null' => TRUE,
),
2012-08-07 18:33:39 +00:00
'uuid' => array(
'description' => 'Unique Key: Universally unique identifier for this entity.',
'type' => 'varchar',
'length' => 128,
'not null' => FALSE,
),
2012-02-29 20:25:43 +00:00
// Defaults to NULL in order to avoid a brief period of potential
// deadlocks on the index.
2007-10-10 11:39:35 +00:00
'vid' => array(
2008-12-03 16:32:22 +00:00
'description' => 'The current {node_revision}.vid version identifier.',
2007-10-10 11:39:35 +00:00
'type' => 'int',
'unsigned' => TRUE,
2012-02-29 20:25:43 +00:00
'not null' => FALSE,
'default' => NULL,
2008-03-15 12:31:29 +00:00
),
2007-10-10 11:39:35 +00:00
'type' => array(
2008-11-15 13:01:11 +00:00
'description' => 'The {node_type}.type of this node.',
2007-10-10 11:39:35 +00:00
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => '',
),
2012-02-23 14:22:18 +00:00
'langcode' => array(
2012-01-10 15:29:08 +00:00
'description' => 'The {language}.langcode of this node.',
2007-10-10 11:39:35 +00:00
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => '',
),
2007-10-10 11:39:35 +00:00
'title' => array(
2008-11-15 13:01:11 +00:00
'description' => 'The title of this node, always treated as non-markup plain text.',
2007-10-10 11:39:35 +00:00
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => '',
),
2007-10-10 11:39:35 +00:00
'uid' => array(
2009-02-26 07:30:29 +00:00
'description' => 'The {users}.uid that owns this node; initially, this is the user that created it.',
2007-10-10 11:39:35 +00:00
'type' => 'int',
2012-10-04 20:27:03 +00:00
'unsigned' => TRUE,
2007-10-10 11:39:35 +00:00
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => 0,
),
2007-10-10 11:39:35 +00:00
'status' => array(
2008-11-15 13:01:11 +00:00
'description' => 'Boolean indicating whether the node is published (visible to non-administrators).',
2007-10-10 11:39:35 +00:00
'type' => 'int',
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => 1,
),
2007-10-10 11:39:35 +00:00
'created' => array(
2008-11-15 13:01:11 +00:00
'description' => 'The Unix timestamp when the node was created.',
2007-10-10 11:39:35 +00:00
'type' => 'int',
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => 0,
),
2007-10-10 11:39:35 +00:00
'changed' => array(
2008-11-15 13:01:11 +00:00
'description' => 'The Unix timestamp when the node was most recently saved.',
2007-10-10 11:39:35 +00:00
'type' => 'int',
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => 0,
),
2007-10-10 11:39:35 +00:00
'comment' => array(
2009-03-17 12:41:54 +00:00
'description' => 'Whether comments are allowed on this node: 0 = no, 1 = closed (read only), 2 = open (read/write).',
2007-10-10 11:39:35 +00:00
'type' => 'int',
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => 0,
),
2007-10-10 11:39:35 +00:00
'promote' => array(
2008-11-15 13:01:11 +00:00
'description' => 'Boolean indicating whether the node should be displayed on the front page.',
2007-10-10 11:39:35 +00:00
'type' => 'int',
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => 0,
),
2007-10-10 11:39:35 +00:00
'sticky' => array(
2008-11-15 13:01:11 +00:00
'description' => 'Boolean indicating whether the node should be displayed at the top of lists in which it appears.',
2007-10-10 11:39:35 +00:00
'type' => 'int',
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => 0,
),
2007-10-10 11:39:35 +00:00
'tnid' => array(
2008-11-15 13:01:11 +00:00
'description' => 'The translation set id for this node, which equals the node id of the source post in each set.',
2007-10-10 11:39:35 +00:00
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => 0,
),
2007-10-10 11:39:35 +00:00
'translate' => array(
2008-11-15 13:01:11 +00:00
'description' => 'A boolean indicating whether this translation page needs to be updated.',
2007-10-10 11:39:35 +00:00
'type' => 'int',
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => 0,
2007-10-10 11:39:35 +00:00
),
2008-03-15 12:31:29 +00:00
),
2007-10-05 16:07:22 +00:00
'indexes' => array(
'node_changed' => array('changed'),
'node_created' => array('created'),
2009-01-02 21:12:31 +00:00
'node_frontpage' => array('promote', 'status', 'sticky', 'created'),
2007-10-05 16:07:22 +00:00
'node_status_type' => array('status', 'type', 'nid'),
'node_title_type' => array('title', array('type', 4)),
'node_type' => array(array('type', 4)),
'uid' => array('uid'),
'tnid' => array('tnid'),
'translate' => array('translate'),
2008-03-15 12:31:29 +00:00
),
2007-10-05 16:07:22 +00:00
'unique keys' => array(
2008-03-15 12:31:29 +00:00
'vid' => array('vid'),
2012-08-07 18:33:39 +00:00
'uuid' => array('uuid'),
2008-03-15 12:31:29 +00:00
),
2009-06-01 22:07:10 +00:00
'foreign keys' => array(
2010-08-22 13:55:53 +00:00
'node_revision' => array(
'table' => 'node_revision',
'columns' => array('vid' => 'vid'),
),
'node_author' => array(
'table' => 'users',
'columns' => array('uid' => 'uid'),
),
2009-06-01 22:07:10 +00:00
),
2007-10-05 16:07:22 +00:00
'primary key' => array('nid'),
2008-03-15 12:31:29 +00:00
);
2007-10-05 16:07:22 +00:00
$schema['node_access'] = array(
2008-11-15 13:01:11 +00:00
'description' => 'Identifies which realm/grant pairs a user must possess in order to view, update, or delete specific nodes.',
2007-10-05 16:07:22 +00:00
'fields' => array(
2007-10-10 11:39:35 +00:00
'nid' => array(
2008-11-15 13:01:11 +00:00
'description' => 'The {node}.nid this record affects.',
2007-10-10 11:39:35 +00:00
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => 0,
),
2013-03-27 18:23:49 +00:00
'langcode' => array(
'description' => 'The {language}.langcode of this node.',
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
),
'fallback' => array(
'description' => 'Boolean indicating whether this record should be used as a fallback if a language condition is not provided.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1,
),
2007-10-10 11:39:35 +00:00
'gid' => array(
2008-11-15 13:01:11 +00:00
'description' => "The grant ID a user must possess in the specified realm to gain this row's privileges on the node.",
2007-10-10 11:39:35 +00:00
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => 0,
),
2007-10-10 11:39:35 +00:00
'realm' => array(
2008-11-15 13:01:11 +00:00
'description' => 'The realm in which the user must possess the grant ID. Each node access node can define one or more realms.',
2007-10-10 11:39:35 +00:00
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => '',
),
2007-10-10 11:39:35 +00:00
'grant_view' => array(
2008-11-15 13:01:11 +00:00
'description' => 'Boolean indicating whether a user with the realm/grant pair can view this node.',
2007-10-10 11:39:35 +00:00
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
2008-03-15 12:31:29 +00:00
'size' => 'tiny',
),
2007-10-10 11:39:35 +00:00
'grant_update' => array(
2008-11-15 13:01:11 +00:00
'description' => 'Boolean indicating whether a user with the realm/grant pair can edit this node.',
2007-10-10 11:39:35 +00:00
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
2008-03-15 12:31:29 +00:00
'size' => 'tiny',
),
2007-10-10 11:39:35 +00:00
'grant_delete' => array(
2008-11-15 13:01:11 +00:00
'description' => 'Boolean indicating whether a user with the realm/grant pair can delete this node.',
2007-10-10 11:39:35 +00:00
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
2008-03-15 12:31:29 +00:00
'size' => 'tiny',
2007-10-10 11:39:35 +00:00
),
2008-03-15 12:31:29 +00:00
),
2013-03-27 18:23:49 +00:00
'primary key' => array('nid', 'gid', 'realm', 'langcode'),
2010-08-22 13:55:53 +00:00
'foreign keys' => array(
'affected_node' => array(
'table' => 'node',
'columns' => array('nid' => 'nid'),
),
),
2008-03-15 12:31:29 +00:00
);
2007-10-05 16:07:22 +00:00
2008-12-03 16:32:22 +00:00
$schema['node_revision'] = array(
2008-11-15 13:01:11 +00:00
'description' => 'Stores information about each saved version of a {node}.',
2007-10-05 16:07:22 +00:00
'fields' => array(
2007-10-10 11:39:35 +00:00
'nid' => array(
2008-11-15 13:01:11 +00:00
'description' => 'The {node} this version belongs to.',
2007-10-10 11:39:35 +00:00
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => 0,
),
2007-10-10 11:39:35 +00:00
'vid' => array(
2008-11-15 13:01:11 +00:00
'description' => 'The primary identifier for this version.',
2007-10-10 11:39:35 +00:00
'type' => 'serial',
'unsigned' => TRUE,
2008-03-15 12:31:29 +00:00
'not null' => TRUE,
),
2007-10-10 11:39:35 +00:00
'uid' => array(
2009-02-26 07:30:29 +00:00
'description' => 'The {users}.uid that created this version.',
2007-10-10 11:39:35 +00:00
'type' => 'int',
2012-10-04 20:27:03 +00:00
'unsigned' => TRUE,
2007-10-10 11:39:35 +00:00
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => 0,
),
2007-10-10 11:39:35 +00:00
'title' => array(
2008-11-15 13:01:11 +00:00
'description' => 'The title of this version.',
2007-10-10 11:39:35 +00:00
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => '',
),
2007-10-10 11:39:35 +00:00
'log' => array(
2008-11-15 13:01:11 +00:00
'description' => 'The log entry explaining the changes in this version.',
2007-10-10 11:39:35 +00:00
'type' => 'text',
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'size' => 'big',
),
2007-10-10 11:39:35 +00:00
'timestamp' => array(
2008-11-15 13:01:11 +00:00
'description' => 'A Unix timestamp indicating when this version was created.',
2007-10-10 11:39:35 +00:00
'type' => 'int',
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => 0,
),
2009-08-19 12:37:58 +00:00
'status' => array(
'description' => 'Boolean indicating whether the node (at the time of this revision) is published (visible to non-administrators).',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
),
'comment' => array(
'description' => 'Whether comments are allowed on this node (at the time of this revision): 0 = no, 1 = closed (read only), 2 = open (read/write).',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'promote' => array(
'description' => 'Boolean indicating whether the node (at the time of this revision) should be displayed on the front page.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'sticky' => array(
'description' => 'Boolean indicating whether the node (at the time of this revision) should be displayed at the top of lists in which it appears.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
2008-03-15 12:31:29 +00:00
),
2007-10-05 16:07:22 +00:00
'indexes' => array(
'nid' => array('nid'),
2008-03-15 12:31:29 +00:00
'uid' => array('uid'),
),
2007-10-05 16:07:22 +00:00
'primary key' => array('vid'),
2009-06-01 22:07:10 +00:00
'foreign keys' => array(
2010-08-22 13:55:53 +00:00
'versioned_node' => array(
'table' => 'node',
'columns' => array('nid' => 'nid'),
),
'version_author' => array(
'table' => 'users',
'columns' => array('uid' => 'uid'),
),
2009-06-01 22:07:10 +00:00
),
2008-03-15 12:31:29 +00:00
);
2007-10-05 16:07:22 +00:00
$schema['node_type'] = array(
2008-11-15 13:01:11 +00:00
'description' => 'Stores information about all defined {node} types.',
2007-10-05 16:07:22 +00:00
'fields' => array(
2007-10-10 11:39:35 +00:00
'type' => array(
2008-11-15 13:01:11 +00:00
'description' => 'The machine-readable name of this type.',
2007-10-10 11:39:35 +00:00
'type' => 'varchar',
'length' => 32,
2008-03-15 12:31:29 +00:00
'not null' => TRUE,
),
2007-10-10 11:39:35 +00:00
'name' => array(
2008-11-15 13:01:11 +00:00
'description' => 'The human-readable name of this type.',
2007-10-10 11:39:35 +00:00
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => '',
),
2008-10-08 03:27:56 +00:00
'base' => array(
2008-11-15 13:01:11 +00:00
'description' => 'The base string used to construct callbacks corresponding to this node type.',
2007-10-10 11:39:35 +00:00
'type' => 'varchar',
'length' => 255,
2008-03-15 12:31:29 +00:00
'not null' => TRUE,
),
2010-10-07 00:28:20 +00:00
'module' => array(
'description' => 'The module defining this node type.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
2008-03-15 12:31:29 +00:00
'description' => array(
2008-11-15 13:01:11 +00:00
'description' => 'A brief description of this type.',
2007-10-10 11:39:35 +00:00
'type' => 'text',
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'size' => 'medium',
),
2007-10-10 11:39:35 +00:00
'help' => array(
2008-11-15 13:01:11 +00:00
'description' => 'Help information shown to the user when creating a {node} of this type.',
2007-10-10 11:39:35 +00:00
'type' => 'text',
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'size' => 'medium',
),
2007-10-10 11:39:35 +00:00
'has_title' => array(
2008-11-15 13:01:11 +00:00
'description' => 'Boolean indicating whether this type uses the {node}.title field.',
2007-10-10 11:39:35 +00:00
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'size' => 'tiny',
),
2007-10-10 11:39:35 +00:00
'title_label' => array(
2008-11-15 13:01:11 +00:00
'description' => 'The label displayed for the title field on the edit form.',
2007-10-10 11:39:35 +00:00
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => '',
),
2007-10-10 11:39:35 +00:00
'custom' => array(
2009-08-19 22:46:05 +00:00
'description' => 'A boolean indicating whether this type is defined by a module (FALSE) or by a user via Add content type (TRUE).',
2007-10-10 11:39:35 +00:00
'type' => 'int',
'not null' => TRUE,
'default' => 0,
2008-03-15 12:31:29 +00:00
'size' => 'tiny',
),
2007-10-10 11:39:35 +00:00
'modified' => array(
2008-11-15 13:01:11 +00:00
'description' => 'A boolean indicating whether this type has been modified by an administrator; currently not used in any way.',
2007-10-10 11:39:35 +00:00
'type' => 'int',
'not null' => TRUE,
'default' => 0,
2008-03-15 12:31:29 +00:00
'size' => 'tiny',
),
2007-10-10 11:39:35 +00:00
'locked' => array(
2008-11-15 13:01:11 +00:00
'description' => 'A boolean indicating whether the administrator can change the machine name of this type.',
2007-10-10 11:39:35 +00:00
'type' => 'int',
'not null' => TRUE,
'default' => 0,
2008-03-15 12:31:29 +00:00
'size' => 'tiny',
),
2010-10-07 00:28:20 +00:00
'disabled' => array(
'description' => 'A boolean indicating whether the node type is disabled.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny'
),
2007-10-10 11:39:35 +00:00
'orig_type' => array(
2008-11-15 13:01:11 +00:00
'description' => 'The original machine-readable name of this node type. This may be different from the current type name if the locked field is 0.',
2007-10-10 11:39:35 +00:00
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
2008-03-15 12:31:29 +00:00
'default' => '',
2007-10-10 11:39:35 +00:00
),
2008-03-15 12:31:29 +00:00
),
2007-10-05 16:07:22 +00:00
'primary key' => array('type'),
2008-03-15 12:31:29 +00:00
);
2007-10-05 16:07:22 +00:00
2010-03-28 11:16:29 +00:00
2007-10-05 16:07:22 +00:00
return $schema;
}
2008-10-08 03:27:56 +00:00
2010-03-01 07:39:12 +00:00
/**
* Implements hook_install().
*/
function node_install() {
// Populate the node access table.
db_insert('node_access')
->fields(array(
'nid' => 0,
'gid' => 0,
'realm' => 'all',
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
))
->execute();
}
2012-01-08 07:14:15 +00:00
/**
* Implements hook_uninstall().
2012-10-04 16:41:38 +00:00
*
* @see node_ranking()
* @see _node_rankings()
2012-01-08 07:14:15 +00:00
*/
function node_uninstall() {
// Delete node type variables.
$types = db_query('SELECT type FROM {node_type}')->fetchCol();
foreach ($types as $type) {
db_delete('variable')
->condition(db_or()
->condition('name', 'node_preview_' . $type)
->condition('name', 'node_options_' . $type)
->condition('name', 'node_submitted_' . $type)
->condition('name', 'node_permissions_' . $type)
Issue #258785 by Désiré, Schnitzel, kbasarab, pkiraly, desbeers, Bojhan, voxpelli, clemens.tolboom, Artusamak, Gábor Hojtsy, dvinegla: Added Provide more flexible settings for initial language on content types.
2012-06-16 14:48:36 +00:00
->condition('name', 'node_type_language_translation_enabled_' . $type)
2012-01-08 07:14:15 +00:00
)
->execute();
2012-10-18 08:59:12 +00:00
config('language.settings')->clear('node. ' . $type . '.language.default_configuration')->save();
2012-01-08 07:14:15 +00:00
}
// Delete node search ranking variables.
variable_del('node_rank_relevance');
variable_del('node_rank_sticky');
variable_del('node_rank_promote');
variable_del('node_rank_recent');
// Delete remaining general module variables.
2012-11-02 06:07:16 +00:00
state()->delete('node.node_access_needs_rebuild');
2012-01-08 07:14:15 +00:00
variable_del('node_admin_theme');
variable_del('node_recent_block_count');
2012-11-06 13:57:02 +00:00
// Delete any stored state.
state()->delete('node.cron_last');
2012-01-08 07:14:15 +00:00
}
2010-09-13 05:50:09 +00:00
/**
2011-11-28 11:44:25 +00:00
* Fetches node types directly from the database.
2010-09-13 05:50:09 +00:00
*
2012-10-04 16:12:04 +00:00
* @ingroup update_api
2010-09-13 05:50:09 +00:00
*/
2011-04-26 02:22:56 +00:00
function _update_7000_node_get_types() {
2011-05-12 01:28:56 +00:00
$node_types = db_query('SELECT * FROM {node_type}')->fetchAllAssoc('type', PDO::FETCH_OBJ);
// Create default settings for orphaned nodes.
$all_types = db_query('SELECT DISTINCT type FROM {node}')->fetchCol();
$extra_types = array_diff($all_types, array_keys($node_types));
foreach ($extra_types as $type) {
2011-07-18 07:54:40 +00:00
$type_object = new stdClass();
2011-05-12 01:28:56 +00:00
$type_object->type = $type;
// In Drupal 6, whether you have a body field or not is a flag in the node
// type table. If it's enabled, nodes may or may not have an empty string
// for the bodies. As we can't detect what this setting should be in
// Drupal 7 without access to the Drupal 6 node type settings, we assume
// the default, which is to enable the body field.
$type_object->has_body = 1;
$type_object->body_label = 'Body';
$node_types[$type_object->type] = $type_object;
}
return $node_types;
2010-09-13 05:50:09 +00:00
}
2012-01-08 07:14:15 +00:00
/**
* @addtogroup updates-7.x-to-8.x
* @{
*/
2012-02-16 15:52:30 +00:00
/**
* Rename node type language variable names.
*
* @see http://drupal.org/node/540294
2012-06-02 19:45:56 +00:00
*
* @ingroup config_upgrade
2012-02-16 15:52:30 +00:00
*/
function node_update_8001() {
$types = db_query('SELECT type FROM {node_type}')->fetchCol();
foreach ($types as $type) {
2012-08-07 19:11:13 +00:00
$node_type_language = update_variable_get('language_content_type_' . $type);
Issue #258785 by Désiré, Schnitzel, kbasarab, pkiraly, desbeers, Bojhan, voxpelli, clemens.tolboom, Artusamak, Gábor Hojtsy, dvinegla: Added Provide more flexible settings for initial language on content types.
2012-06-16 14:48:36 +00:00
if (isset($node_type_language)) {
2012-08-07 19:11:13 +00:00
update_variable_set('node_type_language_' . $type, $node_type_language);
2012-02-16 15:52:30 +00:00
}
2012-08-07 19:11:13 +00:00
update_variable_del('language_content_type_' . $type);
2012-02-16 15:52:30 +00:00
}
}
2012-02-23 14:22:18 +00:00
/**
* Rename node.language field to node.langcode.
*/
function node_update_8002() {
$spec = array(
'description' => 'The {language}.langcode of this node.',
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
);
db_change_field('node', 'language', 'langcode', $spec);
}
2012-01-08 07:14:15 +00:00
/**
Issue #258785 by Désiré, Schnitzel, kbasarab, pkiraly, desbeers, Bojhan, voxpelli, clemens.tolboom, Artusamak, Gábor Hojtsy, dvinegla: Added Provide more flexible settings for initial language on content types.
2012-06-16 14:48:36 +00:00
* Rename node type language variable names.
*/
function node_update_8003() {
$types = db_query('SELECT type FROM {node_type}')->fetchCol();
foreach ($types as $type) {
2012-08-07 19:11:13 +00:00
update_variable_set('node_type_language_default_' . $type, LANGUAGE_NOT_SPECIFIED);
$node_type_language = update_variable_get('node_type_language_' . $type, 0);
Issue #258785 by Désiré, Schnitzel, kbasarab, pkiraly, desbeers, Bojhan, voxpelli, clemens.tolboom, Artusamak, Gábor Hojtsy, dvinegla: Added Provide more flexible settings for initial language on content types.
2012-06-16 14:48:36 +00:00
if ($node_type_language == 0) {
2013-01-16 01:11:30 +00:00
update_variable_set('node_type_language_show_' . $type, FALSE);
Issue #258785 by Désiré, Schnitzel, kbasarab, pkiraly, desbeers, Bojhan, voxpelli, clemens.tolboom, Artusamak, Gábor Hojtsy, dvinegla: Added Provide more flexible settings for initial language on content types.
2012-06-16 14:48:36 +00:00
}
if ($node_type_language == 2) {
// Translation was enabled, so enable it again and
// unhide the language selector. Because if language is
// LANGUAGE_NOT_SPECIFIED and the selector hidden, translation
// cannot be enabled.
2013-01-16 01:11:30 +00:00
update_variable_set('node_type_language_show_' . $type, TRUE);
2012-08-07 19:11:13 +00:00
update_variable_set('node_type_language_translation_enabled_' . $type, TRUE);
Issue #258785 by Désiré, Schnitzel, kbasarab, pkiraly, desbeers, Bojhan, voxpelli, clemens.tolboom, Artusamak, Gábor Hojtsy, dvinegla: Added Provide more flexible settings for initial language on content types.
2012-06-16 14:48:36 +00:00
}
2012-08-07 19:11:13 +00:00
update_variable_del('node_type_language_' . $type);
Issue #258785 by Désiré, Schnitzel, kbasarab, pkiraly, desbeers, Bojhan, voxpelli, clemens.tolboom, Artusamak, Gábor Hojtsy, dvinegla: Added Provide more flexible settings for initial language on content types.
2012-06-16 14:48:36 +00:00
}
}
2012-08-07 18:33:39 +00:00
/**
* Create a UUID column for nodes.
*/
function node_update_8004() {
$spec = array(
'description' => 'Unique Key: Universally unique identifier for this entity.',
'type' => 'varchar',
'length' => 128,
'not null' => FALSE,
);
$keys = array(
'unique keys' => array(
'uuid' => array('uuid'),
),
);
// Account for sites having the contributed UUID module installed.
if (db_field_exists('node', 'uuid')) {
db_change_field('node', 'uuid', 'uuid', $spec, $keys);
}
else {
db_add_field('node', 'uuid', $spec, $keys);
}
}
2012-10-04 20:27:03 +00:00
/**
* Make *id fields unsigned.
*/
function node_update_8005() {
db_drop_index('node', 'uid');
db_change_field('node', 'uid', 'uid',
array(
'description' => 'The {users}.uid that owns this node; initially, this is the user that created it.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
array('indexes' => array(
'uid' => array('uid'),
))
);
db_drop_index('node_revision', 'uid');
db_change_field('node_revision', 'uid', 'uid',
array(
'description' => 'The {users}.uid that created this version.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
array('indexes' => array(
'uid' => array('uid'),
))
);
db_drop_primary_key('history');
db_drop_index('history', 'nid');
db_change_field('history', 'uid', 'uid',
array(
'description' => 'The {users}.uid that read the {node} nid.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
)
);
db_change_field('history', 'nid', 'nid',
array(
'description' => 'The {node}.nid that was read.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
array('primary key' => array('uid', 'nid'), 'indexes' => array(
'nid' => array('nid'),
))
);
}
2012-10-08 16:39:59 +00:00
/**
2012-10-17 16:40:55 +00:00
* Generate a UUID for all nodes.
2012-10-08 16:39:59 +00:00
*/
function node_update_8006(&$sandbox) {
if (!isset($sandbox['progress'])) {
$sandbox['progress'] = 0;
$sandbox['last'] = 0;
$sandbox['max'] = db_query('SELECT COUNT(nid) FROM {node} WHERE uuid IS NULL')->fetchField();
}
$nids = db_query_range('SELECT nid FROM {node} WHERE nid > :nid AND uuid IS NULL ORDER BY nid ASC', 0, 10, array(':nid' => $sandbox['last']))->fetchCol();
update_add_uuids($sandbox, 'node', 'nid', $nids);
$sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
}
2012-10-18 08:59:12 +00:00
/**
* Move the language default values to config.
*/
function node_update_8007() {
$types = db_query('SELECT type FROM {node_type}')->fetchCol();
foreach ($types as $type) {
$language_default = update_variable_get('node_type_language_default_' . $type, NULL);
2013-01-16 01:11:30 +00:00
$language_show = update_variable_get('node_type_language_show_' . $type, NULL);
if (isset($language_default) || isset($language_show)) {
$values = array('langcode' => $language_default, 'language_show' => $language_show);
2012-10-18 08:59:12 +00:00
config('language.settings')->set('node.' . $type . '.language.default_configuration', $values)->save();
}
}
}
2012-10-26 16:07:34 +00:00
/**
* Rename default menu names.
*/
function node_update_8008() {
// System menu's new block deltas are prefixed with 'menu-'.
$map = array(
'navigation' => 'menu-tools',
'management' => 'menu-admin',
'user-menu' => 'menu-account',
'main-menu' => 'menu-main',
);
foreach ($map as $old => $new) {
db_update('block_node_type')
->condition('module', 'system')
->condition('delta', $old)
->fields(array('delta' => $new))
->execute();
}
}
2012-10-31 22:55:19 +00:00
/**
* Coverts default_nodes_main variable to config.
*
* @ingroup config_upgrade
*/
function node_update_8009() {
update_variables_to_config('node.settings', array('default_nodes_main' => 'items_per_page'));
}
2012-11-02 06:07:16 +00:00
/**
* Moves node_access_needs_rebuild from variable to state.
*
* @ingroup config_upgrade
*/
2012-11-02 06:13:22 +00:00
function node_update_8010() {
2012-11-02 06:07:16 +00:00
update_variables_to_state(array('node_access_needs_rebuild' => 'node.node_access_needs_rebuild'));
}
2012-11-06 13:57:02 +00:00
/**
* Moves node cron last run time from variable to state.
*
* @ingroup config_upgrade
*/
function node_update_8011() {
update_variables_to_state(array('node_cron_last' =>'node.cron_last'));
}
2012-11-20 02:33:19 +00:00
/**
* Enable History module.
*/
function node_update_8012() {
// Enable the history module without re-installing the schema.
update_module_enable(array('history'));
}
2012-11-29 07:28:47 +00:00
/**
* Renames global revision permissions to use the word 'all'.
*/
function node_update_8013() {
$actions = array('view', 'delete', 'revert');
foreach ($actions as $action) {
db_update('role_permission')
->fields(array('permission' => $action . ' all revisions'))
->condition('permission', $action . ' revisions')
->condition('module', 'node')
->execute();
}
}
2013-02-16 23:29:53 +00:00
/**
* Enable Datetime module, which is now a required dependency.
*/
function node_update_8014() {
// Enable the datetime module.
update_module_enable(array('datetime'));
}
2013-03-27 18:23:49 +00:00
/**
* Add language support to the {node_access} table.
*/
function node_update_8015() {
// Add the langcode field.
$langcode_field = array(
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
'description' => 'The {language}.langcode of this node.',
);
db_add_field('node_access', 'langcode', $langcode_field);
// Add the fallback field.
$fallback_field = array(
'description' => 'Boolean indicating whether this record should be used as a fallback if a language condition is not provided.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1,
);
db_add_field('node_access', 'fallback', $fallback_field);
db_drop_primary_key('node_access');
db_add_primary_key('node_access', array('nid', 'gid', 'realm', 'langcode'));
}
Issue #258785 by Désiré, Schnitzel, kbasarab, pkiraly, desbeers, Bojhan, voxpelli, clemens.tolboom, Artusamak, Gábor Hojtsy, dvinegla: Added Provide more flexible settings for initial language on content types.
2012-06-16 14:48:36 +00:00
/**
* @} End of "addtogroup updates-7.x-to-8.x"
2012-01-08 07:14:15 +00:00
* The next series of updates should start at 9000.
*/