Merged changes form stabel branch up to the current state (2.3.22+).
[fa-stable.git] / admin / db / maintenance_db.inc
index 16434ecd163d46a2933014b4f6dd00797df62732..71081c5763e9b1f1ae0e992e90e85558d94c484d 100644 (file)
@@ -303,10 +303,12 @@ function db_import($filename, $connection, $force=true, $init=true, $protect=fal
 
        ini_set("max_execution_time", "180");
        db_query("SET foreign_key_checks=0");
+       $check_line_len = false;
        // uncrompress gziped backup files
        if (strpos($filename, ".gz") || strpos($filename, ".GZ"))
-               $lines = db_ungzip("lines", $filename);
-       elseif (strpos($filename, ".zip") || strpos($filename, ".ZIP"))
+       {       $lines = db_ungzip("lines", $filename);
+               $check_line_len = true;
+       } elseif (strpos($filename, ".zip") || strpos($filename, ".ZIP"))
                $lines = db_unzip("lines", $filename);
        else
                $lines = file("". $filename);
@@ -317,8 +319,9 @@ function db_import($filename, $connection, $force=true, $init=true, $protect=fal
 
        foreach($lines as $line_no => $line)
        {
+               $gzfile_bug = $check_line_len && (strlen($line) == 8190); // there is a bug in php (at least 4.1.1-5.5.9) gzfile which limits line length to 8190 bytes!
+
                $line = trim($line);
-               
                if ($init)
                        $line = str_replace("0_", $connection["tbpref"], $line);
 
@@ -351,8 +354,7 @@ function db_import($filename, $connection, $force=true, $init=true, $protect=fal
                 if($query_table != '')  // inside allowed query
                 {
                        $table = $query_table;
-
-                       if (substr($line, -strlen($delimiter)) == $delimiter) // end of query found
+                       if (!$gzfile_bug && substr($line, -strlen($delimiter)) == $delimiter) // end of query found 
                        {
                                $line = substr($line, 0, strlen($line) - strlen($delimiter)); // strip delimiter
                                $query_table = '';