Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-19897

fetchKeyword gives SQL query error when using attribute filtering

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: High High
    • Resolution: Unresolved
    • Affects Version/s: 5.0.0beta2
    • Fix Version/s: None
    • Component/s: Database related
    • Environment:

      Debian squeeze php-5.3.17 mysql-5.5

      Description

      using this fetch (taken from a template ezdemo):

      fetch( 'content', 'keyword', hash( 'alphabet', rawurldecode( $view_parameters.tag ),
      'classid', 'blog_post',
      'parent_node_id', $node.node_id,
      'offset', $view_parameters.offset,
      'sort_by', array( 'attribute', false(), 'blog_post/publication_date' ),
      'limit', $page_limit ) )

      produce this query
      SELECT DISTINCT ezcontentobject_tree.node_id, ezkeyword.keyword, a0.sort_key_int
      FROM ezkeyword
      INNER JOIN ezkeyword_attribute_link ON (ezkeyword_attribute_link.keyword_id = ezkeyword.id)
      INNER JOIN ezcontentobject_attribute ON (ezcontentobject_attribute.id = ezkeyword_attribute_link.objectattribute_id)
      INNER JOIN ezcontentobject ON (ezcontentobject_attribute.version = ezcontentobject.current_version AND ezcontentobject_attribute.contentobject_id = ezcontentobject.id)
      INNER JOIN ezcontentobject_tree ON (ezcontentobject_tree.contentobject_id = ezcontentobject.id)
      INNER JOIN ezcontentclass ON (ezcontentclass.id = ezcontentobject.contentclass_id)
      INNER JOIN ezcontentobject_attribute a0 ON (
      a0.contentobject_id = ezcontentobject.id AND
      a0.contentclassattribute_id = 198 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 ) )
      )
      )
      INNER JOIN ezcontentobject_name ON (ezcontentobject_name.contentobject_id = ezcontentobject.id)

      WHERE
      ezkeyword.keyword LIKE '%mykeyword'
      AND ezcontentobject_tree.is_invisible = 0
      AND ((ezcontentobject.section_id in (1)) OR (ezcontentobject.contentclass_id in (25, 33) AND ezcontentobject.section_id in (3)))

      AND ezcontentobject_tree.parent_node_id = '70'
      AND ezcontentclass.version = 0
      AND ezcontentobject.status = 1
      AND ezcontentobject_tree.main_node_id = ezcontentobject_tree.node_id
      ORDER BY a0.sort_key_int DESC
      LIMIT 0, 10

      which give the following error when executed on my system (mysql-5.5):
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Query error (1054): Unknown column 'ezcontentobject_name.content_version' in 'on' at line 1

      I think there is a problem in kernel/content/ezcontentfunctioncollection.php ligne 950 when the query is built. the INNER JOIN clause which joins the table ezcontentobject_name should be declared before the other INNER JOIN clauses related to the attributes filter.

      with the attached patch I've got the correct behavior.

        Activity

        Hide
        Albulescu Alexandru added a comment -

        The patch solve the problems for eZFlow , for this error.

        Show
        Albulescu Alexandru added a comment - The patch solve the problems for eZFlow , for this error.

          People

          • Assignee:
            Unassigned
            Reporter:
            Boukhalfa François
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: