Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
drupal.org
email
Commits
cf887375
Commit
cf887375
authored
Jul 30, 2008
by
Matthias Hutterer
Browse files
added update script from 5.x to 6.x
parent
1a692854
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
+41
-0
email.install
email.install
+41
-0
No files found.
email.install
View file @
cf887375
<?php
// Updates happen in random order, whether or not the module is enabled,
// so include critical code here just to be sure.
include_once
(
drupal_get_path
(
'module'
,
'content'
)
.
'/content.module'
);
/**
* Implementation of hook_install().
*/
...
...
@@ -32,3 +36,40 @@ function email_disable() {
content_notify
(
'disable'
,
'email'
);
}
/**
* Implemenation of hook_update_N();
*
* Update from 5.x to 6.x
*
* Set all columns to accept NULL values and set empty string values in the
* database to NULL.
*/
function
email_update_6001
()
{
$ret
=
array
();
$ret
[]
=
update_sql
(
"UPDATE {"
.
content_instance_tablename
()
.
"} SET widget_type = 'email_textfield' WHERE widget_type = 'email'"
);
content_associate_fields
(
'email'
);
content_clear_type_cache
(
TRUE
);
include_once
(
drupal_get_path
(
'module'
,
'content'
)
.
'/content.install'
);
$types
=
content_types_install
();
foreach
(
$types
as
$type_name
=>
$fields
)
{
foreach
(
$fields
as
$field
)
{
switch
(
$field
[
'type'
])
{
case
'email'
:
$db_info
=
content_database_info
(
$field
);
$table
=
$db_info
[
'table'
];
foreach
(
$db_info
[
'columns'
]
as
$column
=>
$attributes
)
{
$attributes
[
'not null'
]
=
FALSE
;
$column
=
$attributes
[
'column'
];
db_change_field
(
$ret
,
$table
,
$column
,
$column
,
$attributes
);
db_field_set_no_default
(
$ret
,
$table
,
$column
);
$ret
[]
=
update_sql
(
"UPDATE {"
.
$table
.
"} SET "
.
$column
.
" = NULL WHERE "
.
$column
.
" = ''"
);
}
break
;
}
}
}
return
$ret
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment