* Lots of non-functional changes (to comply with old patch)
authorMichael Stucki <michael.stucki@typo3.org>
Tue, 26 Feb 2008 14:16:25 +0000 (14:16 +0000)
committerMichael Stucki <michael.stucki@typo3.org>
Tue, 26 Feb 2008 14:16:25 +0000 (14:16 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@3301 709f56b5-9817-0410-a4d7-c38de5d9e867

t3lib/class.t3lib_install.php

index 2a3ff1c..6f35351 100755 (executable)
@@ -297,51 +297,53 @@ class t3lib_install {
                $total = array();
 
                foreach($lines as $value)       {
-                       if ($value[0]!='#')     {
-                               if (!$table)    {
-                                       $parts = explode(' ',$value);
-                                       if ($parts[0]=='CREATE' && $parts[1]=='TABLE')  {
-                                               $table = str_replace( '`', '', $parts[2]);
-                                               if (TYPO3_OS=='WIN') {  // tablenames are always lowercase on windows!
-                                                       $table = strtolower($table);
-                                               }
+                       if (substr($value,0,1)=='#') {
+                               continue;       // Ignore comments
+                       }
+
+                       if (!strlen($table)) {
+                               $parts = explode(' ',$value);
+                               if ($parts[0]=='CREATE' && $parts[1]=='TABLE')  {
+                                       $table = str_replace( '`', '', $parts[2]);
+                                       if (TYPO3_OS=='WIN') {  // tablenames are always lowercase on windows!
+                                               $table = strtolower($table);
                                        }
+                               }
+                       } else {
+                               if (substr($value,0,1)==')' && substr($value,-1)==';')  {
+                                       $ttype = array();
+                                       preg_match('/(ENGINE|TYPE)=([a-zA-Z]*)/',$value,$ttype);
+                                       $total[$table]['extra']['ttype'] = $ttype[2];
+                                       $table = '';
                                } else {
-                                       if (substr($value,0,1)==')' && substr($value,-1)==';')  {
-                                               $ttype = array();
-                                               preg_match('/(ENGINE|TYPE)=([a-zA-Z]*)/',$value,$ttype);
-                                               $total[$table]['extra']['ttype'] = $ttype[2];
-                                               $table = '';
-                                       } else {
-                                               $lineV = preg_replace('/,$/','',$value);
-                                               $lineV = str_replace('UNIQUE KEY', 'UNIQUE', $lineV);
-                                               $parts = explode(' ',$lineV,2);
+                                       $lineV = preg_replace('/,$/','',$value);
+                                       $lineV = str_replace('UNIQUE KEY', 'UNIQUE', $lineV);
+                                       $parts = explode(' ',$lineV,2);
 
-                                                       // Make sure there is no default value when auto_increment is set
-                                               if(stristr($parts[1],'auto_increment')) {
-                                                       $parts[1] = preg_replace('/ default \'0\'/i','',$parts[1]);
-                                               }
-                                                       // "default" is always lower-case
-                                               if(strstr($parts[1], ' DEFAULT '))      {
-                                                       $parts[1] = str_replace(' DEFAULT ', ' default ', $parts[1]);
-                                               }
+                                               // Make sure there is no default value when auto_increment is set
+                                       if(stristr($parts[1],'auto_increment')) {
+                                               $parts[1] = preg_replace('/ default \'0\'/i','',$parts[1]);
+                                       }
+                                               // "default" is always lower-case
+                                       if(strstr($parts[1], ' DEFAULT '))      {
+                                               $parts[1] = str_replace(' DEFAULT ', ' default ', $parts[1]);
+                                       }
 
-                                                       // Change order of "default" and "null" statements
-                                               $parts[1] = preg_replace('/(.*) (default .*) (NOT NULL)/', '$1 $3 $2', $parts[1]);
-                                               $parts[1] = preg_replace('/(.*) (default .*) (NULL)/', '$1 $3 $2', $parts[1]);
-
-                                                       // Remove double blanks
-                                               $parts[1] = preg_replace('/([^ ]+)[ ]+([^ ]+)/', '$1 $2', $parts[1]);
-
-                                               if ($parts[0]!='PRIMARY' && $parts[0]!='KEY' && $parts[0]!='UNIQUE')    {
-                                                       $key = str_replace('`', '', $parts[0]);
-                                                       $total[$table]['fields'][$key] = $parts[1];
-                                               } else {        // Process keys
-                                                       $newParts = explode(' ',$parts[1],2);
-                                                       $key = str_replace('`', '', ($parts[0]=='PRIMARY'?$parts[0]:$newParts[0]));
-                                                       $lineV = str_replace('`', '', $lineV);
-                                                       $total[$table]['keys'][$key] = $lineV;
-                                               }
+                                               // Change order of "default" and "null" statements
+                                       $parts[1] = preg_replace('/(.*) (default .*) (NOT NULL)/', '$1 $3 $2', $parts[1]);
+                                       $parts[1] = preg_replace('/(.*) (default .*) (NULL)/', '$1 $3 $2', $parts[1]);
+
+                                               // Remove double blanks
+                                       $parts[1] = preg_replace('/([^ ]+)[ ]+([^ ]+)/', '$1 $2', $parts[1]);
+
+                                       if ($parts[0]!='PRIMARY' && $parts[0]!='KEY' && $parts[0]!='UNIQUE')    {
+                                               $key = str_replace('`', '', $parts[0]);
+                                               $total[$table]['fields'][$key] = $parts[1];
+                                       } else {        // Process keys
+                                               $newParts = explode(' ',$parts[1],2);
+                                               $key = str_replace('`', '', ($parts[0]=='PRIMARY'?$parts[0]:$newParts[0]));
+                                               $lineV = str_replace('`', '', $lineV);
+                                               $total[$table]['keys'][$key] = $lineV;
                                        }
                                }
                        }
@@ -630,7 +632,7 @@ class t3lib_install {
                if (!strstr($row['Type'],'blob') && !strstr($row['Type'],'text')) {
                                // Add a default value if the field is not auto-incremented (these fields never have a default definition)
                        if (!stristr($row['Extra'],'auto_increment')) {
-                               $field[] = 'default '."'".(addslashes($row['Default']))."'";
+                               $field[] = 'DEFAULT \''.addslashes($row['Default']).'\'';
                        }
                }
                if ($row['Extra']) {