Projet

Général

Profil

Paste
Télécharger (9,43 ko) Statistiques
| Branche: | Révision:

root / drupal7 / modules / simpletest / tests / upgrade / drupal-6.upload.database.php @ 1afa1695

1
<?php
2

    
3
db_insert('files')->fields(array(
4
  'fid',
5
  'uid',
6
  'filename',
7
  'filepath',
8
  'filemime',
9
  'filesize',
10
  'status',
11
  'timestamp',
12
))
13
/*
14
 * This entry is deliberately omitted to test the upgrade routine when facing
15
 * possible data corruption.
16
 *
17
->values(array(
18
  'fid' => '1',
19
  'uid' => '1',
20
  'filename' => 'powered-blue-80x15.png',
21
  'filepath' => 'sites/default/files/powered-blue-80x15.png',
22
  'filemime' => 'image/png',
23
  'filesize' => '1011',
24
  'status' => '1',
25
  'timestamp' => '1285700240',
26
)) */
27
->values(array(
28
  'fid' => '2',
29
  'uid' => '1',
30
  'filename' => 'powered-blue-80x15.png',
31
  'filepath' => 'sites/default/files/powered-blue-80x15_0.png',
32
  'filemime' => 'image/png',
33
  'filesize' => '1011',
34
  'status' => '1',
35
  'timestamp' => '1285700317',
36
))
37
->values(array(
38
  'fid' => '3',
39
  'uid' => '1',
40
  'filename' => 'powered-blue-88x31.png',
41
  'filepath' => 'sites/default/files/powered-blue-88x31.png',
42
  'filemime' => 'image/png',
43
  'filesize' => '2113',
44
  'status' => '1',
45
  'timestamp' => '1285700343',
46
))
47
->values(array(
48
  'fid' => '4',
49
  'uid' => '1',
50
  'filename' => 'powered-blue-135x42.png',
51
  'filepath' => 'sites/default/files/powered-blue-135x42.png',
52
  'filemime' => 'image/png',
53
  'filesize' => '3027',
54
  'status' => '1',
55
  'timestamp' => '1285700366',
56
))
57
->values(array(
58
  'fid' => '5',
59
  'uid' => '1',
60
  'filename' => 'powered-black-80x15.png',
61
  'filepath' => 'sites/default/files/powered-black-80x15.png',
62
  'filemime' => 'image/png',
63
  'filesize' => '1467',
64
  'status' => '1',
65
  'timestamp' => '1285700529',
66
))
67
->values(array(
68
  'fid' => '6',
69
  'uid' => '1',
70
  'filename' => 'powered-black-135x42.png',
71
  'filepath' => 'sites/default/files/powered-black-135x42.png',
72
  'filemime' => 'image/png',
73
  'filesize' => '2817',
74
  'status' => '1',
75
  'timestamp' => '1285700552',
76
))
77
->values(array(
78
  'fid' => '7',
79
  'uid' => '1',
80
  'filename' => 'forum-hot-new.png',
81
  'filepath' => 'sites/default/files/forum-hot-new.png',
82
  'filemime' => 'image/png',
83
  'filesize' => '237',
84
  'status' => '1',
85
  'timestamp' => '1285708937',
86
))
87
->values(array(
88
  'fid' => '8',
89
  'uid' => '1',
90
  'filename' => 'forum-hot.png',
91
  'filepath' => 'sites/default/files/forum-hot.png',
92
  'filemime' => 'image/png',
93
  'filesize' => '229',
94
  'status' => '1',
95
  'timestamp' => '1285708944',
96
))
97
->values(array(
98
  'fid' => '9',
99
  'uid' => '1',
100
  'filename' => 'forum-new.png',
101
  'filepath' => 'sites/default/files/forum-new.png',
102
  'filemime' => 'image/png',
103
  'filesize' => '175',
104
  'status' => '1',
105
  'timestamp' => '1285708950',
106
))
107
->values(array(
108
  'fid' => '10',
109
  'uid' => '1',
110
  'filename' => 'forum-sticky.png',
111
  'filepath' => 'sites/default/files/forum-sticky.png',
112
  'filemime' => 'image/png',
113
  'filesize' => '329',
114
  'status' => '1',
115
  'timestamp' => '1285708957',
116
))
117
/*
118
 * This is a case where the path is repeated twice.
119
 */
120
->values(array(
121
  'fid' => '11',
122
  'uid' => '1',
123
  'filename' => 'crazy-basename.png',
124
  'filepath' => '/drupal-6/file/directory/path/drupal-6/file/directory/path/crazy-basename.png',
125
  'filemime' => 'image/png',
126
  'filesize' => '329',
127
  'status' => '1',
128
  'timestamp' => '1285708958',
129
))
130
->execute();
131

    
132
db_insert('node')->fields(array(
133
  'nid',
134
  'vid',
135
  'type',
136
  'language',
137
  'title',
138
  'uid',
139
  'status',
140
  'created',
141
  'changed',
142
  'comment',
143
  'promote',
144
  'moderate',
145
  'sticky',
146
  'tnid',
147
  'translate',
148
))
149
->values(array(
150
  'nid' => '38',
151
  'vid' => '50',
152
  'type' => 'page',
153
  'language' => '',
154
  'title' => 'node title 38 revision 50',
155
  'uid' => '1',
156
  'status' => '1',
157
  'created' => '1285603317',
158
  'changed' => '1285603317',
159
  'comment' => '0',
160
  'promote' => '0',
161
  'moderate' => '0',
162
  'sticky' => '0',
163
  'tnid' => '0',
164
  'translate' => '0',
165
))
166
->values(array(
167
  'nid' => '39',
168
  'vid' => '52',
169
  'type' => 'page',
170
  'language' => '',
171
  'title' => 'node title 39 revision 52',
172
  'uid' => '1',
173
  'status' => '1',
174
  'created' => '1285700317',
175
  'changed' => '1285700600',
176
  'comment' => '0',
177
  'promote' => '0',
178
  'moderate' => '0',
179
  'sticky' => '0',
180
  'tnid' => '0',
181
  'translate' => '0',
182
))
183
->values(array(
184
  'nid' => '40',
185
  'vid' => '53',
186
  'type' => 'page',
187
  'language' => '',
188
  'title' => 'node title 40 revision 53',
189
  'uid' => '1',
190
  'status' => '1',
191
  'created' => '1285709012',
192
  'changed' => '1285709012',
193
  'comment' => '0',
194
  'promote' => '0',
195
  'moderate' => '0',
196
  'sticky' => '0',
197
  'tnid' => '0',
198
  'translate' => '0',
199
))
200
 ->execute();
201

    
202
db_insert('node_revisions')->fields(array(
203
  'nid',
204
  'vid',
205
  'uid',
206
  'title',
207
  'body',
208
  'teaser',
209
  'log',
210
  'timestamp',
211
  'format',
212
))
213
->values(array(
214
  'nid' => '38',
215
  'vid' => '50',
216
  'uid' => '1',
217
  'title' => 'node title 38 revision 50',
218
  'body' => "Attachments:\r\npowered-blue-80x15.png",
219
  'teaser' => "Attachments:\r\npowered-blue-80x15.png",
220
  'log' => '',
221
  'timestamp' => '1285603317',
222
  'format' => '1',
223
))
224
->values(array(
225
  'nid' => '39',
226
  'vid' => '51',
227
  'uid' => '1',
228
  'title' => 'node title 39 revision 51',
229
  'body' => "Attachments:\r\npowered-blue-80x15.png\r\npowered-blue-88x31.png\r\npowered-blue-135x42.png",
230
  'teaser' => "Attachments:\r\npowered-blue-80x15.png\r\npowered-blue-88x31.png\r\npowered-blue-135x42.png",
231
  'log' => '',
232
  'timestamp' => '1285700487',
233
  'format' => '1',
234
))
235
->values(array(
236
  'nid' => '39',
237
  'vid' => '52',
238
  'uid' => '1',
239
  'title' => 'node title 39 revision 52',
240
  'body' => "Attachments:\r\npowered-blue-88x31.png\r\npowered-black-80x15.png\r\npowered-black-135x42.png",
241
  'teaser' => "Attachments:\r\npowered-blue-88x31.png\r\npowered-black-80x15.png\r\npowered-black-135x42.png",
242
  'log' => '',
243
  'timestamp' => '1285700600',
244
  'format' => '1',
245
))
246
->values(array(
247
  'nid' => '40',
248
  'vid' => '53',
249
  'uid' => '1',
250
  'title' => 'node title 40 revision 53',
251
  'body' => "Attachments:\r\nforum-hot-new.png\r\nforum-hot.png\r\nforum-sticky.png\r\nforum-new.png\r\ncrazy-basename.png",
252
  'teaser' => "Attachments:\r\nforum-hot-new.png\r\nforum-hot.png\r\nforum-sticky.png\r\nforum-new.png\r\ncrazy-basename.png",
253
  'log' => '',
254
  'timestamp' => '1285709012',
255
  'format' => '1',
256
))
257
 ->execute();
258

    
259
db_create_table('upload', array(
260
  'fields' => array(
261
    'fid' => array(
262
      'type' => 'int',
263
      'unsigned' => TRUE,
264
      'not null' => TRUE,
265
      'default' => 0,
266
    ),
267
    'nid' => array(
268
      'type' => 'int',
269
      'unsigned' => TRUE,
270
      'not null' => TRUE,
271
      'default' => 0,
272
    ),
273
    'vid' => array(
274
      'type' => 'int',
275
      'unsigned' => TRUE,
276
      'not null' => TRUE,
277
      'default' => 0,
278
    ),
279
    'description' => array(
280
      'type' => 'varchar',
281
      'length' => 255,
282
      'not null' => TRUE,
283
      'default' => '',
284
    ),
285
    'list' => array(
286
      'type' => 'int',
287
      'unsigned' => TRUE,
288
      'not null' => TRUE,
289
      'default' => 0,
290
      'size' => 'tiny',
291
    ),
292
    'weight' => array(
293
      'type' => 'int',
294
      'not null' => TRUE,
295
      'default' => 0,
296
      'size' => 'tiny',
297
    ),
298
  ),
299
  'primary key' => array(
300
    'vid',
301
    'fid',
302
  ),
303
  'indexes' => array(
304
    'fid' => array(
305
      'fid',
306
    ),
307
    'nid' => array(
308
      'nid',
309
    ),
310
  ),
311
  'module' => 'upload',
312
  'name' => 'upload',
313
));
314
db_insert('upload')->fields(array(
315
  'fid',
316
  'nid',
317
  'vid',
318
  'description',
319
  'list',
320
  'weight',
321
))
322
->values(array(
323
  'fid' => '1',
324
  'nid' => '38',
325
  'vid' => '50',
326
  'description' => 'powered-blue-80x15.png',
327
  'list' => '1',
328
  'weight' => '0',
329
))
330
->values(array(
331
  'fid' => '2',
332
  'nid' => '39',
333
  'vid' => '51',
334
  'description' => 'powered-blue-80x15.png',
335
  'list' => '1',
336
  'weight' => '0',
337
))
338
->values(array(
339
  'fid' => '3',
340
  'nid' => '39',
341
  'vid' => '51',
342
  'description' => 'powered-blue-88x31.png',
343
  'list' => '1',
344
  'weight' => '0',
345
))
346
->values(array(
347
  'fid' => '4',
348
  'nid' => '39',
349
  'vid' => '51',
350
  'description' => 'powered-blue-135x42.png',
351
  'list' => '1',
352
  'weight' => '0',
353
))
354
->values(array(
355
  'fid' => '3',
356
  'nid' => '39',
357
  'vid' => '52',
358
  'description' => 'powered-blue-88x31.png',
359
  'list' => '1',
360
  'weight' => '0',
361
))
362
->values(array(
363
  'fid' => '5',
364
  'nid' => '39',
365
  'vid' => '52',
366
  'description' => 'powered-black-80x15.png',
367
  'list' => '1',
368
  'weight' => '0',
369
))
370
->values(array(
371
  'fid' => '6',
372
  'nid' => '39',
373
  'vid' => '52',
374
  'description' => 'powered-black-135x42.png',
375
  'list' => '1',
376
  'weight' => '0',
377
))
378
->values(array(
379
  'fid' => '7',
380
  'nid' => '40',
381
  'vid' => '53',
382
  'description' => 'forum-hot-new.png',
383
  'list' => '1',
384
  'weight' => '-4',
385
))
386
->values(array(
387
  'fid' => '8',
388
  'nid' => '40',
389
  'vid' => '53',
390
  'description' => 'forum-hot.png',
391
  'list' => '1',
392
  'weight' => '-3',
393
))
394
->values(array(
395
  'fid' => '10',
396
  'nid' => '40',
397
  'vid' => '53',
398
  'description' => 'forum-sticky.png',
399
  'list' => '1',
400
  'weight' => '-2',
401
))
402
->values(array(
403
  'fid' => '9',
404
  'nid' => '40',
405
  'vid' => '53',
406
  'description' => 'forum-new.png',
407
  'list' => '1',
408
  'weight' => '-1',
409
))
410
->values(array(
411
  'fid' => '11',
412
  'nid' => '40',
413
  'vid' => '53',
414
  'description' => 'crazy-basename.png',
415
  'list' => '1',
416
  'weight' => '0',
417
))
418
->execute();
419

    
420
// Add series of entries for invalid node vids to the {upload} table.
421
for ($i = 30; $i < 250; $i += 2) {
422
  db_insert('upload')->fields(array(
423
    'fid',
424
    'nid',
425
    'vid',
426
    'description',
427
    'list',
428
    'weight',
429
  ))
430
  // Invalid fid, invalid vid.
431
  ->values(array(
432
    'fid' => $i,
433
    'nid' => '40',
434
    'vid' => 24 + $i,
435
    'description' => 'crazy-basename.png',
436
    'list' => '1',
437
    'weight' => '0',
438
  ))
439
  // Valid fid, invalid vid.
440
  ->values(array(
441
    'fid' => 2,
442
    'nid' => '40',
443
    'vid' => 24 + $i + 1,
444
    'description' => 'crazy-basename.png',
445
    'list' => '1',
446
    'weight' => '0',
447
  ))
448
  ->execute();
449
}