feeds.install 21 KB

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