1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Schema definitions install/update/uninstall hooks.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Implements hook_requirements().
|
10
|
*/
|
11
|
function feeds_requirements($phase) {
|
12
|
$t = get_t();
|
13
|
|
14
|
$requirements = array();
|
15
|
|
16
|
module_load_include('module', 'feeds');
|
17
|
// Check if we have any SimplePie importers.
|
18
|
$needs_simplepie = FALSE;
|
19
|
foreach (feeds_importer_load_all() as $importer) {
|
20
|
if ($importer->config['parser']['plugin_key'] === 'FeedsSimplePieParser') {
|
21
|
$needs_simplepie = TRUE;
|
22
|
break;
|
23
|
}
|
24
|
}
|
25
|
|
26
|
if (!$needs_simplepie) {
|
27
|
return $requirements;
|
28
|
}
|
29
|
|
30
|
$requirements['simplepie'] = array(
|
31
|
'title' => $t('SimplePie'),
|
32
|
'value' => $t('Installed'),
|
33
|
'description' => $t('The SimplePie library is required for Feeds SimplePie Parser.'),
|
34
|
'severity' => REQUIREMENT_OK,
|
35
|
);
|
36
|
|
37
|
if (!feeds_simplepie_exists()) {
|
38
|
$requirements['simplepie']['value'] = $t('Not installed');
|
39
|
|
40
|
$folder = drupal_get_path('module', 'feeds') . '/libraries';
|
41
|
if (module_exists('libraries')) {
|
42
|
$folder = 'sites/all/libraries/simplepie';
|
43
|
}
|
44
|
|
45
|
$args = array(
|
46
|
'!url' => 'http://simplepie.org/downloads/',
|
47
|
'%folder' => $folder,
|
48
|
'%file' => 'simplepie.compiled.php',
|
49
|
);
|
50
|
$requirements['simplepie']['description'] .= $t('<br />Download the compiled, single-file version of the library from the <a href="!url">SimplePie download page</a>, place it into %folder and rename it to %file.', $args);
|
51
|
$requirements['simplepie']['severity'] = REQUIREMENT_ERROR;
|
52
|
}
|
53
|
|
54
|
return $requirements;
|
55
|
}
|
56
|
|
57
|
/**
|
58
|
* Implement hook_uninstall()
|
59
|
*/
|
60
|
function feeds_uninstall() {
|
61
|
variable_del('http_request_timeout');
|
62
|
variable_del('feeds_reschedule');
|
63
|
}
|
64
|
|
65
|
/**
|
66
|
* Implements hook_schema().
|
67
|
*/
|
68
|
function feeds_schema() {
|
69
|
$schema = array();
|
70
|
|
71
|
$schema['feeds_importer'] = array(
|
72
|
'description' => 'Configuration of feeds objects.',
|
73
|
'export' => array(
|
74
|
'key' => 'id',
|
75
|
'identifier' => 'feeds_importer',
|
76
|
'default hook' => 'feeds_importer_default', // Function hook name.
|
77
|
'api' => array(
|
78
|
'owner' => 'feeds',
|
79
|
'api' => 'feeds_importer_default', // Base name for api include files.
|
80
|
'minimum_version' => 1,
|
81
|
'current_version' => 1,
|
82
|
),
|
83
|
),
|
84
|
'fields' => array(
|
85
|
'id' => array(
|
86
|
'type' => 'varchar',
|
87
|
'length' => 128,
|
88
|
'not null' => TRUE,
|
89
|
'default' => '',
|
90
|
'description' => 'Id of the fields object.',
|
91
|
),
|
92
|
'config' => array(
|
93
|
'type' => 'blob',
|
94
|
'size' => 'big',
|
95
|
'not null' => FALSE,
|
96
|
'description' => 'Configuration of the feeds object.',
|
97
|
'serialize' => TRUE,
|
98
|
),
|
99
|
),
|
100
|
'primary key' => array('id'),
|
101
|
);
|
102
|
$schema['feeds_source'] = array(
|
103
|
'description' => 'Source definitions for feeds.',
|
104
|
'fields' => array(
|
105
|
'id' => array(
|
106
|
'type' => 'varchar',
|
107
|
'length' => 128,
|
108
|
'not null' => TRUE,
|
109
|
'default' => '',
|
110
|
'description' => 'Id of the feed configuration.',
|
111
|
),
|
112
|
'feed_nid' => array(
|
113
|
'type' => 'int',
|
114
|
'not null' => TRUE,
|
115
|
'default' => 0,
|
116
|
'unsigned' => TRUE,
|
117
|
'description' => 'Node nid if this particular source is attached to a feed node.',
|
118
|
),
|
119
|
'config' => array(
|
120
|
'type' => 'blob',
|
121
|
'size' => 'big',
|
122
|
'not null' => FALSE,
|
123
|
'description' => 'Configuration of the source.',
|
124
|
'serialize' => TRUE,
|
125
|
),
|
126
|
'source' => array(
|
127
|
'type' => 'text',
|
128
|
'not null' => TRUE,
|
129
|
'description' => 'Main source resource identifier. E. g. a path or a URL.',
|
130
|
),
|
131
|
'state' => array(
|
132
|
'type' => 'blob',
|
133
|
'size' => 'big',
|
134
|
'not null' => FALSE,
|
135
|
'description' => 'State of import or clearing batches.',
|
136
|
'serialize' => TRUE,
|
137
|
),
|
138
|
'fetcher_result' => array(
|
139
|
'type' => 'blob',
|
140
|
'size' => 'big',
|
141
|
'not null' => FALSE,
|
142
|
'description' => 'Cache for fetcher result.',
|
143
|
'serialize' => TRUE,
|
144
|
),
|
145
|
'imported' => array(
|
146
|
'type' => 'int',
|
147
|
'not null' => TRUE,
|
148
|
'default' => 0,
|
149
|
'unsigned' => TRUE,
|
150
|
'description' => 'Timestamp when this source was imported last.',
|
151
|
),
|
152
|
),
|
153
|
'primary key' => array('id', 'feed_nid'),
|
154
|
'indexes' => array(
|
155
|
'id' => array('id'),
|
156
|
'feed_nid' => array('feed_nid'),
|
157
|
'id_source' => array('id', array('source', 128)),
|
158
|
),
|
159
|
);
|
160
|
$schema['feeds_item'] = array(
|
161
|
'description' => 'Tracks items such as nodes, terms, users.',
|
162
|
'fields' => array(
|
163
|
'entity_type' => array(
|
164
|
'type' => 'varchar',
|
165
|
'length' => 32,
|
166
|
'not null' => TRUE,
|
167
|
'default' => '',
|
168
|
'description' => 'The entity type.',
|
169
|
),
|
170
|
'entity_id' => array(
|
171
|
'type' => 'int',
|
172
|
'unsigned' => TRUE,
|
173
|
'not null' => TRUE,
|
174
|
'description' => 'The imported entity\'s serial id.',
|
175
|
),
|
176
|
'id' => array(
|
177
|
'type' => 'varchar',
|
178
|
'length' => 128,
|
179
|
'not null' => TRUE,
|
180
|
'default' => '',
|
181
|
'description' => 'The id of the importer that created this item.',
|
182
|
),
|
183
|
'feed_nid' => array(
|
184
|
'type' => 'int',
|
185
|
'unsigned' => TRUE,
|
186
|
'not null' => TRUE,
|
187
|
'description' => 'Node id of the source, if available.',
|
188
|
),
|
189
|
'imported' => array(
|
190
|
'type' => 'int',
|
191
|
'not null' => TRUE,
|
192
|
'default' => 0,
|
193
|
'description' => 'Import date of the feed item, as a Unix timestamp.',
|
194
|
),
|
195
|
'url' => array(
|
196
|
'type' => 'text',
|
197
|
'not null' => TRUE,
|
198
|
'description' => 'Link to the feed item.',
|
199
|
),
|
200
|
'guid' => array(
|
201
|
'type' => 'text',
|
202
|
'not null' => TRUE,
|
203
|
'description' => 'Unique identifier for the feed item.'
|
204
|
),
|
205
|
'hash' => array(
|
206
|
'type' => 'varchar',
|
207
|
'length' => 32, // The length of an MD5 hash.
|
208
|
'not null' => TRUE,
|
209
|
'default' => '',
|
210
|
'description' => 'The hash of the source item.',
|
211
|
),
|
212
|
),
|
213
|
'primary key' => array('entity_type', 'entity_id'),
|
214
|
'indexes' => array(
|
215
|
'id' => array('id'),
|
216
|
'feed_nid' => array('feed_nid'),
|
217
|
'lookup_url' => array('entity_type', 'id', 'feed_nid', array('url', 128)),
|
218
|
'lookup_guid' => array('entity_type', 'id', 'feed_nid', array('guid', 128)),
|
219
|
'global_lookup_url' => array('entity_type', array('url', 128)),
|
220
|
'global_lookup_guid' => array('entity_type', array('guid', 128)),
|
221
|
'imported' => array('imported'),
|
222
|
),
|
223
|
);
|
224
|
$schema['feeds_push_subscriptions'] = array(
|
225
|
'description' => 'PubSubHubbub subscriptions.',
|
226
|
'fields' => array(
|
227
|
'domain' => array(
|
228
|
'type' => 'varchar',
|
229
|
'length' => 128,
|
230
|
'not null' => TRUE,
|
231
|
'default' => '',
|
232
|
'description' => 'Domain of the subscriber. Corresponds to an importer id.',
|
233
|
),
|
234
|
'subscriber_id' => array(
|
235
|
'type' => 'int',
|
236
|
'not null' => TRUE,
|
237
|
'default' => 0,
|
238
|
'unsigned' => TRUE,
|
239
|
'description' => 'ID of the subscriber. Corresponds to a feed nid.',
|
240
|
),
|
241
|
'timestamp' => array(
|
242
|
'type' => 'int',
|
243
|
'unsigned' => FALSE,
|
244
|
'default' => 0,
|
245
|
'not null' => TRUE,
|
246
|
'description' => 'Created timestamp.',
|
247
|
),
|
248
|
'hub' => array(
|
249
|
'type' => 'text',
|
250
|
'not null' => TRUE,
|
251
|
'description' => 'The URL of the hub endpoint of this subscription.',
|
252
|
),
|
253
|
'topic' => array(
|
254
|
'type' => 'text',
|
255
|
'not null' => TRUE,
|
256
|
'description' => 'The topic URL (feed URL) of this subscription.',
|
257
|
),
|
258
|
'secret' => array(
|
259
|
'type' => 'varchar',
|
260
|
'length' => 128,
|
261
|
'not null' => TRUE,
|
262
|
'default' => '',
|
263
|
'description' => 'Shared secret for message authentication.',
|
264
|
),
|
265
|
'status' => array(
|
266
|
'type' => 'varchar',
|
267
|
'length' => 64,
|
268
|
'not null' => TRUE,
|
269
|
'default' => '',
|
270
|
'description' => 'Status of subscription.',
|
271
|
),
|
272
|
'post_fields' => array(
|
273
|
'type' => 'text',
|
274
|
'not null' => FALSE,
|
275
|
'description' => 'Fields posted.',
|
276
|
'serialize' => TRUE,
|
277
|
),
|
278
|
),
|
279
|
'primary key' => array('domain', 'subscriber_id'),
|
280
|
'indexes' => array(
|
281
|
'timestamp' => array('timestamp'),
|
282
|
),
|
283
|
);
|
284
|
$schema['feeds_log'] = array(
|
285
|
'description' => 'Table that contains logs of feeds events.',
|
286
|
'fields' => array(
|
287
|
'flid' => array(
|
288
|
'type' => 'serial',
|
289
|
'not null' => TRUE,
|
290
|
'description' => 'Primary Key: Unique feeds event ID.',
|
291
|
),
|
292
|
'id' => array(
|
293
|
'type' => 'varchar',
|
294
|
'length' => 128,
|
295
|
'not null' => TRUE,
|
296
|
'default' => '',
|
297
|
'description' => 'The id of the importer that logged the event.',
|
298
|
),
|
299
|
'feed_nid' => array(
|
300
|
'type' => 'int',
|
301
|
'unsigned' => TRUE,
|
302
|
'not null' => TRUE,
|
303
|
'description' => 'Node id of the source, if available.',
|
304
|
),
|
305
|
'log_time' => array(
|
306
|
'type' => 'int',
|
307
|
'not null' => TRUE,
|
308
|
'default' => 0,
|
309
|
'description' => 'Unix timestamp of when event occurred.',
|
310
|
),
|
311
|
'request_time' => array(
|
312
|
'type' => 'int',
|
313
|
'not null' => TRUE,
|
314
|
'default' => 0,
|
315
|
'description' => 'Unix timestamp of the request when the event occurred.',
|
316
|
),
|
317
|
'type' => array(
|
318
|
'type' => 'varchar',
|
319
|
'length' => 64,
|
320
|
'not null' => TRUE,
|
321
|
'default' => '',
|
322
|
'description' => 'Type of log message, for example "feeds_import"."',
|
323
|
),
|
324
|
'message' => array(
|
325
|
'type' => 'text',
|
326
|
'not null' => TRUE,
|
327
|
'size' => 'big',
|
328
|
'description' => 'Text of log message to be passed into the t() function.',
|
329
|
),
|
330
|
'variables' => array(
|
331
|
'type' => 'blob',
|
332
|
'not null' => TRUE,
|
333
|
'size' => 'big',
|
334
|
'description' => 'Serialized array of variables that match the message string and that is passed into the t() function.',
|
335
|
),
|
336
|
'severity' => array(
|
337
|
'type' => 'int',
|
338
|
'unsigned' => TRUE,
|
339
|
'not null' => TRUE,
|
340
|
'default' => 0,
|
341
|
'size' => 'tiny',
|
342
|
'description' => 'The severity level of the event; ranges from 0 (Emergency) to 7 (Debug)',
|
343
|
),
|
344
|
),
|
345
|
'primary key' => array('flid'),
|
346
|
'indexes' => array(
|
347
|
'id' => array('id'),
|
348
|
'id_feed_nid' => array('id', 'feed_nid'),
|
349
|
'request_time' => array('request_time'),
|
350
|
'log_time' => array('log_time'),
|
351
|
'type' => array('type'),
|
352
|
),
|
353
|
);
|
354
|
|
355
|
$schema['cache_feeds_http'] = drupal_get_schema_unprocessed('system', 'cache');
|
356
|
$schema['cache_feeds_http']['description'] = 'Cache table for Feeds downloads.';
|
357
|
|
358
|
return $schema;
|
359
|
}
|
360
|
|
361
|
/**
|
362
|
* Rename feeds_source.batch to feeds_source.state, add slot for caching fetcher
|
363
|
* result.
|
364
|
*/
|
365
|
function feeds_update_7100() {
|
366
|
$spec = array(
|
367
|
'type' => 'text',
|
368
|
'size' => 'big',
|
369
|
'not null' => FALSE,
|
370
|
'description' => 'State of import or clearing batches.',
|
371
|
'serialize' => TRUE,
|
372
|
);
|
373
|
db_change_field('feeds_source', 'batch', 'state', $spec);
|
374
|
|
375
|
$spec = array(
|
376
|
'type' => 'text',
|
377
|
'size' => 'big',
|
378
|
'not null' => FALSE,
|
379
|
'description' => 'Cache for fetcher result.',
|
380
|
'serialize' => TRUE,
|
381
|
);
|
382
|
db_add_field('feeds_source', 'fetcher_result', $spec);
|
383
|
}
|
384
|
|
385
|
/**
|
386
|
* Add imported timestamp to feeds_source table.
|
387
|
*/
|
388
|
function feeds_update_7201() {
|
389
|
$spec = array(
|
390
|
'type' => 'int',
|
391
|
'not null' => TRUE,
|
392
|
'default' => 0,
|
393
|
'unsigned' => TRUE,
|
394
|
'description' => 'Timestamp when this source was imported last.',
|
395
|
);
|
396
|
db_add_field('feeds_source', 'imported', $spec);
|
397
|
}
|
398
|
|
399
|
/**
|
400
|
* Create a single feeds_item table tracking all imports.
|
401
|
*/
|
402
|
function feeds_update_7202() {
|
403
|
$spec = array(
|
404
|
'description' => 'Tracks items such as nodes, terms, users.',
|
405
|
'fields' => array(
|
406
|
'entity_type' => array(
|
407
|
'type' => 'varchar',
|
408
|
'length' => 32,
|
409
|
'not null' => TRUE,
|
410
|
'default' => '',
|
411
|
'description' => 'The entity type.',
|
412
|
),
|
413
|
'entity_id' => array(
|
414
|
'type' => 'int',
|
415
|
'unsigned' => TRUE,
|
416
|
'not null' => TRUE,
|
417
|
'description' => 'The imported entity\'s serial id.',
|
418
|
),
|
419
|
'id' => array(
|
420
|
'type' => 'varchar',
|
421
|
'length' => 128,
|
422
|
'not null' => TRUE,
|
423
|
'default' => '',
|
424
|
'description' => 'The id of the importer that created this item.',
|
425
|
),
|
426
|
'feed_nid' => array(
|
427
|
'type' => 'int',
|
428
|
'unsigned' => TRUE,
|
429
|
'not null' => TRUE,
|
430
|
'description' => 'Node id of the source, if available.',
|
431
|
),
|
432
|
'imported' => array(
|
433
|
'type' => 'int',
|
434
|
'not null' => TRUE,
|
435
|
'default' => 0,
|
436
|
'description' => 'Import date of the feed item, as a Unix timestamp.',
|
437
|
),
|
438
|
'url' => array(
|
439
|
'type' => 'text',
|
440
|
'not null' => TRUE,
|
441
|
'description' => 'Link to the feed item.',
|
442
|
),
|
443
|
'guid' => array(
|
444
|
'type' => 'text',
|
445
|
'not null' => TRUE,
|
446
|
'description' => 'Unique identifier for the feed item.'
|
447
|
),
|
448
|
'hash' => array(
|
449
|
'type' => 'varchar',
|
450
|
'length' => 32, // The length of an MD5 hash.
|
451
|
'not null' => TRUE,
|
452
|
'default' => '',
|
453
|
'description' => 'The hash of the source item.',
|
454
|
),
|
455
|
),
|
456
|
'primary key' => array('entity_type', 'entity_id'),
|
457
|
'indexes' => array(
|
458
|
'id' => array('id'),
|
459
|
'feed_nid' => array('feed_nid'),
|
460
|
'lookup_url' => array('entity_type', 'id', 'feed_nid', array('url', 128)),
|
461
|
'lookup_guid' => array('entity_type', 'id', 'feed_nid', array('guid', 128)),
|
462
|
'imported' => array('imported'),
|
463
|
),
|
464
|
);
|
465
|
db_create_table('feeds_item', $spec);
|
466
|
// Copy all existing values from old tables and drop them.
|
467
|
$insert = "INSERT INTO {feeds_item} (entity_type, entity_id, id, feed_nid, imported, url, guid, hash)";
|
468
|
db_query($insert . " SELECT 'node', nid, id, feed_nid, imported, url, guid, hash FROM {feeds_node_item}");
|
469
|
db_query($insert . " SELECT 'taxonomy_term', tid, id, feed_nid, 0, '', '', '' FROM {feeds_term_item}");
|
470
|
db_drop_table('feeds_node_item');
|
471
|
db_drop_table('feeds_term_item');
|
472
|
}
|
473
|
|
474
|
/**
|
475
|
* Add feeds_log table.
|
476
|
*/
|
477
|
function feeds_update_7203() {
|
478
|
$schema = array(
|
479
|
'description' => 'Table that contains logs of feeds events.',
|
480
|
'fields' => array(
|
481
|
'flid' => array(
|
482
|
'type' => 'serial',
|
483
|
'not null' => TRUE,
|
484
|
'description' => 'Primary Key: Unique feeds event ID.',
|
485
|
),
|
486
|
'id' => array(
|
487
|
'type' => 'varchar',
|
488
|
'length' => 128,
|
489
|
'not null' => TRUE,
|
490
|
'default' => '',
|
491
|
'description' => 'The id of the importer that logged the event.',
|
492
|
),
|
493
|
'feed_nid' => array(
|
494
|
'type' => 'int',
|
495
|
'unsigned' => TRUE,
|
496
|
'not null' => TRUE,
|
497
|
'description' => 'Node id of the source, if available.',
|
498
|
),
|
499
|
'log_time' => array(
|
500
|
'type' => 'int',
|
501
|
'not null' => TRUE,
|
502
|
'default' => 0,
|
503
|
'description' => 'Unix timestamp of when event occurred.',
|
504
|
),
|
505
|
'request_time' => array(
|
506
|
'type' => 'int',
|
507
|
'not null' => TRUE,
|
508
|
'default' => 0,
|
509
|
'description' => 'Unix timestamp of the request when the event occurred.',
|
510
|
),
|
511
|
'type' => array(
|
512
|
'type' => 'varchar',
|
513
|
'length' => 64,
|
514
|
'not null' => TRUE,
|
515
|
'default' => '',
|
516
|
'description' => 'Type of log message, for example "feeds_import"."',
|
517
|
),
|
518
|
'message' => array(
|
519
|
'type' => 'text',
|
520
|
'not null' => TRUE,
|
521
|
'size' => 'big',
|
522
|
'description' => 'Text of log message to be passed into the t() function.',
|
523
|
),
|
524
|
'variables' => array(
|
525
|
'type' => 'blob',
|
526
|
'not null' => TRUE,
|
527
|
'size' => 'big',
|
528
|
'description' => 'Serialized array of variables that match the message string and that is passed into the t() function.',
|
529
|
),
|
530
|
'severity' => array(
|
531
|
'type' => 'int',
|
532
|
'unsigned' => TRUE,
|
533
|
'not null' => TRUE,
|
534
|
'default' => 0,
|
535
|
'size' => 'tiny',
|
536
|
'description' => 'The severity level of the event; ranges from 0 (Emergency) to 7 (Debug)',
|
537
|
),
|
538
|
),
|
539
|
'primary key' => array('flid'),
|
540
|
'indexes' => array(
|
541
|
'id' => array('id'),
|
542
|
'id_feed_nid' => array('id', 'feed_nid'),
|
543
|
'request_time' => array('request_time'),
|
544
|
'log_time' => array('log_time'),
|
545
|
'type' => array('type'),
|
546
|
),
|
547
|
);
|
548
|
db_create_table('feeds_log', $schema);
|
549
|
}
|
550
|
|
551
|
/**
|
552
|
* Add index for looking up by entity_type + url/ guid to feeds_item table.
|
553
|
*/
|
554
|
function feeds_update_7204() {
|
555
|
db_add_index('feeds_item', 'global_lookup_url', array('entity_type', array('url', 128)));
|
556
|
db_add_index('feeds_item', 'global_lookup_guid', array('entity_type', array('guid', 128)));
|
557
|
}
|
558
|
|
559
|
/**
|
560
|
* Shorten {feeds_item}.entity_type to 32 chars and shorten relevant indexes.
|
561
|
*/
|
562
|
function feeds_update_7205() {
|
563
|
db_drop_primary_key('feeds_item');
|
564
|
db_drop_index('feeds_item', 'lookup_url');
|
565
|
db_drop_index('feeds_item', 'lookup_guid');
|
566
|
db_drop_index('feeds_item', 'global_lookup_url');
|
567
|
db_drop_index('feeds_item', 'global_lookup_guid');
|
568
|
|
569
|
db_change_field('feeds_item', 'entity_type', 'entity_type', array(
|
570
|
'type' => 'varchar',
|
571
|
'length' => 32,
|
572
|
'not null' => TRUE,
|
573
|
'default' => '',
|
574
|
'description' => 'The entity type.',
|
575
|
));
|
576
|
|
577
|
db_add_primary_key('feeds_item', array('entity_type', 'entity_id'));
|
578
|
db_add_index('feeds_item', 'lookup_url', array('entity_type', 'id', 'feed_nid', array('url', 128)));
|
579
|
db_add_index('feeds_item', 'lookup_guid', array('entity_type', 'id', 'feed_nid', array('guid', 128)));
|
580
|
db_add_index('feeds_item', 'global_lookup_url', array('entity_type', array('url', 128)));
|
581
|
db_add_index('feeds_item', 'global_lookup_guid', array('entity_type', array('guid', 128)));
|
582
|
}
|
583
|
|
584
|
/**
|
585
|
* Change state and fetcher_result fields from text to blob.
|
586
|
*/
|
587
|
function feeds_update_7206() {
|
588
|
db_change_field('feeds_source', 'state', 'state', array(
|
589
|
'type' => 'blob',
|
590
|
'size' => 'big',
|
591
|
'not null' => FALSE,
|
592
|
'description' => 'State of import or clearing batches.',
|
593
|
'serialize' => TRUE,
|
594
|
));
|
595
|
|
596
|
db_change_field('feeds_source', 'fetcher_result', 'fetcher_result', array(
|
597
|
'type' => 'blob',
|
598
|
'size' => 'big',
|
599
|
'not null' => FALSE,
|
600
|
'description' => 'Cache for fetcher result.',
|
601
|
'serialize' => TRUE,
|
602
|
));
|
603
|
}
|
604
|
|
605
|
/**
|
606
|
* Change config fields from text to big blobs.
|
607
|
*/
|
608
|
function feeds_update_7207() {
|
609
|
db_change_field('feeds_importer', 'config', 'config', array(
|
610
|
'type' => 'blob',
|
611
|
'size' => 'big',
|
612
|
'not null' => FALSE,
|
613
|
'description' => 'Configuration of the feeds object.',
|
614
|
'serialize' => TRUE,
|
615
|
));
|
616
|
|
617
|
db_change_field('feeds_source', 'config', 'config', array(
|
618
|
'type' => 'blob',
|
619
|
'size' => 'big',
|
620
|
'not null' => FALSE,
|
621
|
'description' => 'Configuration of the feeds object.',
|
622
|
'serialize' => TRUE,
|
623
|
));
|
624
|
}
|
625
|
|
626
|
/**
|
627
|
* Update to use generic bundle handling.
|
628
|
*/
|
629
|
function feeds_update_7208(&$sandbox) {
|
630
|
|
631
|
if (!isset($sandbox['importers'])) {
|
632
|
// Get all importers.
|
633
|
$sandbox['importers'] = db_query("SELECT id FROM {feeds_importer}")->fetchCol();
|
634
|
$sandbox['total'] = count($sandbox['importers']);
|
635
|
}
|
636
|
|
637
|
$importer = array_pop($sandbox['importers']);
|
638
|
$config = db_query("SELECT config FROM {feeds_importer} WHERE id = :id", array(':id' => $importer))->fetchField();
|
639
|
|
640
|
if ($config) {
|
641
|
$config = unserialize($config);
|
642
|
|
643
|
switch ($config['processor']['plugin_key']) {
|
644
|
case 'FeedsNodeProcessor':
|
645
|
$config_key = 'content_type';
|
646
|
break;
|
647
|
|
648
|
case 'FeedsTermProcessor':
|
649
|
$config_key = 'vocabulary';
|
650
|
break;
|
651
|
|
652
|
default:
|
653
|
$config_key = FALSE;
|
654
|
break;
|
655
|
}
|
656
|
|
657
|
if ($config_key && isset($config['processor']['config'][$config_key])) {
|
658
|
$config['processor']['config']['bundle'] = $config['processor']['config'][$config_key];
|
659
|
unset($config['processor']['config'][$config_key]);
|
660
|
|
661
|
// Update databse.
|
662
|
db_update('feeds_importer')
|
663
|
->fields(array(
|
664
|
'config' => serialize($config),
|
665
|
))
|
666
|
->condition('id', $importer)
|
667
|
->execute();
|
668
|
}
|
669
|
|
670
|
$sandbox['#finished'] = 1 - count($sandbox['importers']) / $sandbox['total'];
|
671
|
}
|
672
|
else {
|
673
|
$sandbox['#finished'] = 1;
|
674
|
}
|
675
|
}
|
676
|
|
677
|
/**
|
678
|
* Reschedules feeds jobs.
|
679
|
*/
|
680
|
function feeds_update_7209() {
|
681
|
// Reschedule all importers.
|
682
|
variable_set('feeds_reschedule', TRUE);
|
683
|
|
684
|
// Our expire callback has changed names, remove all existing callbacks.
|
685
|
db_delete('job_schedule')
|
686
|
->condition('name', 'feeds_importer_expire')
|
687
|
->execute();
|
688
|
|
689
|
DrupalQueue::get('feeds_importer_expire')->deleteQueue();
|
690
|
}
|
691
|
|
692
|
/**
|
693
|
* Fix importer mappings for file and image fields to use :uri convention.
|
694
|
*/
|
695
|
function feeds_update_7211(&$sandbox) {
|
696
|
// If this is the first pass through this update function then set some
|
697
|
// variables.
|
698
|
if (!isset($sandbox['progress'])) {
|
699
|
$importers = feeds_importer_load_all(TRUE);
|
700
|
$sandbox['importers'] = array_keys($importers);
|
701
|
$sandbox['progress'] = 0;
|
702
|
$sandbox['updated_count'] = 0;
|
703
|
$sandbox['max'] = count($sandbox['importers']);
|
704
|
}
|
705
|
|
706
|
if (empty($sandbox['importers'])) {
|
707
|
return t('No importers to process.');
|
708
|
}
|
709
|
|
710
|
// Load a single importer.
|
711
|
$importer = array_pop($sandbox['importers']);
|
712
|
$importer = feeds_importer($importer);
|
713
|
$mappings = $importer->processor->getMappings();
|
714
|
|
715
|
foreach ($mappings as $key => $mapping) {
|
716
|
// Act on mappings that do not contain a colon.
|
717
|
if (strpos($mapping['target'], ':') !== FALSE) {
|
718
|
continue;
|
719
|
}
|
720
|
|
721
|
// Get field data. Check if $info is empty to weed out non-field mappings
|
722
|
// like temporary targets.
|
723
|
if (!$info = field_info_field($mapping['target'])) {
|
724
|
continue;
|
725
|
}
|
726
|
|
727
|
// Act on file or image fields.
|
728
|
if (in_array($info['type'], array('file', 'image'))) {
|
729
|
// Add ':uri' to fix the mapping.
|
730
|
$mappings[$key]['target'] = $mapping['target'] . ':uri';
|
731
|
}
|
732
|
}
|
733
|
|
734
|
// If importer has changed, add the updated config and save it.
|
735
|
if ($importer->processor->getMappings() !== $mappings) {
|
736
|
$importer->processor->addConfig(array('mappings' => $mappings));
|
737
|
$importer->save();
|
738
|
$sandbox['updated_count']++;
|
739
|
}
|
740
|
|
741
|
$sandbox['progress']++;
|
742
|
|
743
|
// Set the value for finished. If progress == max then finished will be 1,
|
744
|
// signifying we are done.
|
745
|
$sandbox['#finished'] = ($sandbox['progress'] / $sandbox['max']);
|
746
|
|
747
|
if (empty($sandbox['importers'])) {
|
748
|
$sandbox['#finished'] = 1;
|
749
|
return t('@importers total importers processed, @updated_count with fields that were updated.', array('@importers' => $sandbox['max'], '@updated_count' => $sandbox['updated_count']));
|
750
|
}
|
751
|
}
|
752
|
|
753
|
/**
|
754
|
* Create {cache_feeds_http} table.
|
755
|
*/
|
756
|
function feeds_update_7212() {
|
757
|
if (!db_table_exists('cache_feeds_http')) {
|
758
|
$schema = drupal_get_schema_unprocessed('system', 'cache');
|
759
|
$schema['description'] = 'Cache table for Feeds downloads.';
|
760
|
db_create_table('cache_feeds_http', $schema);
|
761
|
}
|
762
|
}
|