Skip to content

Commit

Permalink
php-5.2 does not have support for varargs in zend_parse_parameters().…
Browse files Browse the repository at this point in the history
… remove those from midgard_query_constraint_group constructor in php-5.2. Closes gh-11
  • Loading branch information
indeyets committed Jun 17, 2010
1 parent bf18471 commit 4e574db
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 10 additions & 0 deletions php_midgard_query_constraints.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,17 @@ static PHP_METHOD(midgard_query_constraint_group, __construct)
int type_len = 3, num_varargs = 0;
zval ***varargs = NULL;

#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 2
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &type, &type_len) == FAILURE) {
zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Failed to create constraint group");
return;
}
#else
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s*", &type, &type_len, &varargs, &num_varargs) == FAILURE) {
zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Failed to create constraint group");
return;
}
#endif

MidgardQueryConstraintGroup *constraint_group = NULL;

Expand Down Expand Up @@ -265,8 +272,11 @@ static PHP_METHOD(midgard_query_constraint_group, __construct)

ZEND_BEGIN_ARG_INFO_EX(arginfo_midgard_query_constraint_group___construct, 0, 0, 0)
ZEND_ARG_INFO(0, type)
#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 2
#else
ZEND_ARG_OBJ_INFO(0, constraint, midgard_query_constraint_simple, 1)
ZEND_ARG_INFO(0, ...)
#endif
ZEND_END_ARG_INFO()

static PHP_METHOD(midgard_query_constraint_group, get_type)
Expand Down
9 changes: 4 additions & 5 deletions tests_templates/042-midgard_query_select.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ var_dump($list[0]->a == 'abc');
var_dump($list[1]->a == 'abc');


$group = new midgard_query_constraint_group(
'AND',
new midgard_query_constraint(new midgard_query_property('a', $storage), '=', new midgard_query_value('abc')),
new midgard_query_constraint(new midgard_query_property('b', $storage), '=', new midgard_query_value('ghi'))
);
$group = new midgard_query_constraint_group('AND');

$group->add_constraint(new midgard_query_constraint(new midgard_query_property('a', $storage), '=', new midgard_query_value('abc')));
$group->add_constraint(new midgard_query_constraint(new midgard_query_property('b', $storage), '=', new midgard_query_value('ghi')));

var_dump($q->set_constraint($group));
var_dump($q->execute());
Expand Down

0 comments on commit 4e574db

Please sign in to comment.