[php] Skip directorout typemap if PHP exception pending

Otherwise can end up with a second PHP exception if the directorout
typemap doesn't accept PHP Null.  `SWIG_fail` in this case results
in us returning to PHP which then propagates the pending exception.

This commit fixes a failure in smoketest.php in Xapian's PHP bindings,
but I've not managed to come up with a reproducer which works for
SWIG's testsuite.
This commit is contained in:
Olly Betts 2022-06-09 17:42:21 +12:00
commit 2df27036b7

View file

@ -2249,11 +2249,13 @@ public:
if (tm)
tm = Copy(tm);
}
if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) {
Replaceall(tm, "$error", "EG(exception)");
Printv(w->code, Str(tm), "\n", NIL);
if (!tm || Len(tm) == 0 || Equal(tm, "1")) {
// Skip marshalling the return value as there isn't one.
tm = NewString("if ($error) SWIG_fail;");
}
Append(w->code, "}\n");
Replaceall(tm, "$error", "EG(exception)");
Printv(w->code, Str(tm), "\n}\n{\n", NIL);
Delete(tm);
/* marshal return value from PHP to C/C++ type */
@ -2301,6 +2303,8 @@ public:
}
}
Append(w->code, "}\n");
Delete(cleanup);
Delete(outarg);
}