drupal-6.upload.database.php 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  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. ->execute();
  130. db_insert('node')->fields(array(
  131. 'nid',
  132. 'vid',
  133. 'type',
  134. 'language',
  135. 'title',
  136. 'uid',
  137. 'status',
  138. 'created',
  139. 'changed',
  140. 'comment',
  141. 'promote',
  142. 'moderate',
  143. 'sticky',
  144. 'tnid',
  145. 'translate',
  146. ))
  147. ->values(array(
  148. 'nid' => '38',
  149. 'vid' => '50',
  150. 'type' => 'page',
  151. 'language' => '',
  152. 'title' => 'node title 38 revision 50',
  153. 'uid' => '1',
  154. 'status' => '1',
  155. 'created' => '1285603317',
  156. 'changed' => '1285603317',
  157. 'comment' => '0',
  158. 'promote' => '0',
  159. 'moderate' => '0',
  160. 'sticky' => '0',
  161. 'tnid' => '0',
  162. 'translate' => '0',
  163. ))
  164. ->values(array(
  165. 'nid' => '39',
  166. 'vid' => '52',
  167. 'type' => 'page',
  168. 'language' => '',
  169. 'title' => 'node title 39 revision 52',
  170. 'uid' => '1',
  171. 'status' => '1',
  172. 'created' => '1285700317',
  173. 'changed' => '1285700600',
  174. 'comment' => '0',
  175. 'promote' => '0',
  176. 'moderate' => '0',
  177. 'sticky' => '0',
  178. 'tnid' => '0',
  179. 'translate' => '0',
  180. ))
  181. ->values(array(
  182. 'nid' => '40',
  183. 'vid' => '53',
  184. 'type' => 'page',
  185. 'language' => '',
  186. 'title' => 'node title 40 revision 53',
  187. 'uid' => '1',
  188. 'status' => '1',
  189. 'created' => '1285709012',
  190. 'changed' => '1285709012',
  191. 'comment' => '0',
  192. 'promote' => '0',
  193. 'moderate' => '0',
  194. 'sticky' => '0',
  195. 'tnid' => '0',
  196. 'translate' => '0',
  197. ))
  198. ->execute();
  199. db_insert('node_revisions')->fields(array(
  200. 'nid',
  201. 'vid',
  202. 'uid',
  203. 'title',
  204. 'body',
  205. 'teaser',
  206. 'log',
  207. 'timestamp',
  208. 'format',
  209. ))
  210. ->values(array(
  211. 'nid' => '38',
  212. 'vid' => '50',
  213. 'uid' => '1',
  214. 'title' => 'node title 38 revision 50',
  215. 'body' => "Attachments:\r\npowered-blue-80x15.png",
  216. 'teaser' => "Attachments:\r\npowered-blue-80x15.png",
  217. 'log' => '',
  218. 'timestamp' => '1285603317',
  219. 'format' => '1',
  220. ))
  221. ->values(array(
  222. 'nid' => '39',
  223. 'vid' => '51',
  224. 'uid' => '1',
  225. 'title' => 'node title 39 revision 51',
  226. 'body' => "Attachments:\r\npowered-blue-80x15.png\r\npowered-blue-88x31.png\r\npowered-blue-135x42.png",
  227. 'teaser' => "Attachments:\r\npowered-blue-80x15.png\r\npowered-blue-88x31.png\r\npowered-blue-135x42.png",
  228. 'log' => '',
  229. 'timestamp' => '1285700487',
  230. 'format' => '1',
  231. ))
  232. ->values(array(
  233. 'nid' => '39',
  234. 'vid' => '52',
  235. 'uid' => '1',
  236. 'title' => 'node title 39 revision 52',
  237. 'body' => "Attachments:\r\npowered-blue-88x31.png\r\npowered-black-80x15.png\r\npowered-black-135x42.png",
  238. 'teaser' => "Attachments:\r\npowered-blue-88x31.png\r\npowered-black-80x15.png\r\npowered-black-135x42.png",
  239. 'log' => '',
  240. 'timestamp' => '1285700600',
  241. 'format' => '1',
  242. ))
  243. ->values(array(
  244. 'nid' => '40',
  245. 'vid' => '53',
  246. 'uid' => '1',
  247. 'title' => 'node title 40 revision 53',
  248. 'body' => "Attachments:\r\nforum-hot-new.png\r\nforum-hot.png\r\nforum-sticky.png\r\nforum-new.png\r\ncrazy-basename.png",
  249. 'teaser' => "Attachments:\r\nforum-hot-new.png\r\nforum-hot.png\r\nforum-sticky.png\r\nforum-new.png\r\ncrazy-basename.png",
  250. 'log' => '',
  251. 'timestamp' => '1285709012',
  252. 'format' => '1',
  253. ))
  254. ->execute();
  255. db_create_table('upload', array(
  256. 'fields' => array(
  257. 'fid' => array(
  258. 'type' => 'int',
  259. 'unsigned' => TRUE,
  260. 'not null' => TRUE,
  261. 'default' => 0,
  262. ),
  263. 'nid' => array(
  264. 'type' => 'int',
  265. 'unsigned' => TRUE,
  266. 'not null' => TRUE,
  267. 'default' => 0,
  268. ),
  269. 'vid' => array(
  270. 'type' => 'int',
  271. 'unsigned' => TRUE,
  272. 'not null' => TRUE,
  273. 'default' => 0,
  274. ),
  275. 'description' => array(
  276. 'type' => 'varchar',
  277. 'length' => 255,
  278. 'not null' => TRUE,
  279. 'default' => '',
  280. ),
  281. 'list' => array(
  282. 'type' => 'int',
  283. 'unsigned' => TRUE,
  284. 'not null' => TRUE,
  285. 'default' => 0,
  286. 'size' => 'tiny',
  287. ),
  288. 'weight' => array(
  289. 'type' => 'int',
  290. 'not null' => TRUE,
  291. 'default' => 0,
  292. 'size' => 'tiny',
  293. ),
  294. ),
  295. 'primary key' => array(
  296. 'vid',
  297. 'fid',
  298. ),
  299. 'indexes' => array(
  300. 'fid' => array(
  301. 'fid',
  302. ),
  303. 'nid' => array(
  304. 'nid',
  305. ),
  306. ),
  307. 'module' => 'upload',
  308. 'name' => 'upload',
  309. ));
  310. db_insert('upload')->fields(array(
  311. 'fid',
  312. 'nid',
  313. 'vid',
  314. 'description',
  315. 'list',
  316. 'weight',
  317. ))
  318. ->values(array(
  319. 'fid' => '1',
  320. 'nid' => '38',
  321. 'vid' => '50',
  322. 'description' => 'powered-blue-80x15.png',
  323. 'list' => '1',
  324. 'weight' => '0',
  325. ))
  326. ->values(array(
  327. 'fid' => '2',
  328. 'nid' => '39',
  329. 'vid' => '51',
  330. 'description' => 'powered-blue-80x15.png',
  331. 'list' => '1',
  332. 'weight' => '0',
  333. ))
  334. ->values(array(
  335. 'fid' => '3',
  336. 'nid' => '39',
  337. 'vid' => '51',
  338. 'description' => 'powered-blue-88x31.png',
  339. 'list' => '1',
  340. 'weight' => '0',
  341. ))
  342. ->values(array(
  343. 'fid' => '4',
  344. 'nid' => '39',
  345. 'vid' => '51',
  346. 'description' => 'powered-blue-135x42.png',
  347. 'list' => '1',
  348. 'weight' => '0',
  349. ))
  350. ->values(array(
  351. 'fid' => '3',
  352. 'nid' => '39',
  353. 'vid' => '52',
  354. 'description' => 'powered-blue-88x31.png',
  355. 'list' => '1',
  356. 'weight' => '0',
  357. ))
  358. ->values(array(
  359. 'fid' => '5',
  360. 'nid' => '39',
  361. 'vid' => '52',
  362. 'description' => 'powered-black-80x15.png',
  363. 'list' => '1',
  364. 'weight' => '0',
  365. ))
  366. ->values(array(
  367. 'fid' => '6',
  368. 'nid' => '39',
  369. 'vid' => '52',
  370. 'description' => 'powered-black-135x42.png',
  371. 'list' => '1',
  372. 'weight' => '0',
  373. ))
  374. ->values(array(
  375. 'fid' => '7',
  376. 'nid' => '40',
  377. 'vid' => '53',
  378. 'description' => 'forum-hot-new.png',
  379. 'list' => '1',
  380. 'weight' => '-4',
  381. ))
  382. ->values(array(
  383. 'fid' => '8',
  384. 'nid' => '40',
  385. 'vid' => '53',
  386. 'description' => 'forum-hot.png',
  387. 'list' => '1',
  388. 'weight' => '-3',
  389. ))
  390. ->values(array(
  391. 'fid' => '10',
  392. 'nid' => '40',
  393. 'vid' => '53',
  394. 'description' => 'forum-sticky.png',
  395. 'list' => '1',
  396. 'weight' => '-2',
  397. ))
  398. ->values(array(
  399. 'fid' => '9',
  400. 'nid' => '40',
  401. 'vid' => '53',
  402. 'description' => 'forum-new.png',
  403. 'list' => '1',
  404. 'weight' => '-1',
  405. ))
  406. ->values(array(
  407. 'fid' => '11',
  408. 'nid' => '40',
  409. 'vid' => '53',
  410. 'description' => 'crazy-basename.png',
  411. 'list' => '1',
  412. 'weight' => '0',
  413. ))
  414. ->execute();
  415. // Add series of entries for invalid node vids to the {upload} table.
  416. for ($i = 30; $i < 250; $i += 2) {
  417. db_insert('upload')->fields(array(
  418. 'fid',
  419. 'nid',
  420. 'vid',
  421. 'description',
  422. 'list',
  423. 'weight',
  424. ))
  425. // Invalid fid, invalid vid.
  426. ->values(array(
  427. 'fid' => $i,
  428. 'nid' => '40',
  429. 'vid' => 24 + $i,
  430. 'description' => 'crazy-basename.png',
  431. 'list' => '1',
  432. 'weight' => '0',
  433. ))
  434. // Valid fid, invalid vid.
  435. ->values(array(
  436. 'fid' => 2,
  437. 'nid' => '40',
  438. 'vid' => 24 + $i + 1,
  439. 'description' => 'crazy-basename.png',
  440. 'list' => '1',
  441. 'weight' => '0',
  442. ))
  443. ->execute();
  444. }