Opened 14 years ago

#3220 new defect

Possible PHP Mapscript Bug

Reported by: nnikolov Owned by: mapserverbugs
Priority: normal Milestone:
Component: MapScript-PHP Version: 5.2
Severity: minor Keywords: msQueryByRect
Cc:

Description

When we use queryByRect on a map object, we get this error message in the mapserver error log file, whenever no shapes were found:

msQueryByRect(): Search returned no results. No matching record(s) found.

We want to suppress this message because in our script, finding 0 shapes is a legitimate result. However it appears at all debug levels and even if we use the the ‘@’ control operator as suggested in the documentation below.

The relevant line of code in our script is:

$QueryResult = @$detLayer->queryByRect($my_rect);

And in our map file we have: DEBUG 0

We notice a comment on the web:

so what does the @ operator do? It temporarily sets the error reporting level to 0 for that line. If that line triggers an error, the error handler will still be called, but it will be called with an error level of 0

http://php.net/manual/en/language.operators.errorcontrol.php

In the mapscript code we cannot see that this error is made conditional on DEBUG level. Should it be made so? If so, we suggest the following code change in mapquery.c file at the very end of msQueryByRect function:

if(map->debug > 4) { /* Added by NN */

msSetError(MS_NOTFOUND, "No matching record(s) found.", "msQueryByRect()");

} return(MS_FAILURE);

where 4 is the an arbitrary debug level above which we want the error message to appear.

Background: Here’s the entry in Mapscript documentation (http://mapserver.org/mapscript/php/index.html#mapobj-class):

int queryByRect(rectObj rect)

Query all selected layers in map using a rectangle specified in georeferenced map coordinates (i.e. not pixels). The query is performed on all the shapes that are part of a CLASS that contains a Templating value or that match any class in a layer that contains a LAYER TEMPLATE value. Returns MS_SUCCESS if shapes were found or MS_FAILURE if nothing was found or if some other error happened (note that the error message in case nothing was found can be avoided in PHP using the ‘@’ control operator).

Change History (0)

Note: See TracTickets for help on using tickets.