[redland-dev] redland/php questions

Russell Cloran russell at rucus.net
Mon Mar 7 20:54:59 GMT 2005

On Mon, 2005-03-07 at 19:58 +0000, Dave Beckett wrote:
> 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.

PHP does have a special NULL value,

That page says it has been in existence since 4 ... and I can't imagine
that there are too many 3 installations remaining out there (is it even
supported any more? I see one download from a 2002 security issue for it
on the downloads page.)

Anyways, I think that the following type of patches which you sent me
somewhere between and do the right sort of thing wrt
returning PHP NULLs:

-    SWIG_SetPointerZval(return_value, (void *)result,
SWIGTYPE_p_librdf_iterator, 1);
+    if(!result) {
+        ZVAL_NULL(return_value);
+    }else {
+        SWIG_SetPointerZval(return_value, (void *)result,
SWIGTYPE_p_librdf_iterator, 1);
+    }

In other words, where the C documentation says it would return NULL, it
returns a PHP NULL - the behaviour I'd expect (I'm not sure if I'm alone
in this thinking?).

I hope I haven't completely misunderstood the issue at hand...

echo http://russell.rucus.net/spam/ |sed 's,t/.*,t,;P;s,.*//,,;s,\.,@,;'

More information about the redland-dev mailing list