From 159abf01541986a2f80472b797ee6c895d40801f Mon Sep 17 00:00:00 2001 From: gggeek Date: Thu, 17 Feb 2022 12:22:41 +0000 Subject: [PATCH] fix one warning in specific mysql configs; welcome 2022 --- bin/php/checkattributes.php | 2 +- bin/php/checkschema.php | 2 +- bin/php/checkstorage.php | 2 +- bin/php/generatedefsfrompersistentobjects.php | 2 +- .../ezdbiezbinaryfilechecker.php | 2 +- .../datatypecheckers/ezdbiezfloatchecker.php | 2 +- .../datatypecheckers/ezdbiezimagechecker.php | 2 +- .../ezdbiezintegerchecker.php | 2 +- .../datatypecheckers/ezdbiezmediachecker.php | 2 +- .../datatypecheckers/ezdbiezstringchecker.php | 2 +- .../datatypecheckers/ezdbiezuserchecker.php | 2 +- .../ezdbinullabletypechecker.php | 2 +- classes/ezdbibasechecker.php | 2 +- classes/ezdbidatatypechecker.php | 2 +- classes/ezdbireportgenerator.php | 2 +- classes/ezdbischemachecker.php | 4 +- classes/ezdbischemachecks.php | 2 +- classes/ezdbistoragecker.php | 2 +- doc/changelogs/changelog-0.26.0-to-0.26.1 | 3 + doc/todo_ezimagefile | 93 +++++++++++++++++++ extension.xml | 4 +- ezinfo.php | 4 +- interfaces/ezdbidatatypecheckerinterface.php | 2 +- interfaces/ezdbischemafileformatinterface.php | 2 +- 24 files changed, 121 insertions(+), 25 deletions(-) create mode 100644 doc/changelogs/changelog-0.26.0-to-0.26.1 create mode 100644 doc/todo_ezimagefile diff --git a/bin/php/checkattributes.php b/bin/php/checkattributes.php index 7964cb3..daace52 100644 --- a/bin/php/checkattributes.php +++ b/bin/php/checkattributes.php @@ -3,7 +3,7 @@ * A CLI script which checks problems with all object attributes of a given datatype in current database * * @author G. Giunta - * @copyright (C) G. Giunta 2014-2021 + * @copyright (C) G. Giunta 2014-2022 * @license Licensed under GNU General Public License v2.0. See file license.txt */ diff --git a/bin/php/checkschema.php b/bin/php/checkschema.php index 7bb1b1a..21ddcaf 100644 --- a/bin/php/checkschema.php +++ b/bin/php/checkschema.php @@ -3,7 +3,7 @@ * A CLI script which checks problems with data in the current schema * * @author G. Giunta - * @copyright (C) G. Giunta 2014-2021 + * @copyright (C) G. Giunta 2014-2022 * @license Licensed under GNU General Public License v2.0. See file license.txt */ diff --git a/bin/php/checkstorage.php b/bin/php/checkstorage.php index 65d1535..52e337d 100644 --- a/bin/php/checkstorage.php +++ b/bin/php/checkstorage.php @@ -3,7 +3,7 @@ * A CLI script which checks for orphan storage files * * @author G. Giunta - * @copyright (C) G. Giunta 2016-2021 + * @copyright (C) G. Giunta 2016-2022 * @license Licensed under GNU General Public License v2.0. See file license.txt */ diff --git a/bin/php/generatedefsfrompersistentobjects.php b/bin/php/generatedefsfrompersistentobjects.php index 08a1b0d..1f4cf5e 100644 --- a/bin/php/generatedefsfrompersistentobjects.php +++ b/bin/php/generatedefsfrompersistentobjects.php @@ -3,7 +3,7 @@ * A CLI script which checks all persistent object defs for FKs and generates a file with definitions * * @author G. Giunta - * @copyright (C) G. Giunta 2014-2021 + * @copyright (C) G. Giunta 2014-2022 * @license Licensed under GNU General Public License v2.0. See file license.txt */ diff --git a/classes/datatypecheckers/ezdbiezbinaryfilechecker.php b/classes/datatypecheckers/ezdbiezbinaryfilechecker.php index 7e7b778..cb12a04 100644 --- a/classes/datatypecheckers/ezdbiezbinaryfilechecker.php +++ b/classes/datatypecheckers/ezdbiezbinaryfilechecker.php @@ -1,7 +1,7 @@ ezimagefile is a many-to-one relationship, as ezimagefile misses version + - somewhat useful, but not sufficient: what if the matched ezimagefile row does not match any of the file paths in the ezcoa row? + +select count(*) +from ezcontentobject_attribute a +left join (select distinct(contentobject_attribute_id) as contentobject_attribute_id from ezimagefile) i on i.contentobject_attribute_id = a.id +where data_type_string = 'ezimage' +and (ExtractValue(data_text, '/ezimage/@filename') is not null and ExtractValue(data_text, '/ezimage/@filename') != '') +and i.contentobject_attribute_id is null +; + +b) check rows in ezcoa which miss a value for original file but do have rows in ezimagefile + - some of these do have instead ' OK; to do: also replace " +- take care 3: we might be having problems when the match expression contains '\' chars... => OK: escaped them to \\ +- take care 4: we can not replace all spaces in filenames with the path !!! it will fail for files having spaces... => OK, we now explode using alias names, which should not contain spaces +- take care 5: we should escape chars % and _ found in filepath when we use it for LIKE matching + +start with: + +select i.contentobject_attribute_id, group_concat(i.filepath) +from ezimagefile i +left join ( + select + id, + concat( + '|', ExtractValue(data_text, '/ezimage/@dirpath'), '/', replace(ExtractValue(data_text, '/ezimage/@filename'), '&', '&'), + '|', ExtractValue(data_text, '/ezimage/@dirpath'), '/', replace(ExtractValue(data_text, '/ezimage/@basename'), '&', '&'), '_', + replace( + -- list of aliases, space separated + replace(ExtractValue(data_text, '/ezimage/alias/@name'), '&', '&'), + ' ', + concat('.', ExtractValue(data_text, '/ezimage/@suffix'), '|', ExtractValue(data_text, '/ezimage/@dirpath'), '/', replace(ExtractValue(data_text, '/ezimage/@basename'), '&', '&') , '_') + ), + '.', ExtractValue(data_text, '/ezimage/@suffix'), '|' + ) as all_filepaths + from ezcontentobject_attribute + where data_type_string = 'ezimage' + and ExtractValue(data_text, '/ezimage/@filename') != '' and ExtractValue(data_text, '/ezimage/@filename') is not null + -- and id = 27610921 +) a on i.contentobject_attribute_id = a.id and a.all_filepaths like concat('%|',replace(i.filepath, '\\', '\\\\'),'|%') +where a.id is null +group by i.contentobject_attribute_id + +d) check any ezcoa row of type ezimage which does have a value for original file but for which none of the files in the data_text field matches a row in ezimagefile + +- tested ok on kc prod data (0 results) +- but some fixes still to be applied - see query above... +- todo: add a test which would split the paths found in ecoa and check each of those separately + +select * +from ( + select + id, + concat( + '|', ExtractValue(data_text, '/ezimage/@dirpath'), '/', replace(ExtractValue(data_text, '/ezimage/@filename'), '&', '&'), + '|', ExtractValue(data_text, '/ezimage/@dirpath'), '/', replace(ExtractValue(data_text, '/ezimage/@basename'), '&', '&'), '_', + replace( + -- list of aliases, space separated + replace(ExtractValue(data_text, '/ezimage/alias/@name'), '&', '&'), + ' ', + concat('.', ExtractValue(data_text, '/ezimage/@suffix'), '|', ExtractValue(data_text, '/ezimage/@dirpath'), '/', replace(ExtractValue(data_text, '/ezimage/@basename'), '&', '&') , '_') + ), + '.', ExtractValue(data_text, '/ezimage/@suffix'), '|' + ) as all_filepaths + from ezcontentobject_attribute + where data_type_string = 'ezimage' + and ExtractValue(data_text, '/ezimage/@filename') != '' and ExtractValue(data_text, '/ezimage/@filename') is not null +) a +left join ezimagefile i on i.contentobject_attribute_id = a.id and a.all_filepaths like concat('%|',replace(i.filepath, '\\', '\\\\'),'|%') +where i.id is null +; diff --git a/extension.xml b/extension.xml index 2e9927c..4b600d6 100644 --- a/extension.xml +++ b/extension.xml @@ -2,8 +2,8 @@ eZ DB Integrity extension - 0.26.0 - Copyright (C) 2014-2021 Gaetano Giunta + 0.26.1 + Copyright (C) 2014-2022 Gaetano Giunta GNU General Public License v2.0 diff --git a/ezinfo.php b/ezinfo.php index e20b8f3..c8d8425 100644 --- a/ezinfo.php +++ b/ezinfo.php @@ -6,8 +6,8 @@ static function info() { return array( 'Name' => "eZ DB Integrity extension", - 'Version' => "0.26.0", - 'Copyright' => "Copyright (C) 2014-2021 Gaetano Giunta", + 'Version' => "0.21.0", + 'Copyright' => "Copyright (C) 2014-2022 Gaetano Giunta", 'License' => "GNU General Public License v2.0" ); } diff --git a/interfaces/ezdbidatatypecheckerinterface.php b/interfaces/ezdbidatatypecheckerinterface.php index ce87a40..7886c63 100644 --- a/interfaces/ezdbidatatypecheckerinterface.php +++ b/interfaces/ezdbidatatypecheckerinterface.php @@ -1,7 +1,7 @@