1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 14:17:49 +02:00

Removed false-positive when an SQL file uses type JSON

Moved comparison processing into separate method. prepareResults()
This commit is contained in:
Cameron
2019-02-24 11:35:32 -08:00
parent af7714be93
commit d994785e63

View File

@@ -125,19 +125,17 @@ class db_verify
} }
private function loadCreateTableData()
{
}
/** /**
* Permissive field validation * Permissive field validation
*/ */
private function diffStructurePermissive($expected, $actual) private function diffStructurePermissive($expected, $actual)
{ {
if($expected['type'] === 'JSON') // Fix for JSON alias MySQL 5.7+
{
$expected['type'] = 'LONGTEXT';
}
// Permit actual text types that default to null even when // Permit actual text types that default to null even when
// expected does not explicitly default to null // expected does not explicitly default to null
if(0 === strcasecmp($expected['type'], $actual['type']) && if(0 === strcasecmp($expected['type'], $actual['type']) &&
@@ -265,7 +263,7 @@ class db_verify
function compare($selection,$language='') public function compare($selection,$language='')
{ {
$this->currentTable = $selection; $this->currentTable = $selection;
@@ -354,20 +352,57 @@ class db_verify
$tbl = "lan_".$language."_".$tbl; $tbl = "lan_".$language."_".$tbl;
} }
$this->prepareResults($tbl, $selection, $sqlData, $fileData);
unset($data);
}
}
/**
* @param string $type fields|indices
* @return array
*/
public function getResults($type='fields')
{
if($type === 'indices')
{
return $this->indices;
}
return $this->results;
}
/**
* @param string $tbl table name without prefix.
* @param string $selection 'core' OR plugin-folder name.
* @param array $sqlData ie. array('field'=>getFields($data), 'index'=>getFields($data));
* @param array $fileData ie. array('field'=>getFields($data), 'index'=>getFields($data));
* @todo Check for additional fields in SQL that should be removed.
* @todo Add support for MYSQL 5 table layout .eg. journal_id INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
*/
public function prepareResults($tbl, $selection, $sqlData, $fileData)
{
// Check field and index data // Check field and index data
foreach(['field', 'index'] as $type) foreach(['field', 'index'] as $type)
{ {
$results = 'results'; $results = 'results';
if ($type === 'index') $results = 'indices';
if ($type === 'index')
{
$results = 'indices';
}
foreach($fileData[$type] as $key => $value) foreach($fileData[$type] as $key => $value)
{ {
$this->{$results}[$tbl][$key]['_status'] = 'ok'; $this->{$results}[$tbl][$key]['_status'] = 'ok';
//print("EXPECTED");
//print_a($value);
//print("ACTUAL");
//print_a($sqlData[$type][$key]);
if(!is_array($sqlData[$type][$key])) if(!is_array($sqlData[$type][$key]))
{ {
$this->errors[$tbl]['_status'] = 'error'; // table status $this->errors[$tbl]['_status'] = 'error'; // table status
@@ -385,17 +420,19 @@ class db_verify
$this->{$results}[$tbl][$key]['_file'] = $selection; $this->{$results}[$tbl][$key]['_file'] = $selection;
} }
// TODO Check for additional fields in SQL that should be removed.
// TODO Add support for MYSQL 5 table layout .eg. journal_id INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
}
} }
unset($data); }
return null;
} }
}
/** /**
* Compile Results into a complete list of Fixes that could be run without the need of a form selection. * Compile Results into a complete list of Fixes that could be run without the need of a form selection.