Opened 22 years ago

Last modified 20 years ago

#236 new defect

[PHP MapScript] Make most functions produce tappable errors

Reported by: dmorissette Owned by: dmorissette
Priority: highest Milestone: FUTURE
Component: MapScript-PHP Version: 4.1
Severity: normal Keywords:
Cc: wbronsema@…, pspencer@…, zjames@…

Description

With the current version of PHP MapScript, it is impossible to trap most error 
conditions since the PHP module almost always produces E_ERROR php error codes, 
and this has the effect of halting the script and none of the error handling 
functions in PHP can trap that.

It seems that all other modules use E_WARNING for things like failure to read a 
file, connect to a database, etc.  This allows the user to trap any error 
condition, which is impossible with PHP MapScript.  So for all 'normal' error 
conditions we should produce an E_WARNING that will be trappable with the '@' 
character in the PHP script.  

Note that we should also make sure that all functions return valid status codes 
(MS_SUCCESS/MS_FAILURE or 0/-1, or TRUE/FALSE) as documented in the PHP 
MapScript docs.

Since this will affect existing developers who always counted on the fact that 
errors would abort their script, we should document this change properly in the 
HISTORY.TXT.

P.S. We also discussed previously the possibility of setting a default (global) 
error level for MapScript (E_ERROR or E_WARNING), but when I came to implement 
this it looked too much like a mess and I thought that it would be simpler and 
better to align the behavior of php_mapscript with the behavior of other PHP 
modules.  We'll just have to be more careful about detecting error conditions 
when we use the module.

Change History (3)

comment:1 by assefa, 21 years ago

Version: 4.04.1

comment:2 by assefa, 21 years ago

Cc: zjames@… added
Adding Zak to CC.

Right now the ms_newMapObj function returns a E_WRANING and It is possible to
trap that with the @. It seems that this would be sufficient for Mapedit. If
other functions that currently return E_ERROR needs to be changed to E_WARNING,
we can modify them as needed.

comment:3 by assefa, 20 years ago

Cc: sfournier@… removed
Milestone: FUTURE
This is a more general issue and won't be solved for this release. I think 
thinks work for our needs from what I know. I am setting this to FUTURE. If 
there are specific functions that need to be altered before the release, 
please indicate.
Note: See TracTickets for help on using tickets.