Forums / Setup & design / Problem with fetch function attribute

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

eZ debug

Timing: Jan 18 2025 18:18:23
Script start
Timing: Jan 18 2025 18:18:23
Module start 'content'
Timing: Jan 18 2025 18:18:23
Module end 'content'
Timing: Jan 18 2025 18:18:24
Script end

Main resources:

Total runtime0.9342 sec
Peak memory usage4,096.0000 KB
Database Queries219

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 588.9609180.8281
Module start 'content' 0.00560.7858 769.7891735.0625
Module end 'content' 0.79140.1425 1,504.8516348.4453
Script end 0.9339  1,853.2969 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.4169210.0002
Check MTime0.00150.1647210.0001
Mysql Total
Database connection0.00070.072510.0007
Mysqli_queries0.829888.82792190.0038
Looping result0.00210.22232170.0000
Template Total0.909197.320.4545
Template load0.00200.217420.0010
Template processing0.907097.091820.4535
Template load and register function0.00020.022510.0002
states
state_id_array0.00070.073510.0007
state_identifier_array0.00070.077020.0004
Override
Cache load0.00180.1973580.0000
Sytem overhead
Fetch class attribute can translate value0.00110.113850.0002
Fetch class attribute name0.00140.1491130.0001
XML
Image XML parsing0.00190.207750.0004
class_abstraction
Instantiating content class attribute0.00000.0031150.0000
General
dbfile0.01731.8549420.0004
String conversion0.00000.000630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
10content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
19content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
8content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
9content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 53
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs