[SPT/CWIS] include/SPT--GlobalSearchEngine.php , array_merge() and PHP 5.1.6
Jhonatan Tirado
jhonatantiradotiradodeep at gmail.com
Wed May 2 10:24:22 CDT 2007
Yes, that's the only fact I've found wiht PHP5 and CWIS.
I've done testing, maybe not a lot, but enough I think.
Anyway, I'm still testing, looking for errors. But, it seems no problems
until now.
Another fact about PHP5 , not related with CWIS but with Drupal, is an
incompatibility wiht some templates, specifically xtemplate engine. I solved
it by using a different template engine, based on PHP.
If i find something else, I'll let you know.
Bye
2007/5/1, Kucera, Rich <Kucerar at hhmi.org>:
>
> Thanks for the tip J (not sure if I like the new PHP though).
>
>
>
> That's the only issue you've found with PHP5? Have you done a lot of
> testing?
>
> Thanks,
>
> -Rich
>
>
> ------------------------------
>
> *From:* spt-cwis-users-bounces at scout.wisc.edu [mailto:
> spt-cwis-users-bounces at scout.wisc.edu] *On Behalf Of *Jhonatan Tirado
> *Sent:* Monday, April 30, 2007 7:26 PM
> *To:* spt-cwis-users at scout.wisc.edu
> *Subject:* [SPT/CWIS] include/SPT--GlobalSearchEngine.php ,array_merge()
> and PHP 5.1.6
>
>
>
> Hi.
> Recently, I had the following problem:
>
> *Warning*: array_merge() [ function.array-merge<http://peru.campusvirtualsp.org/repositorio/function.array-merge>]:
> Argument #1 is not an array in */var/www/repositorio/include/SPT--
> GlobalSearchEngine.php *on line *91*
>
> *Warning*: array_merge() [function.array-merge<http://peru.campusvirtualsp.org/repositorio/function.array-merge>]:
> Argument #2 is not an array in */var/www/repositorio/include/SPT--
> GlobalSearchEngine.php *on line *91*
>
> *Warning*: usort() [function.usort<http://peru.campusvirtualsp.org/repositorio/function.usort>]:
> The argument should be an array in */var/www/repositorio/include/SPT--
> GlobalSearchEngine.php* on line *100*
>
> *Warning*: array_slice() [function.array-slice<http://peru.campusvirtualsp.org/repositorio/function.array-slice>]:
> The first argument should be an array in *
> /var/www/repositorio/include/SPT--GlobalSearchEngine.php *on line *106
> *
> It happened while doing a global search to another friend sites.
> Specifically, the following code gave the error:
>
> function PerformSearch($SetSpec, $StartingResult, $NumberOfResults)
> {
> # for each global search site
> $DB =& new SPTDatabase();
> $DB->Query("SELECT * FROM GlobalSearchSites");
> $SearchResults = array();
> while ($SiteInfo = $DB->FetchRow())
> {
> # retrieve results from site
> $SiteSearchResults = $this->SearchSite($SiteInfo, $SetSpec);
>
> # add results to result list
> *$SearchResults = array_merge($SearchResults,
> $SiteSearchResults); **error*
> }
>
> # sort the results in descending order by search score
> function SearchScoreCmp($ResultA, $ResultB)
> {
> return ($ResultA["Search Score"] == $ResultB["Search Score"])
> ? 0
> : (($ResultA["Search Score"] < $ResultB["Search
> Score"]) ? 1 : -1);
> }
> usort($SearchResults, "SearchScoreCmp");
>
> # save number of results found
> $this->NumberOfResultsAvailable = count($SearchResults);
>
> # trim result list to match range requested by caller
> $SearchResults = array_slice($SearchResults, $StartingResult,
> $NumberOfResults);
>
> # return search results to caller
> return $SearchResults;
> }
>
> It happens when there are not results matching the search criteria. In
> that case, *$SiteSearchResults *would be null. With PHP 4.x, no problem,
> it converts null to array on the fly. But PHP 5.x needs to have it
> explicit. So, the only thing you have to do is to add (array), to convert
> the variable to array on the fly, cause in other way, PHP wouldn't
> understand the syntaxis and give you the error:
> *$SearchResults = array_merge($SearchResults, (array) $SiteSearchResults);
> *
>
> So, if any of you wants to upgrade to PHP 5.x, it's OK. The only thing you
> have to do is to add that word (array()) and you're done.
>
> Greetings!
>
> PD: I'm also using MySQL 5.x, Apache 2.x and Ubuntu Server Edition 6.10
>
> --
> Jhonatan Hamner Tirado Tirado
> Analista Desarrollador
> Celular: +51 44 9670126
> Lima, Perú
>
> _______________________________________________
> SPT-CWIS-Users mailing list
> SPT-CWIS-Users at scout.wisc.edu
> http://scout.wisc.edu/mailman/listinfo/spt-cwis-users
>
>
--
Jhonatan Hamner Tirado Tirado
Analista Desarrollador
Celular: +51 44 9670126
Lima, Perú
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.scout.wisc.edu/pipermail/spt-cwis-users/attachments/20070502/abd5178d/attachment-0003.html
More information about the SPT-CWIS-Users
mailing list