[svn:PHP-Sandwich] rev 1416 - in PHP-Sandwich/trunk: . lib/PHP t
[email protected] 26 Jul 2005 02:39:40 -0000
| Newsgroups | perl.php.sandwich.dev |
|---|---|
| Message-ID | <[email protected]> |
Author: gschlossnagle
Date: Mon Jul 25 19:39:40 2005
New Revision: 1416
Modified:
PHP-Sandwich/trunk/PHP.xs
PHP-Sandwich/trunk/lib/PHP/Interpreter.pm
PHP-Sandwich/trunk/t/20.t
Log:
Not the fix I want for 20, but a fix nonetheless.
Modified: PHP-Sandwich/trunk/PHP.xs
==============================================================================
--- PHP-Sandwich/trunk/PHP.xs (original)
+++ PHP-Sandwich/trunk/PHP.xs Mon Jul 25 19:39:40 2005
@@ -465,13 +465,11 @@ SV* SAND_new(classname, ...)
else if(!strcmp(trackvars_key, "FILES")) {
track_vars_array = PG(http_globals)[TRACK_VARS_FILES];
}
- /*
else if(!strcmp(trackvars_key, "BRIC")) {
zval *bric = SvZval(trackvars TSRMLS_CC);
zend_register_auto_global("BRIC", sizeof("BRIC")-1, NULL TSRMLS_CC);
zend_hash_update(&EG(symbol_table), "BRIC", sizeof("BRIC"), &bric, sizeof(zval *), NULL);
}
- */
else if(!strcmp(trackvars_key, "OUTPUT")) {
sandwich_per_interp *interp = (sandwich_per_interp *)SG(server_context);
if(interp) {
@@ -563,12 +561,13 @@ SV *SAND_call(interp, method_name, ...)
zval_dtor(&method);
if(retval == NULL) {
tsrm_set_interpreter_context(old_ctx);
- croak("A PHP error occured\n");
+ croakstr = "A PHP error occured\n";
} else {
RETVAL = newSVzval(retval, interp);
}
}
tsrm_set_interpreter_context(old_ctx);
+ if(croakstr) croak(croakstr);
}
OUTPUT:
RETVAL
Modified: PHP-Sandwich/trunk/lib/PHP/Interpreter.pm
==============================================================================
--- PHP-Sandwich/trunk/lib/PHP/Interpreter.pm (original)
+++ PHP-Sandwich/trunk/lib/PHP/Interpreter.pm Mon Jul 25 19:39:40 2005
@@ -15,8 +15,8 @@ sub AUTOLOAD {
my $self = shift;
$sub =~ s/.*:://;
unshift @_, $sub;
- unshift @_, $self;
- goto &call;
+ # we'd prefer to use goto here, but it dies if we croak in it
+ $self->call(@_);
}
1;
Modified: PHP-Sandwich/trunk/t/20.t
==============================================================================
--- PHP-Sandwich/trunk/t/20.t (original)
+++ PHP-Sandwich/trunk/t/20.t Mon Jul 25 19:39:40 2005
@@ -1,17 +1,17 @@
-#!/opt/ecelerity/3rdParty/bin/perl -w
use strict;
+use Test::More tests => 3;
-use PHP;
-use PHP::Interpreter;
-
-use Data::Dumper;
+BEGIN {
+ use_ok 'PHP::Interpreter';
+}
-my $p = PHP::Interpreter->new();
my $foo = Foo->new();
-$foo->addInterp;
-
-$foo->upper();
+ok $foo->addInterp, "Add an intepreter to foo";
+eval {
+ $foo->upper();
+};
+is $@, "A PHP error occured\n", "Invalid code causes a croak()";
package Foo;
@@ -31,8 +31,7 @@ sub addInterp {
sub upper {
my $self = shift;
my $p = $self->{php};
- print "calling invalid code\n";
- print $p->strln('george');
+ $p->strln('george');
}
1;