Skip to content

Commit

Permalink
one new FK; check files for 0 size; release 0.21
Browse files Browse the repository at this point in the history
  • Loading branch information
gggeek committed May 2, 2020
1 parent 8dddc30 commit b334a12
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 14 deletions.
6 changes: 5 additions & 1 deletion classes/datatypecheckers/ezdbiezbinaryfilechecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ public function checkObjectAttribute( array $contentObjectAttribute )
else
{
// if it is, check its size as well
if ( $this->maxSize > 0 )
if ( $file->size() == 0 )
{
$warnings[] = "Binary file has 0 bytes size" . $this->postfixErrorMsg( $contentObjectAttribute );
}
else if ( $this->maxSize > 0 )
{
$maxSize = $this->maxSize * 1024 * 1024;
if ( $file->size() > $maxSize )
Expand Down
8 changes: 6 additions & 2 deletions classes/datatypecheckers/ezdbiezimagechecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,16 @@ public function checkObjectAttribute( array $contentObjectAttribute )
else
{
// if it is, check its size as well
if ( $this->maxSize > 0 )
if ( $file->size() == 0 )
{
$warnings[] = "Image file has 0 bytes size" . $this->postfixErrorMsg( $contentObjectAttribute );
}
else if ( $this->maxSize > 0 )
{
$maxSize = $this->maxSize * 1024 * 1024;
if ( $file->size() > $maxSize )
{
$warnings[] = "Image bigger than {$maxSize} bytes : " . $file->size(). $this->postfixErrorMsg( $contentObjectAttribute );
$warnings[] = "Image file bigger than {$maxSize} bytes : " . $file->size(). $this->postfixErrorMsg( $contentObjectAttribute );
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion classes/datatypecheckers/ezdbiezmediachecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,19 @@ public function checkObjectAttribute( array $contentObjectAttribute )
else
{
// if it is, check its size as well
if ( $this->maxSize > 0 )
if ( $file->size() == 0 )
{
$warnings[] = "Media file has 0 bytes size" . $this->postfixErrorMsg( $contentObjectAttribute );
}
else if ( $this->maxSize > 0 )
{
$maxSize = $this->maxSize * 1024 * 1024;
if ( $file->size() > $maxSize )
{
$warnings[] = "Media file larger than {$maxSize} bytes : " . $file->size(). $this->postfixErrorMsg( $contentObjectAttribute );
}
}

}
}
else
Expand Down
2 changes: 2 additions & 0 deletions doc/changelogs/changelog-0.20.0-to-0.21.0
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ changelog from version 0.20.0 to 0.21.0

. fixed one FK check for ezmedia
. removed the useless check of one FK on ezcontentobject_attribute, with always many false positives
. added one more FK from ezcontentobject to ezcontentobject_version
. when checking attributes of type ezbinaryfile, ezmedia, ezimagefile, check for files which exist but have 0 bytes on disk
7 changes: 4 additions & 3 deletions doc/todo
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
+ also write them

. check for clustering violations:
+ in mysql ezdb, master vs. slave table
+ in ezdfs, files in table but not in the filesystem (nb: already done in recent eZ versions?)
+ in mysql ezdb, master vs. slave table (???)
+ in ezdfs, files in table but not in the filesystem & vice-versa - nb: this is already done by dfscleanup.php,
but it only checks for file existence, not for discrepancies in size or mtime


# storage checking
Expand All @@ -39,7 +40,7 @@

# attribute checking

. add check for files which do exist on disk but have 0-byte size
. add extra checking for ezimage attributes' xml string vs. ezimagefile table rows (see dedicated todo)

. finish check of violations of constraints on all existing datatypes:
+ see the missing ones from ezdbintegrity.ini
Expand Down
2 changes: 1 addition & 1 deletion extension.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<software>
<metadata>
<name>eZ DB Integrity extension</name>
<version>0.20.0</version>
<version>0.21.0</version>
<copyright>Copyright (C) 2014-2020 Gaetano Giunta</copyright>
<license>GNU General Public License v2.0</license>
</metadata>
Expand Down
2 changes: 1 addition & 1 deletion ezinfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ static function info()
{
return array(
'Name' => "<a href=\"http://projects.ez.no/ezdbintegrity\">eZ DB Integrity extension</a>",
'Version' => "0.20.0",
'Version' => "0.21.0",
'Copyright' => "Copyright (C) 2014-2020 Gaetano Giunta",
'License' => "GNU General Public License v2.0"
);
Expand Down
12 changes: 7 additions & 5 deletions settings/ezdbintegrity.ini
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,14 @@ ezcontentclassgroup[]=modifier_id::ezuser::contentobject_id
ezcontentclass_name[]=contentclass_id::ezcontentclass::id
ezcontentclass_name[]=language_locale::ezcontent_language::locale
ezcontentobject[]=contentclass_id::ezcontentclass::id
ezcontentobject[]=initial_language_id::ezcontent_language::id
ezcontentobject[]=owner_id::ezuser::contentobject_id
ezcontentobject[]=section_id::ezsection::id
ezcontentobject[]=id::ezcontentobject_trash::contentobject_id::status = 2
ezcontentobject[]=id::ezcontentobject_tree::contentobject_id::status = 1
# @todo this looks more like a special query than a FK, really
ezcontentobject[]=id::ezcontentobject_version::contentobject_id::ezcontentobject.status = 1 AND ezcontentobject_version.status = 1
ezcontentobject[]=id,current_version::ezcontentobject_version::contentobject_id,version
ezcontentobject[]=initial_language_id::ezcontent_language::id
ezcontentobject[]=owner_id::ezuser::contentobject_id
ezcontentobject[]=section_id::ezsection::id
# @todo it seems we have lang & 1 as well... how to implement this in sql?
#ezcontentobject_attribute[]=language_id::ezcontent_language::id
# this FK seems to be massively violated all the time, and pretty harmless
Expand Down Expand Up @@ -286,8 +288,6 @@ objects_without_a_main_node[sql]=SELECT id FROM ezcontentobject WHERE status = 1
children_of_non_container_parents[sql]=SELECT pclass.identifier as parent_class, count(*) as children FROM ezcontentobject_tree child, ezcontentobject_tree parent, ezcontentobject pobj, ezcontentclass pclass WHERE (pclass.is_container != 1 or pclass.is_container is null) AND child.parent_node_id = parent.node_id AND parent.contentobject_id = pobj.id AND pobj.contentclass_id = pclass.id GROUP BY pclass.id ORDER BY pclass.identifier
related_nodes_with_different_objects[sql]=SELECT main_node_id, COUNT(DISTINCT contentobject_id) FROM ezcontentobject_tree GROUP BY main_node_id HAVING COUNT(DISTINCT contentobject_id) > 1
visible_but_hidden_nodes[sql]=SELECT node_id, is_hidden, is_invisible FROM ezcontentobject_tree WHERE is_hidden=1 AND is_invisible=0
#objects_without_versions[sql]=SELECT id FROM ezcontentobject WHERE NOT EXISTS ( SELECT contentobject_id, version from ezcontentobject_version WHERE ezcontentobject.id = ezcontentobject_version.contentobject_id )
#object_versions_without_attributes[sql]=SELECT contentobject_id, version FROM ezcontentobject_version WHERE NOT EXISTS ( SELECT contentobject_id, version from ezcontentobject_attribute WHERE ezcontentobject_version.contentobject_id = ezcontentobject_attribute.contentobject_id and ezcontentobject_version.version = ezcontentobject_attribute.version )
objects_versions_with_bad_attribute_count[sql]=select * from ( select count(*) as objattributes, contentobject_id, version, language_code, contentclass_id as contentclass_id_o from ezcontentobject_attribute coa, ezcontentobject co where coa.contentobject_id = co.id group by version, contentobject_id, contentclass_id, language_code ) q1, ( select count(*) as classattributes, contentclass_id from ezcontentclass_attribute cca, ezcontentclass cc where cca.contentclass_id = cc.id and cca.version = cc.version and cc.version = 0 group by cc.id, cc.version ) q2 where q1.contentclass_id_o = q2.contentclass_id and q1.objattributes <> q2.classattributes
# nb: the following query can create a huge temp table!
ezflow_blocks_with_invalid_zones[sql]=SELECT * FROM ezm_block WHERE zone_id NOT IN ( SELECT DISTINCT ( SUBSTRING( a.data_text, LOCATE( '<zone id="id_', a.data_text ) +13, 32 ) ) AS existing_zone_id FROM ezcontentobject_attribute a, ezcontentobject_version v WHERE a.version = v.version AND a.contentobject_id = v.contentobject_id AND a.data_type_string = 'ezpage' )
Expand All @@ -299,3 +299,5 @@ policy_limitations_for_missing_locations[sql]=SELECT p.role_id, p.id as policy_i
policy_limitations_for_missing_classes[sql]= SELECT p.role_id, p.id as policy_id, p.module_name, p.function_name, l.identifier, v.value FROM ezpolicy_limitation_value v JOIN ezpolicy_limitation l ON v.limitation_id = l.id JOIN ezpolicy p ON l.policy_id = p.id LEFT JOIN ezcontentclass c ON v.value = c.id WHERE l.identifier IN ('Class', 'ParentClass') AND c.id IS NULL ORDER BY p.role_id, p.module_name, p.function_name, p.id, v.value
policy_limitations_for_missing_sections[sql]= SELECT p.role_id, p.id as policy_id, p.module_name, p.function_name, l.identifier, v.value FROM ezpolicy_limitation_value v JOIN ezpolicy_limitation l ON v.limitation_id = l.id JOIN ezpolicy p ON l.policy_id = p.id LEFT JOIN ezsection s ON v.value = s.id WHERE l.identifier IN ('Section', 'NewSection') AND s.id IS NULL ORDER BY p.role_id, p.module_name, p.function_name, p.id, v.value
policy_limitations_for_missing_states[sql]= SELECT p.role_id, p.id as policy_id, p.module_name, p.function_name, l.identifier, v.value FROM ezpolicy_limitation_value v JOIN ezpolicy_limitation l ON v.limitation_id = l.id JOIN ezpolicy p ON l.policy_id = p.id LEFT JOIN ezcobj_state s ON v.value = s.id WHERE l.identifier IN ('State', 'NewState') AND s.id IS NULL ORDER BY p.role_id, p.module_name, p.function_name, p.id, v.value

# @todo: ezcontentobject_link where contentclassattribute_id = 0 and relation_type = 8 (and vice-versa)

0 comments on commit b334a12

Please sign in to comment.