This issue has been created
 
 
Blog Application / cid:jira-generated-image-avatar-65169f29-2bf5-41f4-83dd-235b420993f9 BLOG-299 Open

The blog post visibility migration compares the hidden flag of the page with a number

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-ca3be72c-095d-4be8-b890-1cbb5428e416 Thomas Mortagne created this issue on 17/Nov/26 15:11
 
Summary: The blog post visibility migration compares the hidden flag of the page with a number
Issue Type: cid:jira-generated-image-avatar-65169f29-2bf5-41f4-83dd-235b420993f9 Bug
Affects Versions: 9.15.15
Assignee: Unassigned
Created: 17/Nov/26 15:11
Priority: cid:jira-generated-image-static-major-81a4a696-0c72-4784-a765-5ef8539a50e2 Major
Reporter: Thomas Mortagne
Description:

The XWQL query of DefaultBlogVisibilityMigration compares the hidden flag of the page with numbers:

((obj.published = 0 or obj.hidden = 1) and doc.hidden <> 1)
(obj.published = 1 and obj.hidden = 0 and doc.hidden <> 0)

Since Hibernate 6, HQL checks the types of both sides of a comparison when the query is parsed, and rejects incompatible ones (SemanticException: Cannot compare left expression of type ... with right expression of type ...). XWiki is moving to Hibernate 7 (XWIKI-19708), where these queries will fail on every database. With Hibernate 5 the literal is copied as is in the SQL, so the queries rely on the database converting it implicitly, which not all databases do.

This probably already fails on PostgreSQL, where the hidden flag is stored in a boolean column which can't be compared with an integer.

Compare it with a boolean instead (doc.hidden <> true, doc.hidden <> false). obj.published and obj.hidden are fine since boolean XClass properties are stored as integers. This works with all the databases and all the Hibernate versions.