[development] PHP input format -> syntax checking

Robert Wohleb rob at techsanctuary.com
Tue Aug 22 08:32:02 UTC 2006


My second reply must have been lost as I haven't seen it. Maybe my FROM
field was wack and the mailing list is holding it up. Anyways...

There is a difference between fatal errors and parse errors. Fatal
errors tend to involve resource handles, memory allocation, etc. The
method I described should work to detect parse errors.

~Rob

Tadej Baša wrote:
> Robert Wohleb pravi:
>> Hi,
>>
>> As long as the submitted code does not cause a fatal error, 
> that's exactly what I want to prevent. e.g. a missing ')' (parse
> error) in custom block visibility causes the whole site to break.
>
> - Tadej
>
>> you should be able to eval the code with drupal_eval and catch any
>> errors with a
>> custom error handler. The trick will be in writing the error handler.
>>
>> http://api.drupal.org/api/4.7/function/drupal_eval
>> http://us3.php.net/manual/en/ref.errorfunc.php
>>
>> ~Rob
>>
>> Tadej Baša wrote:
>>> Hi,
>>> as you know, there is no way to recover from syntax errors in PHP code
>>> a  user submits (either as nodes or for example in custom block
>>> visibility settings). I'm trying to figure out, if it would be
>>> possible to send the code to drupal_eval with javascript and prevent
>>> form submission if an error is returned.
>>> What do you think?
>>>
>>> -Tadej
>>>
>>>
>>>
>>>
>>
>
>
>
>
>

-- 
----------------------------------------------------------
It is by Caffeine alone that I set my mind in motion
It is by the beans of Java, that my thoughts acquire speed
The hands acquire shakes; the shakes become a warning 
It is by Caffeine alone that I set my mind in motion



More information about the development mailing list