Problem with fetch function attribute

Author Message

christian bencivenni

Monday 28 January 2008 11:32:54 pm

I found this code in event_view_calendar.tpl:

{def    $events=fetch( 'content', 'list', hash(
            'parent_node_id', $event_node_id,
            'sort_by', array( 'attribute', true(), 'event/from_time'),
            'class_filter_type',  'include',
            'class_filter_array', array( 'event' ),
            'main_node_only', true(),
             'attribute_filter',
            array( 'or',
                    array( 'event/from_time', 'between', array( sum($first_ts,1), sub($last_ts,1)  )),
                    array( 'event/to_time', 'between', array( sum($first_ts,1), sub($last_ts,1) )) )
                ))}

but it seems don't work with my installation of ez 3.10.0

I try with:

{def    $eventi=fetch( 'content', 'list', hash(
            'parent_node_id', $event_node_id,
            'sort_by', array( 'attribute', false(), 'from_time'),
            'class_filter_type',  'include',
            'class_filter_array', array( 'event' ) ))}	

but it still don't work.

So I try with:

{def    $eventi=fetch( 'content', 'list', hash(
            'parent_node_id', $event_node_id,
            'class_filter_type',  'include',
            'class_filter_array', array( 'event' ) ))}	

and it works!
Where is my error?
Thank you

christian bencivenni

Tuesday 29 January 2008 12:38:30 am

Well... I find also that in ez 3.9.2 installation the same template works perfectly but in 3.10.0 not yet.
I use ez 3.10.0 with postgreSQL.
it can be a bug with the db?

Stéphane Bullier

Tuesday 29 January 2008 1:29:25 am

Hello,

I think you make a mistake in your fetch list with parameter sort_by :
You forgot 'event' in line 3.

1    {def   $eventi=fetch( 'content', 'list', hash(
2           'parent_node_id', $event_node_id,
3           'sort_by', array( 'attribute', false(), 'from_time'),
4           'class_filter_type', 'include',
5           'class_filter_array', array( 'event' ) ))}  

You have to write 'event/from_time'.

Stéphane

christian bencivenni

Tuesday 29 January 2008 2:07:58 am

ok.
I cut and paste one of the numerous template I'm testing, but even with 'event/from_time' it doesn't work. I find the same problem with Blog pages. They will not work until I manually remove the sort_by line from template.

Łukasz Serwatka

Tuesday 29 January 2008 5:22:17 am

Sorting by attribute works fine as long as it is supported by attribute and syntax is correct. You can track SQL errors with enabled SQL debug in debug output. You should see where error is.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

christian bencivenni

Wednesday 30 January 2008 12:19:24 am

Thanks Lukasz.
I tried with this simple template:

{*?template charset=utf-8?*}
{* Event Calendar - Full Calendar view *}
{def
    $event_node    = $node
    $event_node_id = $event_node.node_id
    }
{def    $events=fetch( 'content', 'list', hash(
            'parent_node_id', $event_node_id,
            'sort_by', array( 'attribute', true(), 'event/from_time'),
            'class_filter_type',  'include',
            'class_filter_array', array( 'event' )  ))
}

But activating the SQL debug I can read an incredible number of query notice. I tried to decode the most of them and I found two interesting things. The first one is a PHP Warning:

Warning: PHP Jan 30 2008 08:21:42 
pg_exec() [<a href='function.pg-exec'>function.pg-exec</a>]: Query failed: ERROR:  for SELECT DISTINCT, ORDER BY expressions must appear in select list in /home/xtian/3.10.0/lib/ezdb/classes/ezpostgresqldb.php on line 164

And the second one in an SQL error. Unfortunately it seems to be a little bit complex for me but I think it is the center of the problem because I can read

a0.contentclassattribute_id = 297

which is the attribute I use to make the order_by.
This is the entire Error code:

Error: eZPostgreSQLDB Jan 30 2008 08:21:42 
Error: error executing query: 
SELECT DISTINCT
ezcontentobject.*, ezcontentobject_tree.*,  ezcontentclass.serialized_name_list as class_serialized_name_list, ezcontentclass.identifier as class_identifier, ezcontentclass.is_container as is_container, ezcontentobject_name.name as name,  ezcontentobject_name.real_translation 
                       
FROM
ezcontentobject_tree, ezcontentobject,ezcontentclass, ezcontentobject_name, ezcontentobject_attribute a0
                      
WHERE
ezcontentobject_tree.path_string like '/1/2/236/%'
and
ezcontentobject_tree.depth <= 3
and  
a0.contentobject_id = ezcontentobject.id
AND
a0.contentclassattribute_id = 297
AND
a0.version = ezcontentobject_name.content_version
AND
( a0.language_id & ezcontentobject.language_mask > 0
AND
( (   ezcontentobject.language_mask - ( ezcontentobject.language_mask & a0.language_id ) ) & 1 )
+ ( ( ( ezcontentobject.language_mask - ( ezcontentobject.language_mask & a0.language_id ) ) & 2 ) )
<
( a0.language_id & 1 )
+ ( ( a0.language_id & 2 ) ) ) 
AND 
ezcontentclass.version=0
AND
ezcontentobject_tree.node_id != 236
AND
ezcontentobject_tree.contentobject_id = ezcontentobject.id 
AND
ezcontentclass.id = ezcontentobject.contentclass_id
AND
ezcontentobject.contentclass_id  IN  ( 38 )
AND
ezcontentobject_tree.contentobject_id = ezcontentobject_name.contentobject_id
and
ezcontentobject_tree.contentobject_version = ezcontentobject_name.content_version
and 
( ezcontentobject_name.language_id & ezcontentobject.language_mask > 0
AND
 ( (   ezcontentobject.language_mask - ( ezcontentobject.language_mask & ezcontentobject_name.language_id ) ) & 1 )
+ ( ( ( ezcontentobject.language_mask - ( ezcontentobject.language_mask & ezcontentobject_name.language_id ) ) & 2 ) )
<
( ezcontentobject_name.language_id & 1 )
+ ( ( ezcontentobject_name.language_id & 2 ) ) ) 
AND ezcontentobject_tree.is_invisible = 0
AND ((ezcontentobject.section_id in (1))
OR (ezcontentobject.contentclass_id in (29, 30, 31, 32, 33, 40)
AND ezcontentobject.section_id in (3))
OR (( ( ezcontentobject_tree.node_id in (226) ) ))) 
AND 
ezcontentobject.language_mask & 3 > 0 

ORDER BY
a0.sort_key_int ASC ERROR:  for SELECT DISTINCT, ORDER BY expressions must appear in select list

Someone can tell me if it is a server problem or an ez bug and, if possible, a solution?
Thank you in advance.

André R.

Wednesday 30 January 2008 12:59:06 am

Have you recently upgraded pgSql ? What verison do you use?

http://archives.postgresql.org/pgsql-jdbc/2005-05/msg00062.php

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Łukasz Serwatka

Wednesday 30 January 2008 12:59:50 am

Could you report this problem in the issue tracker?

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

christian bencivenni

Wednesday 30 January 2008 1:09:32 am

I never do it.
What I must do?

Łukasz Serwatka

Wednesday 30 January 2008 1:38:11 am

Just proceed as mention on this page:
http://issues.ez.no/

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.