[redland-dev] redland/php questions

Dave Beckett dave.beckett at bristol.ac.uk
Mon Mar 7 19:58:40 GMT 2005


On Wed, 2 Mar 2005, Sebastian Dietzold wrote:
> Hi again,
> 
> i have some question about the usage of the redland php interface:
> 
> 1. how can i handle errors and warnings e.g. from 
> librdf_parser_parse_into_model or librdf_query_execute. 
> librdf_world_set_error and librdf_world_set_logger are not supported yet 
> and the messages appear only in apaches error.log. It is possible?

It's possible but means looking into PHP/C interfacing and then linking it 
in with SWIG.  No estimate how hard it is before looking.

> 2. if i try to ask the type of a node with which is NULL (e.g. a var in a 
> result set is empty) this error appears (and librdf_node_get_type returns 
> type=0):
> 
> rdf_node.c:714: (librdf_node_get_type) assertion failed: object pointer of 
> type librdf_node is NULL.
> 
> but ($node != NULL) in php so i can't check empty nodes without throwing 
> much errors. it is possible to avoid this?

Not at present.  The problem is that some redland calls return a C NULL 
pointer or a value (string usually) and PHP/SWIG can't handle that so I 
have to add a patch to the return value to return "" - for example, 
the language of a literal.

There is also the problem with the SWIG wrappers which wrap pointers with 
objects even if the pointers are NULL, so a NULL node pointer in redland 
turns into a non-NULL object in python, wrapping a NULL pointer.  One 
answer to this would be to add a librdf_php_node_is_null() call and any 
others for other types that need the check.  A bit nasty, but it would 
work for the short-term.

Does PHP have a null, which I should be using here?  If it does in some 
newer version it probably means I can't use it since there are many 
earlier versions out there.

Dave
 


More information about the redland-dev mailing list