Change in advancedsearch.php

Author Message

Juan Pablo Vercesi

Thursday 09 February 2006 8:49:49 am

Hi there,

I'm working on the search engine of a site, and have found this difference between two versions of eZ that I can't figure out why.

Originally, this site was in eZ 3.3.4, whose <i>/kernel/content/advancedsearch.php</i> file has the following lines (near line 120):

$searchContentClassID = -1;
$searchContentClassAttributes = 0;
$searchContentClassAttributeArray = array();
if ( $http->hasVariable( 'SearchContentClassID' ) and
     $http->variable( 'SearchContentClassID' ) != -1 )
{
    $searchContentClassID = $http->variable( 'SearchContentClassID' );
    $searchContentClass =& eZContentClass::fetch( $searchContentClassID );
    $searchContentClassAttributeArray =& $searchContentClass->fetchSearchableAttributes();
}

On the other hand, ez 3.6.5 has these on the same place:

$searchContentClassID = -1;
$searchContentClassAttributes = 0;
$searchContentClassAttributeArray = array();
if ( $http->hasVariable( 'SearchContentClassID' ) and
     $http->variable( 'SearchContentClassID' ) != -1 and
     (int)$http->variable( 'SearchContentClassID' ) > 0 )
{
    $searchContentClassID = (int)$http->variable( 'SearchContentClassID' );
    $searchContentClass =& eZContentClass::fetch( $searchContentClassID );
    if ( is_object( $searchContentClass ) )
        $searchContentClassAttributeArray =& $searchContentClass->fetchSearchableAttributes();
}

As you can see, the line inside the <i>if</i> block that assigns a value to <i>$searchContentClassID</i> has a type cast. This causes that if <i>$http->variable( 'SearchContentClassID' )</i> were returning an array (which, in fact, is my case), it is converted to an int, and the returning value is always 1 (my guess is that that conversion returns a "true" value, which is that the array exists).

I know that I can solve my 'problem' just removing the type casting, but I post this because I'd like to know why the type cast was added, how it changes the search behaviour and anything that could be related to it.

Thanks

JP,
may the source be with you.

Marko Žmak

Friday 19 May 2006 5:40:00 am

I also noticed this and reported it as a bug:

http://ez.no/bugs/view/8312

and also suggested a fix.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Nabil Alimi

Saturday 20 May 2006 5:52:55 am

Okkk my thread 1 line up there doesn't make sense anymore. :)

My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr

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