Skip to content

Commit

Permalink
fix one warning in specific mysql configs; welcome 2022
Browse files Browse the repository at this point in the history
  • Loading branch information
gggeek committed Feb 17, 2022
1 parent c4f4a83 commit 159abf0
Show file tree
Hide file tree
Showing 24 changed files with 121 additions and 25 deletions.
2 changes: 1 addition & 1 deletion bin/php/checkattributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand Down
2 changes: 1 addition & 1 deletion bin/php/checkschema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand Down
2 changes: 1 addition & 1 deletion bin/php/checkstorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand Down
2 changes: 1 addition & 1 deletion bin/php/generatedefsfrompersistentobjects.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/datatypecheckers/ezdbiezbinaryfilechecker.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @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
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/datatypecheckers/ezdbiezfloatchecker.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @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
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/datatypecheckers/ezdbiezimagechecker.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @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
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/datatypecheckers/ezdbiezintegerchecker.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @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
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/datatypecheckers/ezdbiezmediachecker.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @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
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/datatypecheckers/ezdbiezstringchecker.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @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
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/datatypecheckers/ezdbiezuserchecker.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @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
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/datatypecheckers/ezdbinullabletypechecker.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @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
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/ezdbibasechecker.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @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
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/ezdbidatatypechecker.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @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
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/ezdbireportgenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Formats results in various modes
*
* @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
*/

Expand Down
4 changes: 2 additions & 2 deletions classes/ezdbischemachecker.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @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
*/

Expand Down Expand Up @@ -229,7 +229,7 @@ public function checkFKDefinition( $childTable, $childCol, $parentTable, $parent
if ($t1['type'] != $t2['type']) {
$diffs[] = "Column type mismatch: {$t1['type']} vs. {$t2['type']}";
} else {
if ($t1['length'] != $t2['length']) {
if (isset($t1['length']) && isset($t2['length']) && $t1['length'] != $t2['length']) {
$diffs[] = "Column length mismatch: {$t1['length']} vs. {$t2['length']}";
}
}
Expand Down
2 changes: 1 addition & 1 deletion classes/ezdbischemachecks.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @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
*/

Expand Down
2 changes: 1 addition & 1 deletion classes/ezdbistoragecker.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @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
*/

Expand Down
3 changes: 3 additions & 0 deletions doc/changelogs/changelog-0.26.0-to-0.26.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
changelog from version 0.26.0 to 0.26.1

. fixed: a warning when the db is set up in a way such tahtw e fail to get column definition length
93 changes: 93 additions & 0 deletions doc/todo_ezimagefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
NB: SOME/ALL OF THE STUFF BELOW FAILS BECAUSE PK FOR ezcoa IS ID,VERSION!

a) check rows in ezcoa which do have a value for original file but miss a row in ezimagefile - matching based on attribute id
- found 0 when testing kc prod data
- remember that ezcoa<->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 '<original attribute_id="172" attribute_version="179"'
- the others hve NULL for ezdata_text value
- _but_, the rows in ezimagefile are probably referring to _other versions_ of the same attribute!
end result is: useless query...

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 null or ExtractValue(data_text, '/ezimage/@filename') = '')
and i.contentobject_attribute_id is not null
;

c) check any ezimagefile which is not in the xml text in ezcoa.data_text (to retest...)

- take care! in some cases '/ezimage/@filename' does contain colons and/or spaces,
eg: 'var/ovum_site/storage/images/24870301-1-eng-GB/C:\Users\lambertp\AppData\Local\Temp\F2 UK operators price comparison.jpg'
the fact is: there are few invalid chars in linux filenames... we moved to using | as path separator
- take care 2: ExtractValue does not decode xml entities: we should replace &amp; to & => OK; to do: also replace &quot;
- 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'), '&amp;', '&'),
'|', ExtractValue(data_text, '/ezimage/@dirpath'), '/', replace(ExtractValue(data_text, '/ezimage/@basename'), '&amp;', '&'), '_',
replace(
-- list of aliases, space separated
replace(ExtractValue(data_text, '/ezimage/alias/@name'), '&amp;', '&'),
' ',
concat('.', ExtractValue(data_text, '/ezimage/@suffix'), '|', ExtractValue(data_text, '/ezimage/@dirpath'), '/', replace(ExtractValue(data_text, '/ezimage/@basename'), '&amp;', '&') , '_')
),
'.', 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'), '&amp;', '&'),
'|', ExtractValue(data_text, '/ezimage/@dirpath'), '/', replace(ExtractValue(data_text, '/ezimage/@basename'), '&amp;', '&'), '_',
replace(
-- list of aliases, space separated
replace(ExtractValue(data_text, '/ezimage/alias/@name'), '&amp;', '&'),
' ',
concat('.', ExtractValue(data_text, '/ezimage/@suffix'), '|', ExtractValue(data_text, '/ezimage/@dirpath'), '/', replace(ExtractValue(data_text, '/ezimage/@basename'), '&amp;', '&') , '_')
),
'.', 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
;
4 changes: 2 additions & 2 deletions extension.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<software>
<metadata>
<name>eZ DB Integrity extension</name>
<version>0.26.0</version>
<copyright>Copyright (C) 2014-2021 Gaetano Giunta</copyright>
<version>0.26.1</version>
<copyright>Copyright (C) 2014-2022 Gaetano Giunta</copyright>
<license>GNU General Public License v2.0</license>
</metadata>

Expand Down
4 changes: 2 additions & 2 deletions ezinfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ static function info()
{
return array(
'Name' => "<a href=\"https://github.com/gggeek/ezdbintegrity\">eZ DB Integrity extension</a>",
'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"
);
}
Expand Down
2 changes: 1 addition & 1 deletion interfaces/ezdbidatatypecheckerinterface.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @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
*/

Expand Down
2 changes: 1 addition & 1 deletion interfaces/ezdbischemafileformatinterface.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @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
*/

Expand Down

0 comments on commit 159abf0

Please sign in to comment.