function services_update_7303 in Services 7.3
Update 7303 adds the possibility to configure server settings on a per-endpoint basis. and sets upgrades all new servers to have at least services session enabled.
File
- ./
services.install, line 223 - Install, uninstall and update the Services module.
Code
function services_update_7303() {
// Add the new server settings field.
if (!db_field_exists('services_endpoint', 'server_settings')) {
db_add_field('services_endpoint', 'server_settings', array(
'description' => 'The server settings for the endpoint.',
'type' => 'blob',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
'initial' => '',
));
}
// Fetch all endpoints that currently exist
$result = db_select('services_endpoint', 'se')
->fields('se')
->execute()
->fetchAll();
// Loop through every endpoint and update the authentication section.
// Note, this will not remove previous authentication settings, it will
// only add to them.
foreach ($result as $services_endpoint_object) {
$new_authentication = array(
'services' => 'services',
);
$unserial_endpoint_settings = unserialize($services_endpoint_object->authentication);
db_update('services_endpoint')
->fields(array(
'authentication' => serialize(array_merge($unserial_endpoint_settings, $new_authentication)),
))
->condition('eid', $services_endpoint_object->eid)
->execute();
}
}