Commit 88741c1b authored by KarenS's avatar KarenS

Get rid of helper function content_is_updated(), we can do it better using the...

Get rid of helper function content_is_updated(), we can do it better using the content version variable.
parent edfa3660
......@@ -3,6 +3,7 @@
CCK 6.2-dev
===========
- Get rid of helper function content_is_updated(), we can do it better using the content version variable.
- #318224 by brmassa, fix several errors in Content Copy.
- #318387 Make sure old fieldgroup updates don't run if tables were never created.
- #318227 Clean up update abort logic to more clearly explain what still needs to be done, add a helper function to prevent dangerous database operations until database is updated.
......
......@@ -81,7 +81,7 @@ function content_types_install() {
* Implementation of hook_install().
*/
function content_install() {
variable_set('content_schema_version', 6002);
variable_set('content_schema_version', 6008);
drupal_install_schema('content');
}
......@@ -367,6 +367,7 @@ function content_update_6003() {
if (db_column_exists('content_node_field', 'columns')) {
db_change_field($ret, 'content_node_field', 'columns', 'db_columns', array('type' => 'text', 'size' => 'medium', 'not null' => TRUE));
}
variable_set('content_schema_version', 6003);
return $ret;
}
......@@ -412,7 +413,7 @@ function content_update_6004(&$sandbox) {
if ($sandbox['count']) {
$ret['#finished'] = 1 - count($sandbox['tables']) / $sandbox['count'];
}
variable_set('content_schema_version', 6004);
return $ret;
}
......@@ -427,6 +428,7 @@ function content_update_6005() {
$ret = array();
drupal_load('module', 'content');
db_add_field($ret, content_field_tablename(), 'locked', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0));
variable_set('content_schema_version', 6005);
return $ret;
}
......@@ -441,6 +443,7 @@ function content_update_6006() {
$ret = array();
drupal_load('module', 'content');
db_change_field($ret, content_field_tablename(), 'locked', 'locked', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0));
variable_set('content_schema_version', 6006);
return $ret;
}
......@@ -453,5 +456,18 @@ function content_update_6007() {
return $abort;
}
variable_set('content_schema_version', 6007);
return array();
}
/**
* Dummy update function to make sure schema version gets updated.
*/
function content_update_6008() {
if ($abort = content_check_update()) {
return $abort;
}
variable_set('content_schema_version', 6008);
return array();
}
\ No newline at end of file
......@@ -94,8 +94,8 @@ function content_menu() {
);
// Make sure this doesn't fire until content_types is working,
// needed to avoid errors on initial installation.
if (!defined('MAINTENANCE_MODE') && content_is_updated()) {
// and tables are updated, needed to avoid errors on initial installation.
if (!defined('MAINTENANCE_MODE') && variable_get('content_schema_version', -1) >= 6007) {
foreach (node_get_types() as $type) {
$type_name = $type->type;
$content_type = content_types($type_name);
......@@ -500,9 +500,9 @@ function content_notify($op, $module) {
content_clear_type_cache();
break;
case 'disable':
// When CCK modules are disabled before content module's update is run,
// we can't do this.
if (!content_is_updated()) {
// When CCK modules are disabled before content module's update is run
// to add the active column, we can't do this.
if (!variable_get('content_schema_version', -1) >= 6007) {
return FALSE;
}
db_query("UPDATE {". content_field_tablename() ."} SET active=0 WHERE module='%s'", $module);
......@@ -520,8 +520,8 @@ function content_notify($op, $module) {
*/
function content_associate_fields($module) {
// When CCK modules are enabled before content module's update is run,
// we can't do this.
if (!content_is_updated()) {
// to add module and active columns, we can't do this.
if (!variable_get('content_schema_version', -1) >= 6007) {
return FALSE;
}
$module_fields = module_invoke($module, 'field_info');
......@@ -893,8 +893,9 @@ function _content_sort_items_value_helper($a, $b) {
* Handle storage ops for _content_field_invoke_default().
*/
function content_storage($op, $node) {
// Don't try this before content module's update is run.
if (!content_is_updated()) {
// Don't try this before content module's update is run to add
// the active and module columns.
if (!variable_get('content_schema_version', -1) >= 6007) {
return FALSE;
}
......@@ -1312,8 +1313,9 @@ function _content_type_info($reset = FALSE) {
// or when uninstalled and some subsequent field module uninstall
// attempts to refresh the data.
// Don't try this before content module's update is run.
if (!content_is_updated()) {
// Don't try this before content module's update is run
// to add module and active columns to the table.
if (!variable_get('content_schema_version', -1) >= 6007) {
return array();
}
......@@ -1882,20 +1884,6 @@ function content_cache_tablename() {
}
}
/**
* Test before trying database operations.
*/
function content_is_updated() {
if (!db_table_exists(content_field_tablename())) {
return FALSE;
}
if (!db_column_exists(content_field_tablename(), 'active')
|| !db_column_exists(content_field_tablename(), 'module')) {
return FALSE;
}
return TRUE;
}
/**
* A basic schema used by all field and type tables.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment