[SPT/CWIS] SPT and PHP5
Jhonatan Tirado
jhonatantiradotiradodeep at gmail.com
Tue May 29 17:03:47 CDT 2007
Well, I think the poster you're talking about is the mine.
In fact, I succeeded in porting to PHP5, just using a cast operator.
If you have any question, maybe I can help.
And you can see the site running SPT/CWIS and PHP5 at
http://peru.campusvirtualsp.org/repositorio/SPT--Home.php
Apache/2.0.55
mysql Ver 14.12 Distrib 5.0.24a
Ubuntu Server Edition 6.10
And the poster is the following:
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
2007/5/29, Cristina Gottardi < cristina.gottardi at unipd.it>:
>
> Thank you for your answer. I looked up in the list archives and found
> the poster you mention - I forwarded everything to our techie.
> Thanks again
> Cristina
>
> Kucera, Rich ha scritto:
>
> > We've had success placing SPT/CWIS on XAMPP running in PHP4 mode on
> > SuSE 10.1.
> > (support for PHP4 in SuSE kind of disappears after v10.0). Changing
> > port numbers
> > on that stack to run alongside your real apache will be a bit of
> > hacking, but
> > doable (I've done that). Changing port numbers of the MySQL also
> doable.
> >
> > I don't know of another working PHP4 stack, there are a couple old
> ones,
> > but I don't know if they would still work.
> >
> > There was another poster to this list who succeeded in porting to PHP5
> > with only one minor issue (fixed with a (cast) operator on a return
> > value).
> >
> >
>
> _______________________________________________
> 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 9453947
RPM: #353811
Lima, Perú
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.scout.wisc.edu/pipermail/spt-cwis-users/attachments/20070529/97f38831/attachment-0003.html
More information about the SPT-CWIS-Users
mailing list