Opened 19 years ago

Closed 19 years ago

#1184 closed defect (wontfix)

getLayerByName throws a warning

Reported by: godwinl@… Owned by: mapserverbugs
Priority: high Milestone:
Component: MapScript-PHP Version: 4.4
Severity: normal Keywords:
Cc:

Description

I didn't get a response on the mailing list so I'm filing it anyway...

When I do call the getLayerByName method on a map object, it throws a warning
when the layer doesn't exist.  The docs suggest, and common sense too, that it
returns FALSE when the layer doesn't exist, ot returns the layer when it does.

I tested the issue on Windows/Linux with 4.2, 4.4.1 and 4.5 (cvs from 1 week ago).

snippit:
--------------------------
//returns the layer object ok.
$oLayer = $oMap->getLayerByName("validlayername");
 
//retuns FALSE and echos a warning
$oLayer = $oMap->getLayerByName("notvalidlayer");
--------------------------

 Warning: getLayerByName failed for : notvalidlayer in ...

Change History (2)

comment:1 by assefa, 19 years ago

The php waring generated can be supressed using a @ (something like @$oLayer =
$oMap->getLayerByName("notvalidlayer");) and then you can validate the value of
$oLayer.   Is this accepatable ?

 In my opnion, the default behaviour of generating a php waring is ok since It
can be suppressed for those would do not want the warnings. I agree It should
make it to the docs but I guess most (maybe all) of the wranings gnerated are
not documented so If it is done It must be done for all. Another point is that
we haven't be very consistent or defined a clear guide line on what type of
error a function is suppose to return   for diffrent scenarios. There is a need
to revisit this at one point and have the warings/erros consistent through all
the mapscript flavors but then again It is a long process to pass through all
the functions. 

comment:2 by dmorissette, 19 years ago

Resolution: wontfix
Status: newclosed
Let's close this as WONTFIX for now since the "@" operator should do what you need.
Note: See TracTickets for help on using tickets.