cms/drupal/modules/simpletest/tests/upgrade/drupal-6.upload.database.php
changeset 541 e756a8c72c3d
equal deleted inserted replaced
540:07239de796bb 541:e756a8c72c3d
       
     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 // On some Drupal 6 sites, more than one file can have the same filepath. See
       
   131 // https://www.drupal.org/node/1260938.
       
   132 ->values(array(
       
   133   'fid' => '12',
       
   134   'uid' => '1',
       
   135   'filename' => 'duplicate-name.png',
       
   136   'filepath' => 'sites/default/files/duplicate-name.png',
       
   137   'filemime' => 'image/png',
       
   138   'filesize' => '314',
       
   139   'status' => '1',
       
   140   'timestamp' => '1285708958',
       
   141 ))
       
   142 ->values(array(
       
   143   'fid' => '13',
       
   144   'uid' => '1',
       
   145   'filename' => 'duplicate-name.png',
       
   146   'filepath' => 'sites/default/files/duplicate-name.png',
       
   147   'filemime' => 'image/png',
       
   148   'filesize' => '315',
       
   149   'status' => '1',
       
   150   'timestamp' => '1285708958',
       
   151 ))
       
   152 ->values(array(
       
   153   'fid' => '14',
       
   154   'uid' => '1',
       
   155   'filename' => 'duplicate-name.png',
       
   156   'filepath' => 'sites/default/files/duplicate-name.png',
       
   157   'filemime' => 'image/png',
       
   158   'filesize' => '316',
       
   159   'status' => '1',
       
   160   'timestamp' => '1285708958',
       
   161 ))
       
   162 ->execute();
       
   163 
       
   164 db_insert('node')->fields(array(
       
   165   'nid',
       
   166   'vid',
       
   167   'type',
       
   168   'language',
       
   169   'title',
       
   170   'uid',
       
   171   'status',
       
   172   'created',
       
   173   'changed',
       
   174   'comment',
       
   175   'promote',
       
   176   'moderate',
       
   177   'sticky',
       
   178   'tnid',
       
   179   'translate',
       
   180 ))
       
   181 ->values(array(
       
   182   'nid' => '38',
       
   183   'vid' => '50',
       
   184   'type' => 'page',
       
   185   'language' => '',
       
   186   'title' => 'node title 38 revision 50',
       
   187   'uid' => '1',
       
   188   'status' => '1',
       
   189   'created' => '1285603317',
       
   190   'changed' => '1285603317',
       
   191   'comment' => '0',
       
   192   'promote' => '0',
       
   193   'moderate' => '0',
       
   194   'sticky' => '0',
       
   195   'tnid' => '0',
       
   196   'translate' => '0',
       
   197 ))
       
   198 ->values(array(
       
   199   'nid' => '39',
       
   200   'vid' => '52',
       
   201   'type' => 'page',
       
   202   'language' => '',
       
   203   'title' => 'node title 39 revision 52',
       
   204   'uid' => '1',
       
   205   'status' => '1',
       
   206   'created' => '1285700317',
       
   207   'changed' => '1285700600',
       
   208   'comment' => '0',
       
   209   'promote' => '0',
       
   210   'moderate' => '0',
       
   211   'sticky' => '0',
       
   212   'tnid' => '0',
       
   213   'translate' => '0',
       
   214 ))
       
   215 ->values(array(
       
   216   'nid' => '40',
       
   217   'vid' => '53',
       
   218   'type' => 'page',
       
   219   'language' => '',
       
   220   'title' => 'node title 40 revision 53',
       
   221   'uid' => '1',
       
   222   'status' => '1',
       
   223   'created' => '1285709012',
       
   224   'changed' => '1285709012',
       
   225   'comment' => '0',
       
   226   'promote' => '0',
       
   227   'moderate' => '0',
       
   228   'sticky' => '0',
       
   229   'tnid' => '0',
       
   230   'translate' => '0',
       
   231 ))
       
   232 ->values(array(
       
   233   'nid' => '41',
       
   234   'vid' => '55',
       
   235   'type' => 'page',
       
   236   'language' => '',
       
   237   'title' => 'node title 41 revision 55',
       
   238   'uid' => '1',
       
   239   'status' => '1',
       
   240   'created' => '1285709012',
       
   241   'changed' => '1285709012',
       
   242   'comment' => '0',
       
   243   'promote' => '0',
       
   244   'moderate' => '0',
       
   245   'sticky' => '0',
       
   246   'tnid' => '0',
       
   247   'translate' => '0',
       
   248 ))
       
   249  ->execute();
       
   250 
       
   251 db_insert('node_revisions')->fields(array(
       
   252   'nid',
       
   253   'vid',
       
   254   'uid',
       
   255   'title',
       
   256   'body',
       
   257   'teaser',
       
   258   'log',
       
   259   'timestamp',
       
   260   'format',
       
   261 ))
       
   262 ->values(array(
       
   263   'nid' => '38',
       
   264   'vid' => '50',
       
   265   'uid' => '1',
       
   266   'title' => 'node title 38 revision 50',
       
   267   'body' => "Attachments:\r\npowered-blue-80x15.png",
       
   268   'teaser' => "Attachments:\r\npowered-blue-80x15.png",
       
   269   'log' => '',
       
   270   'timestamp' => '1285603317',
       
   271   'format' => '1',
       
   272 ))
       
   273 ->values(array(
       
   274   'nid' => '39',
       
   275   'vid' => '51',
       
   276   'uid' => '1',
       
   277   'title' => 'node title 39 revision 51',
       
   278   'body' => "Attachments:\r\npowered-blue-80x15.png\r\npowered-blue-88x31.png\r\npowered-blue-135x42.png",
       
   279   'teaser' => "Attachments:\r\npowered-blue-80x15.png\r\npowered-blue-88x31.png\r\npowered-blue-135x42.png",
       
   280   'log' => '',
       
   281   'timestamp' => '1285700487',
       
   282   'format' => '1',
       
   283 ))
       
   284 ->values(array(
       
   285   'nid' => '39',
       
   286   'vid' => '52',
       
   287   'uid' => '1',
       
   288   'title' => 'node title 39 revision 52',
       
   289   'body' => "Attachments:\r\npowered-blue-88x31.png\r\npowered-black-80x15.png\r\npowered-black-135x42.png",
       
   290   'teaser' => "Attachments:\r\npowered-blue-88x31.png\r\npowered-black-80x15.png\r\npowered-black-135x42.png",
       
   291   'log' => '',
       
   292   'timestamp' => '1285700600',
       
   293   'format' => '1',
       
   294 ))
       
   295 ->values(array(
       
   296   'nid' => '40',
       
   297   'vid' => '53',
       
   298   'uid' => '1',
       
   299   'title' => 'node title 40 revision 53',
       
   300   'body' => "Attachments:\r\nforum-hot-new.png\r\nforum-hot.png\r\nforum-sticky.png\r\nforum-new.png\r\ncrazy-basename.png",
       
   301   'teaser' => "Attachments:\r\nforum-hot-new.png\r\nforum-hot.png\r\nforum-sticky.png\r\nforum-new.png\r\ncrazy-basename.png",
       
   302   'log' => '',
       
   303   'timestamp' => '1285709012',
       
   304   'format' => '1',
       
   305 ))
       
   306 ->values(array(
       
   307   'nid' => '41',
       
   308   'vid' => '54',
       
   309   'uid' => '1',
       
   310   'title' => 'node title 41 revision 54',
       
   311   'body' => "Attachments:\r\nduplicate-name.png",
       
   312   'teaser' => "Attachments:\r\nduplicate-name.png",
       
   313   'log' => '',
       
   314   'timestamp' => '1285709012',
       
   315   'format' => '1',
       
   316 ))
       
   317 ->values(array(
       
   318   'nid' => '41',
       
   319   'vid' => '55',
       
   320   'uid' => '1',
       
   321   'title' => 'node title 41 revision 55',
       
   322   'body' => "Attachments:\r\nduplicate-name.png\r\nduplicate-name.png",
       
   323   'teaser' => "Attachments:\r\nduplicate-name.png\r\nduplicate-name.png",
       
   324   'log' => '',
       
   325   'timestamp' => '1285709012',
       
   326   'format' => '1',
       
   327 ))
       
   328  ->execute();
       
   329 
       
   330 db_create_table('upload', array(
       
   331   'fields' => array(
       
   332     'fid' => array(
       
   333       'type' => 'int',
       
   334       'unsigned' => TRUE,
       
   335       'not null' => TRUE,
       
   336       'default' => 0,
       
   337     ),
       
   338     'nid' => array(
       
   339       'type' => 'int',
       
   340       'unsigned' => TRUE,
       
   341       'not null' => TRUE,
       
   342       'default' => 0,
       
   343     ),
       
   344     'vid' => array(
       
   345       'type' => 'int',
       
   346       'unsigned' => TRUE,
       
   347       'not null' => TRUE,
       
   348       'default' => 0,
       
   349     ),
       
   350     'description' => array(
       
   351       'type' => 'varchar',
       
   352       'length' => 255,
       
   353       'not null' => TRUE,
       
   354       'default' => '',
       
   355     ),
       
   356     'list' => array(
       
   357       'type' => 'int',
       
   358       'unsigned' => TRUE,
       
   359       'not null' => TRUE,
       
   360       'default' => 0,
       
   361       'size' => 'tiny',
       
   362     ),
       
   363     'weight' => array(
       
   364       'type' => 'int',
       
   365       'not null' => TRUE,
       
   366       'default' => 0,
       
   367       'size' => 'tiny',
       
   368     ),
       
   369   ),
       
   370   'primary key' => array(
       
   371     'vid',
       
   372     'fid',
       
   373   ),
       
   374   'indexes' => array(
       
   375     'fid' => array(
       
   376       'fid',
       
   377     ),
       
   378     'nid' => array(
       
   379       'nid',
       
   380     ),
       
   381   ),
       
   382   'module' => 'upload',
       
   383   'name' => 'upload',
       
   384 ));
       
   385 db_insert('upload')->fields(array(
       
   386   'fid',
       
   387   'nid',
       
   388   'vid',
       
   389   'description',
       
   390   'list',
       
   391   'weight',
       
   392 ))
       
   393 ->values(array(
       
   394   'fid' => '1',
       
   395   'nid' => '38',
       
   396   'vid' => '50',
       
   397   'description' => 'powered-blue-80x15.png',
       
   398   'list' => '1',
       
   399   'weight' => '0',
       
   400 ))
       
   401 ->values(array(
       
   402   'fid' => '2',
       
   403   'nid' => '39',
       
   404   'vid' => '51',
       
   405   'description' => 'powered-blue-80x15.png',
       
   406   'list' => '1',
       
   407   'weight' => '0',
       
   408 ))
       
   409 ->values(array(
       
   410   'fid' => '3',
       
   411   'nid' => '39',
       
   412   'vid' => '51',
       
   413   'description' => 'powered-blue-88x31.png',
       
   414   'list' => '1',
       
   415   'weight' => '0',
       
   416 ))
       
   417 ->values(array(
       
   418   'fid' => '4',
       
   419   'nid' => '39',
       
   420   'vid' => '51',
       
   421   'description' => 'powered-blue-135x42.png',
       
   422   'list' => '1',
       
   423   'weight' => '0',
       
   424 ))
       
   425 ->values(array(
       
   426   'fid' => '3',
       
   427   'nid' => '39',
       
   428   'vid' => '52',
       
   429   'description' => 'powered-blue-88x31.png',
       
   430   'list' => '1',
       
   431   'weight' => '0',
       
   432 ))
       
   433 ->values(array(
       
   434   'fid' => '5',
       
   435   'nid' => '39',
       
   436   'vid' => '52',
       
   437   'description' => 'powered-black-80x15.png',
       
   438   'list' => '1',
       
   439   'weight' => '0',
       
   440 ))
       
   441 ->values(array(
       
   442   'fid' => '6',
       
   443   'nid' => '39',
       
   444   'vid' => '52',
       
   445   'description' => 'powered-black-135x42.png',
       
   446   'list' => '1',
       
   447   'weight' => '0',
       
   448 ))
       
   449 ->values(array(
       
   450   'fid' => '7',
       
   451   'nid' => '40',
       
   452   'vid' => '53',
       
   453   'description' => 'forum-hot-new.png',
       
   454   'list' => '1',
       
   455   'weight' => '-4',
       
   456 ))
       
   457 ->values(array(
       
   458   'fid' => '8',
       
   459   'nid' => '40',
       
   460   'vid' => '53',
       
   461   'description' => 'forum-hot.png',
       
   462   'list' => '1',
       
   463   'weight' => '-3',
       
   464 ))
       
   465 ->values(array(
       
   466   'fid' => '10',
       
   467   'nid' => '40',
       
   468   'vid' => '53',
       
   469   'description' => 'forum-sticky.png',
       
   470   'list' => '1',
       
   471   'weight' => '-2',
       
   472 ))
       
   473 ->values(array(
       
   474   'fid' => '9',
       
   475   'nid' => '40',
       
   476   'vid' => '53',
       
   477   'description' => 'forum-new.png',
       
   478   'list' => '1',
       
   479   'weight' => '-1',
       
   480 ))
       
   481 ->values(array(
       
   482   'fid' => '11',
       
   483   'nid' => '40',
       
   484   'vid' => '53',
       
   485   'description' => 'crazy-basename.png',
       
   486   'list' => '1',
       
   487   'weight' => '0',
       
   488 ))
       
   489 ->values(array(
       
   490   'fid' => '12',
       
   491   'nid' => '41',
       
   492   'vid' => '54',
       
   493   'description' => 'duplicate-name.png',
       
   494   'list' => '1',
       
   495   'weight' => '0',
       
   496 ))
       
   497 ->values(array(
       
   498   'fid' => '13',
       
   499   'nid' => '41',
       
   500   'vid' => '55',
       
   501   'description' => 'first description',
       
   502   'list' => '0',
       
   503   'weight' => '0',
       
   504 ))
       
   505 ->values(array(
       
   506   'fid' => '14',
       
   507   'nid' => '41',
       
   508   'vid' => '55',
       
   509   'description' => 'second description',
       
   510   'list' => '1',
       
   511   'weight' => '0',
       
   512 ))
       
   513 ->execute();
       
   514 
       
   515 // Add series of entries for invalid node vids to the {upload} table.
       
   516 for ($i = 30; $i < 250; $i += 2) {
       
   517   db_insert('upload')->fields(array(
       
   518     'fid',
       
   519     'nid',
       
   520     'vid',
       
   521     'description',
       
   522     'list',
       
   523     'weight',
       
   524   ))
       
   525   // Invalid fid, invalid vid.
       
   526   ->values(array(
       
   527     'fid' => $i,
       
   528     'nid' => '40',
       
   529     'vid' => 26 + $i,
       
   530     'description' => 'crazy-basename.png',
       
   531     'list' => '1',
       
   532     'weight' => '0',
       
   533   ))
       
   534   // Valid fid, invalid vid.
       
   535   ->values(array(
       
   536     'fid' => 2,
       
   537     'nid' => '40',
       
   538     'vid' => 26 + $i + 1,
       
   539     'description' => 'crazy-basename.png',
       
   540     'list' => '1',
       
   541     'weight' => '0',
       
   542   ))
       
   543   ->execute();
       
   544 }