-
Notifications
You must be signed in to change notification settings - Fork 173
/
restful.install
153 lines (137 loc) · 3.97 KB
/
restful.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
/**
* @file
* Install, update, and uninstall functions for the RESTful module.
*/
/**
* Implements hook_schema().
*/
function restful_schema() {
$schema = array();
$schema['cache_restful'] = drupal_get_schema_unprocessed('system', 'cache');
// Rate limit entity base table.
$schema['restful_rate_limit'] = array(
'description' => 'Rate limit base table',
'fields' => array(
'rlid' => array(
'description' => 'The rate limit unique ID.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'event' => array(
'description' => 'The event name.',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'identifier' => array(
'description' => 'The user & request identifier.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
),
'timestamp' => array(
'description' => 'The Unix timestamp when the rate limit window started.',
'type' => 'int',
'not null' => FALSE,
'default' => NULL,
),
'expiration' => array(
'description' => 'The Unix timestamp when the rate limit window expires.',
'type' => 'int',
'not null' => FALSE,
'default' => NULL,
),
'hits' => array(
'description' => 'The number of hits.',
'type' => 'int',
'not null' => FALSE,
'default' => 0,
),
),
'unique keys' => array(
'identifier' => array('identifier'),
),
'indexes' => array(
'rate_limit_identifier' => array('identifier'),
),
'primary key' => array('rlid'),
);
// Cache fragment entity base table.
$schema['restful_cache_fragment'] = array(
'description' => 'Cache fragment base table',
'fields' => array(
'tid' => array(
'description' => 'The cache fragment unique ID.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'type' => array(
'description' => 'The type of the cache fragment, e.g "entity_id".',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'value' => array(
'description' => 'The value for the tag. Example: 182.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'hash' => array(
'description' => 'The hash used as a cache ID.',
'type' => 'char',
'length' => 40,
'not null' => FALSE,
'default' => NULL,
),
),
'indexes' => array(
'cache_fragment_hash' => array('hash'),
),
'unique keys' => array(
'hash_key_val' => array('type', 'value', 'hash'),
),
'primary key' => array('tid'),
);
return $schema;
}
/**
* Implements hook_uninstall().
*/
function restful_uninstall() {
variable_del('restful_default_output_formatter');
variable_del('restful_enable_discovery_resource');
variable_del('restful_file_upload');
variable_del('restful_file_upload_allow_anonymous_user');
variable_del('restful_hijack_api_pages');
variable_del('restful_hook_menu_base_path');
variable_del('restful_enable_user_login_resource');
variable_del('restful_global_rate_limit');
variable_del('restful_global_rate_period');
variable_del('restful_enable_users_resource');
variable_del('restful_render_cache');
variable_del('restful_skip_basic_auth');
variable_del('restful_allowed_origin');
}
/**
* Create the cache fragments schema.
*/
function restful_update_7200() {
$table_schema = drupal_get_schema('restful_cache_fragment', TRUE);
db_create_table('restful_cache_fragment', $table_schema);
}
/**
* Clear RESTful cache on cache flush.
*/
function restful_update_7201() {
// Even if the recommended value is FALSE, there might be some deploy
// workflows that assume cache clearing.
variable_set('restful_clear_on_cc_all', TRUE);
}