drupal-6.upload.database.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. <?php
  2. db_insert('files')->fields(array(
  3. 'fid',
  4. 'uid',
  5. 'filename',
  6. 'filepath',
  7. 'filemime',
  8. 'filesize',
  9. 'status',
  10. 'timestamp',
  11. ))
  12. /*
  13. * This entry is deliberately omitted to test the upgrade routine when facing
  14. * possible data corruption.
  15. *
  16. ->values(array(
  17. 'fid' => '1',
  18. 'uid' => '1',
  19. 'filename' => 'powered-blue-80x15.png',
  20. 'filepath' => 'sites/default/files/powered-blue-80x15.png',
  21. 'filemime' => 'image/png',
  22. 'filesize' => '1011',
  23. 'status' => '1',
  24. 'timestamp' => '1285700240',
  25. )) */
  26. ->values(array(
  27. 'fid' => '2',
  28. 'uid' => '1',
  29. 'filename' => 'powered-blue-80x15.png',
  30. 'filepath' => 'sites/default/files/powered-blue-80x15_0.png',
  31. 'filemime' => 'image/png',
  32. 'filesize' => '1011',
  33. 'status' => '1',
  34. 'timestamp' => '1285700317',
  35. ))
  36. ->values(array(
  37. 'fid' => '3',
  38. 'uid' => '1',
  39. 'filename' => 'powered-blue-88x31.png',
  40. 'filepath' => 'sites/default/files/powered-blue-88x31.png',
  41. 'filemime' => 'image/png',
  42. 'filesize' => '2113',
  43. 'status' => '1',
  44. 'timestamp' => '1285700343',
  45. ))
  46. ->values(array(
  47. 'fid' => '4',
  48. 'uid' => '1',
  49. 'filename' => 'powered-blue-135x42.png',
  50. 'filepath' => 'sites/default/files/powered-blue-135x42.png',
  51. 'filemime' => 'image/png',
  52. 'filesize' => '3027',
  53. 'status' => '1',
  54. 'timestamp' => '1285700366',
  55. ))
  56. ->values(array(
  57. 'fid' => '5',
  58. 'uid' => '1',
  59. 'filename' => 'powered-black-80x15.png',
  60. 'filepath' => 'sites/default/files/powered-black-80x15.png',
  61. 'filemime' => 'image/png',
  62. 'filesize' => '1467',
  63. 'status' => '1',
  64. 'timestamp' => '1285700529',
  65. ))
  66. ->values(array(
  67. 'fid' => '6',
  68. 'uid' => '1',
  69. 'filename' => 'powered-black-135x42.png',
  70. 'filepath' => 'sites/default/files/powered-black-135x42.png',
  71. 'filemime' => 'image/png',
  72. 'filesize' => '2817',
  73. 'status' => '1',
  74. 'timestamp' => '1285700552',
  75. ))
  76. ->values(array(
  77. 'fid' => '7',
  78. 'uid' => '1',
  79. 'filename' => 'forum-hot-new.png',
  80. 'filepath' => 'sites/default/files/forum-hot-new.png',
  81. 'filemime' => 'image/png',
  82. 'filesize' => '237',
  83. 'status' => '1',
  84. 'timestamp' => '1285708937',
  85. ))
  86. ->values(array(
  87. 'fid' => '8',
  88. 'uid' => '1',
  89. 'filename' => 'forum-hot.png',
  90. 'filepath' => 'sites/default/files/forum-hot.png',
  91. 'filemime' => 'image/png',
  92. 'filesize' => '229',
  93. 'status' => '1',
  94. 'timestamp' => '1285708944',
  95. ))
  96. ->values(array(
  97. 'fid' => '9',
  98. 'uid' => '1',
  99. 'filename' => 'forum-new.png',
  100. 'filepath' => 'sites/default/files/forum-new.png',
  101. 'filemime' => 'image/png',
  102. 'filesize' => '175',
  103. 'status' => '1',
  104. 'timestamp' => '1285708950',
  105. ))
  106. ->values(array(
  107. 'fid' => '10',
  108. 'uid' => '1',
  109. 'filename' => 'forum-sticky.png',
  110. 'filepath' => 'sites/default/files/forum-sticky.png',
  111. 'filemime' => 'image/png',
  112. 'filesize' => '329',
  113. 'status' => '1',
  114. 'timestamp' => '1285708957',
  115. ))
  116. /*
  117. * This is a case where the path is repeated twice.
  118. */
  119. ->values(array(
  120. 'fid' => '11',
  121. 'uid' => '1',
  122. 'filename' => 'crazy-basename.png',
  123. 'filepath' => '/drupal-6/file/directory/path/drupal-6/file/directory/path/crazy-basename.png',
  124. 'filemime' => 'image/png',
  125. 'filesize' => '329',
  126. 'status' => '1',
  127. 'timestamp' => '1285708958',
  128. ))
  129. // On some Drupal 6 sites, more than one file can have the same filepath. See
  130. // https://www.drupal.org/node/1260938.
  131. ->values(array(
  132. 'fid' => '12',
  133. 'uid' => '1',
  134. 'filename' => 'duplicate-name.png',
  135. 'filepath' => 'sites/default/files/duplicate-name.png',
  136. 'filemime' => 'image/png',
  137. 'filesize' => '314',
  138. 'status' => '1',
  139. 'timestamp' => '1285708958',
  140. ))
  141. ->values(array(
  142. 'fid' => '13',
  143. 'uid' => '1',
  144. 'filename' => 'duplicate-name.png',
  145. 'filepath' => 'sites/default/files/duplicate-name.png',
  146. 'filemime' => 'image/png',
  147. 'filesize' => '315',
  148. 'status' => '1',
  149. 'timestamp' => '1285708958',
  150. ))
  151. ->values(array(
  152. 'fid' => '14',
  153. 'uid' => '1',
  154. 'filename' => 'duplicate-name.png',
  155. 'filepath' => 'sites/default/files/duplicate-name.png',
  156. 'filemime' => 'image/png',
  157. 'filesize' => '316',
  158. 'status' => '1',
  159. 'timestamp' => '1285708958',
  160. ))
  161. ->execute();
  162. db_insert('node')->fields(array(
  163. 'nid',
  164. 'vid',
  165. 'type',
  166. 'language',
  167. 'title',
  168. 'uid',
  169. 'status',
  170. 'created',
  171. 'changed',
  172. 'comment',
  173. 'promote',
  174. 'moderate',
  175. 'sticky',
  176. 'tnid',
  177. 'translate',
  178. ))
  179. ->values(array(
  180. 'nid' => '38',
  181. 'vid' => '50',
  182. 'type' => 'page',
  183. 'language' => '',
  184. 'title' => 'node title 38 revision 50',
  185. 'uid' => '1',
  186. 'status' => '1',
  187. 'created' => '1285603317',
  188. 'changed' => '1285603317',
  189. 'comment' => '0',
  190. 'promote' => '0',
  191. 'moderate' => '0',
  192. 'sticky' => '0',
  193. 'tnid' => '0',
  194. 'translate' => '0',
  195. ))
  196. ->values(array(
  197. 'nid' => '39',
  198. 'vid' => '52',
  199. 'type' => 'page',
  200. 'language' => '',
  201. 'title' => 'node title 39 revision 52',
  202. 'uid' => '1',
  203. 'status' => '1',
  204. 'created' => '1285700317',
  205. 'changed' => '1285700600',
  206. 'comment' => '0',
  207. 'promote' => '0',
  208. 'moderate' => '0',
  209. 'sticky' => '0',
  210. 'tnid' => '0',
  211. 'translate' => '0',
  212. ))
  213. ->values(array(
  214. 'nid' => '40',
  215. 'vid' => '53',
  216. 'type' => 'page',
  217. 'language' => '',
  218. 'title' => 'node title 40 revision 53',
  219. 'uid' => '1',
  220. 'status' => '1',
  221. 'created' => '1285709012',
  222. 'changed' => '1285709012',
  223. 'comment' => '0',
  224. 'promote' => '0',
  225. 'moderate' => '0',
  226. 'sticky' => '0',
  227. 'tnid' => '0',
  228. 'translate' => '0',
  229. ))
  230. ->values(array(
  231. 'nid' => '41',
  232. 'vid' => '55',
  233. 'type' => 'page',
  234. 'language' => '',
  235. 'title' => 'node title 41 revision 55',
  236. 'uid' => '1',
  237. 'status' => '1',
  238. 'created' => '1285709012',
  239. 'changed' => '1285709012',
  240. 'comment' => '0',
  241. 'promote' => '0',
  242. 'moderate' => '0',
  243. 'sticky' => '0',
  244. 'tnid' => '0',
  245. 'translate' => '0',
  246. ))
  247. ->execute();
  248. db_insert('node_revisions')->fields(array(
  249. 'nid',
  250. 'vid',
  251. 'uid',
  252. 'title',
  253. 'body',
  254. 'teaser',
  255. 'log',
  256. 'timestamp',
  257. 'format',
  258. ))
  259. ->values(array(
  260. 'nid' => '38',
  261. 'vid' => '50',
  262. 'uid' => '1',
  263. 'title' => 'node title 38 revision 50',
  264. 'body' => "Attachments:\r\npowered-blue-80x15.png",
  265. 'teaser' => "Attachments:\r\npowered-blue-80x15.png",
  266. 'log' => '',
  267. 'timestamp' => '1285603317',
  268. 'format' => '1',
  269. ))
  270. ->values(array(
  271. 'nid' => '39',
  272. 'vid' => '51',
  273. 'uid' => '1',
  274. 'title' => 'node title 39 revision 51',
  275. 'body' => "Attachments:\r\npowered-blue-80x15.png\r\npowered-blue-88x31.png\r\npowered-blue-135x42.png",
  276. 'teaser' => "Attachments:\r\npowered-blue-80x15.png\r\npowered-blue-88x31.png\r\npowered-blue-135x42.png",
  277. 'log' => '',
  278. 'timestamp' => '1285700487',
  279. 'format' => '1',
  280. ))
  281. ->values(array(
  282. 'nid' => '39',
  283. 'vid' => '52',
  284. 'uid' => '1',
  285. 'title' => 'node title 39 revision 52',
  286. 'body' => "Attachments:\r\npowered-blue-88x31.png\r\npowered-black-80x15.png\r\npowered-black-135x42.png",
  287. 'teaser' => "Attachments:\r\npowered-blue-88x31.png\r\npowered-black-80x15.png\r\npowered-black-135x42.png",
  288. 'log' => '',
  289. 'timestamp' => '1285700600',
  290. 'format' => '1',
  291. ))
  292. ->values(array(
  293. 'nid' => '40',
  294. 'vid' => '53',
  295. 'uid' => '1',
  296. 'title' => 'node title 40 revision 53',
  297. 'body' => "Attachments:\r\nforum-hot-new.png\r\nforum-hot.png\r\nforum-sticky.png\r\nforum-new.png\r\ncrazy-basename.png",
  298. 'teaser' => "Attachments:\r\nforum-hot-new.png\r\nforum-hot.png\r\nforum-sticky.png\r\nforum-new.png\r\ncrazy-basename.png",
  299. 'log' => '',
  300. 'timestamp' => '1285709012',
  301. 'format' => '1',
  302. ))
  303. ->values(array(
  304. 'nid' => '41',
  305. 'vid' => '54',
  306. 'uid' => '1',
  307. 'title' => 'node title 41 revision 54',
  308. 'body' => "Attachments:\r\nduplicate-name.png",
  309. 'teaser' => "Attachments:\r\nduplicate-name.png",
  310. 'log' => '',
  311. 'timestamp' => '1285709012',
  312. 'format' => '1',
  313. ))
  314. ->values(array(
  315. 'nid' => '41',
  316. 'vid' => '55',
  317. 'uid' => '1',
  318. 'title' => 'node title 41 revision 55',
  319. 'body' => "Attachments:\r\nduplicate-name.png\r\nduplicate-name.png",
  320. 'teaser' => "Attachments:\r\nduplicate-name.png\r\nduplicate-name.png",
  321. 'log' => '',
  322. 'timestamp' => '1285709012',
  323. 'format' => '1',
  324. ))
  325. ->execute();
  326. db_create_table('upload', array(
  327. 'fields' => array(
  328. 'fid' => array(
  329. 'type' => 'int',
  330. 'unsigned' => TRUE,
  331. 'not null' => TRUE,
  332. 'default' => 0,
  333. ),
  334. 'nid' => array(
  335. 'type' => 'int',
  336. 'unsigned' => TRUE,
  337. 'not null' => TRUE,
  338. 'default' => 0,
  339. ),
  340. 'vid' => array(
  341. 'type' => 'int',
  342. 'unsigned' => TRUE,
  343. 'not null' => TRUE,
  344. 'default' => 0,
  345. ),
  346. 'description' => array(
  347. 'type' => 'varchar',
  348. 'length' => 255,
  349. 'not null' => TRUE,
  350. 'default' => '',
  351. ),
  352. 'list' => array(
  353. 'type' => 'int',
  354. 'unsigned' => TRUE,
  355. 'not null' => TRUE,
  356. 'default' => 0,
  357. 'size' => 'tiny',
  358. ),
  359. 'weight' => array(
  360. 'type' => 'int',
  361. 'not null' => TRUE,
  362. 'default' => 0,
  363. 'size' => 'tiny',
  364. ),
  365. ),
  366. 'primary key' => array(
  367. 'vid',
  368. 'fid',
  369. ),
  370. 'indexes' => array(
  371. 'fid' => array(
  372. 'fid',
  373. ),
  374. 'nid' => array(
  375. 'nid',
  376. ),
  377. ),
  378. 'module' => 'upload',
  379. 'name' => 'upload',
  380. ));
  381. db_insert('upload')->fields(array(
  382. 'fid',
  383. 'nid',
  384. 'vid',
  385. 'description',
  386. 'list',
  387. 'weight',
  388. ))
  389. ->values(array(
  390. 'fid' => '1',
  391. 'nid' => '38',
  392. 'vid' => '50',
  393. 'description' => 'powered-blue-80x15.png',
  394. 'list' => '1',
  395. 'weight' => '0',
  396. ))
  397. ->values(array(
  398. 'fid' => '2',
  399. 'nid' => '39',
  400. 'vid' => '51',
  401. 'description' => 'powered-blue-80x15.png',
  402. 'list' => '1',
  403. 'weight' => '0',
  404. ))
  405. ->values(array(
  406. 'fid' => '3',
  407. 'nid' => '39',
  408. 'vid' => '51',
  409. 'description' => 'powered-blue-88x31.png',
  410. 'list' => '1',
  411. 'weight' => '0',
  412. ))
  413. ->values(array(
  414. 'fid' => '4',
  415. 'nid' => '39',
  416. 'vid' => '51',
  417. 'description' => 'powered-blue-135x42.png',
  418. 'list' => '1',
  419. 'weight' => '0',
  420. ))
  421. ->values(array(
  422. 'fid' => '3',
  423. 'nid' => '39',
  424. 'vid' => '52',
  425. 'description' => 'powered-blue-88x31.png',
  426. 'list' => '1',
  427. 'weight' => '0',
  428. ))
  429. ->values(array(
  430. 'fid' => '5',
  431. 'nid' => '39',
  432. 'vid' => '52',
  433. 'description' => 'powered-black-80x15.png',
  434. 'list' => '1',
  435. 'weight' => '0',
  436. ))
  437. ->values(array(
  438. 'fid' => '6',
  439. 'nid' => '39',
  440. 'vid' => '52',
  441. 'description' => 'powered-black-135x42.png',
  442. 'list' => '1',
  443. 'weight' => '0',
  444. ))
  445. ->values(array(
  446. 'fid' => '7',
  447. 'nid' => '40',
  448. 'vid' => '53',
  449. 'description' => 'forum-hot-new.png',
  450. 'list' => '1',
  451. 'weight' => '-4',
  452. ))
  453. ->values(array(
  454. 'fid' => '8',
  455. 'nid' => '40',
  456. 'vid' => '53',
  457. 'description' => 'forum-hot.png',
  458. 'list' => '1',
  459. 'weight' => '-3',
  460. ))
  461. ->values(array(
  462. 'fid' => '10',
  463. 'nid' => '40',
  464. 'vid' => '53',
  465. 'description' => 'forum-sticky.png',
  466. 'list' => '1',
  467. 'weight' => '-2',
  468. ))
  469. ->values(array(
  470. 'fid' => '9',
  471. 'nid' => '40',
  472. 'vid' => '53',
  473. 'description' => 'forum-new.png',
  474. 'list' => '1',
  475. 'weight' => '-1',
  476. ))
  477. ->values(array(
  478. 'fid' => '11',
  479. 'nid' => '40',
  480. 'vid' => '53',
  481. 'description' => 'crazy-basename.png',
  482. 'list' => '1',
  483. 'weight' => '0',
  484. ))
  485. ->values(array(
  486. 'fid' => '12',
  487. 'nid' => '41',
  488. 'vid' => '54',
  489. 'description' => 'duplicate-name.png',
  490. 'list' => '1',
  491. 'weight' => '0',
  492. ))
  493. ->values(array(
  494. 'fid' => '13',
  495. 'nid' => '41',
  496. 'vid' => '55',
  497. 'description' => 'first description',
  498. 'list' => '0',
  499. 'weight' => '0',
  500. ))
  501. ->values(array(
  502. 'fid' => '14',
  503. 'nid' => '41',
  504. 'vid' => '55',
  505. 'description' => 'second description',
  506. 'list' => '1',
  507. 'weight' => '0',
  508. ))
  509. ->execute();
  510. // Add series of entries for invalid node vids to the {upload} table.
  511. for ($i = 30; $i < 250; $i += 2) {
  512. db_insert('upload')->fields(array(
  513. 'fid',
  514. 'nid',
  515. 'vid',
  516. 'description',
  517. 'list',
  518. 'weight',
  519. ))
  520. // Invalid fid, invalid vid.
  521. ->values(array(
  522. 'fid' => $i,
  523. 'nid' => '40',
  524. 'vid' => 26 + $i,
  525. 'description' => 'crazy-basename.png',
  526. 'list' => '1',
  527. 'weight' => '0',
  528. ))
  529. // Valid fid, invalid vid.
  530. ->values(array(
  531. 'fid' => 2,
  532. 'nid' => '40',
  533. 'vid' => 26 + $i + 1,
  534. 'description' => 'crazy-basename.png',
  535. 'list' => '1',
  536. 'weight' => '0',
  537. ))
  538. ->execute();
  539. }