# zend_get_parameters_ex rework

- Thread: https://externals.io/message/82381
- Original archive: https://news-web.php.net/php.internals/82381
- Started by Lester Caine on 2015-02-10T14:31:09+00:00
- Messages: 13
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #82381 — Lester Caine — 2015-02-10T14:31:09+00:00

URL: https://externals.io/message/82381#82381

in interbase/ibase_blobs.c

> 	zval *blob_arg, *string_arg;
> 	ibase_blob *ib_blob;
> 
> 	RESET_ERRMSG;
> 
> 	if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &blob_arg, &string_arg) == FAILURE) {
> 		WRONG_PARAM_COUNT;
> 	}
> 
> 	ZEND_FETCH_RESOURCE(ib_blob, ibase_blob *, blob_arg, -1, "Interbase blob", le_blob);

I've got that if changes to

>       if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr", &blob_arg, &string_arg)) { 
>               return;
>  	}

But I suspect I need to change the *string_arg to a character string so
'rc' and add a string_len field. At least that is what I think I'm
seeing from the samples I have found.

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

---

## #82474 — Lester Caine — 2015-02-11T12:43:05+00:00

URL: https://externals.io/message/82381#82474 · In reply to: #82381

> in interbase/ibase_blobs.c
> 
> > […]
> 
> I've got that if changes to
> 
> > […]
> 
> But I suspect I need to change the *string_arg to a character string so
> 'rc' and add a string_len field. At least that is what I think I'm
> seeing from the samples I have found.

OK I've got a patch for master, but I know that the changes are not
complete!

http://hg.lsces.org.uk/hg/php-src/rev/8ec9101f59b6

I've still got a question about the &string_arg on line 1.9 and if it
should be changed to a string but that change needs working through the
following code.

Also is what I'm doing here php7 only? so should there be wrappers for a
PHP5 build?

I think that all this leaves is all the complaints about 'NULL' and integer
initialization makes integer from pointer without a cast
and
assignment makes integer from pointer without a cast

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

---

## #82521 — Yasuo Ohgaki — 2015-02-12T10:10:35+00:00

URL: https://externals.io/message/82381#82521 · In reply to: #82474

Hi Lester,



> OK I've got a patch for master, but I know that the changes are not
> complete!
>
> http://hg.lsces.org.uk/hg/php-src/rev/8ec9101f59b6
>
> I've still got a question about the &string_arg on line 1.9 and if it
> should be changed to a string but that change needs working through the
> following code.
>
> Also is what I'm doing here php7 only? so should there be wrappers for a
> PHP5 build?
>

I think we need modules for PHP5 and PHP7.
They differ a lot.

I think that all this leaves is all the complaints about 'NULL' and integer
> initialization makes integer from pointer without a cast
> and
> assignment makes integer from pointer without a cast
>

 1.9 + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"rr", &blob_arg, &string_arg)) {

I don't read the code and just curious.
The "string_arg" isn't string? Why you specify "r" (resource)? Is it badly
named parameter or some kind of string resource?

It may be easier for you and us, if you could use github.

Regards,

--
Yasuo Ohgaki
yohgaki@ohgaki.net

---

## #82522 — Lester Caine — 2015-02-12T11:08:29+00:00

URL: https://externals.io/message/82381#82522 · In reply to: #82521

> 
>  1.9 +if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
> "rr", &blob_arg, &string_arg)) {
> 
> I don't read the code and just curious.
> The "string_arg" isn't string? Why you specify "r" (resource)? Is it
> badly named parameter or some kind of string resource?

This is the bit I have asked about a couple of times already ;)
That value is passed to a second function _php_ibase_blob_add which
expects a zval, but I don't think that this is necessary now? It is a
block of data rather than a text string as such and may include unicode
or other binary data. What it does has not changed since 1990's only how
PHP handles it.

> It may be easier for you and us, if you could use github.

My local repo is just a mirror of git.php.net and I can work from that
locally direct off eclipse which includes stuff I will never backup to
github. 'You don't have to use git' was one of the promises when that
was force on us ... I have an account, but forking php-src just to work
on a couple of extensions is pointless.

Back to code ...
https://github.com/php/php-src/blob/master/ext/interbase/ibase_blobs.c
Line 318 passes string_arg to function at 131
( this is so much easier using eclipse to navigate :) )

The other compile problem I have is the complaints about casting
pointers to integer ...

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

---

## #82523 — Nikita Popov — 2015-02-12T11:35:40+00:00

URL: https://externals.io/message/82381#82523 · In reply to: #82474

> 
> > […]
> &string_arg) == FAILURE) {
> > […]
> "Interbase blob", le_blob);
> > […]
> "rr", &blob_arg, &string_arg)) {
> > […]
>
> OK I've got a patch for master, but I know that the changes are not
> complete!
>
> http://hg.lsces.org.uk/hg/php-src/rev/8ec9101f59b6
>

In ibase_blob_get you're declaring 'len_arg' as 'unsigned long'. If you're
using the 'l' type in zpp you should use the 'zend_long'  type instead -
otherwise it will not work correctly on LLP64 (aka Windows) systems.

>
> I've still got a question about the &string_arg on line 1.9 and if it
> should be changed to a string but that change needs working through the
> following code.
>

Yes, this should be changed to a string. E.g. use the 'S' zpp modifier and
declare the variable as 'zend_string *str'. Then modify the places where it
is used from Z_STRVAL_P(...) to str->val and Z_STRLEN_P(...) to str->len.


> Also is what I'm doing here php7 only? so should there be wrappers for a
> PHP5 build?
>

Apart form a few special exceptions we keep PHP7-only codebases in php-src.
They don't need to (and shouldn't) contain any compat code.

As another tip: If you want to link to code in the PHP codebase, I
recommend using http://lxr.php.net/xref/PHP_TRUNK/ instead of GitHub -
lxr.php.net is cross-referenced, so you can click through function usages.

Nikita

---

## #82529 — Lester Caine — 2015-02-12T12:42:27+00:00

URL: https://externals.io/message/82381#82529 · In reply to: #82523

>     I've still got a question about the &string_arg on line 1.9 and if it
>     should be changed to a string but that change needs working through the
>     following code.
> 
> 
> Yes, this should be changed to a string. E.g. use the 'S' zpp modifier
> and declare the variable as 'zend_string *str'. Then modify the places
> where it is used from Z_STRVAL_P(...) to str->val and Z_STRLEN_P(...) to
> str->len.

OK that makes sense ... and I though I was on a roll, except while I can
convert one of the uses, another is feed by a zval which I then need to
convert to a zend_string, but I think I can just change b_val to
Z_STR*(b_val) but the compiler is saying that Z_STR is not defined?

I've spent half an hour trying to dig around but not managed to find
what I should be using :(

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

---

## #82542 — marius adrian popa — 2015-02-12T15:12:39+00:00

URL: https://externals.io/message/82381#82542 · In reply to: #82529

Finish the patch and i will apply , also ZEND_FETCH_RESOURCE2 must be
replaced with
zend_fetch_resource2 like it was done in pgsql case

https://github.com/php/php-src/commit/0d4255de30314dbfa32827e044b35543b1ae5a39




> 
> > […]
> the
> > […]
>
> OK that makes sense ... and I though I was on a roll, except while I can
> convert one of the uses, another is feed by a zval which I then need to
> convert to a zend_string, but I think I can just change b_val to
> Z_STR*(b_val) but the compiler is saying that Z_STR is not defined?
>
> I've spent half an hour trying to dig around but not managed to find
> what I should be using :(
>
> --
> Lester Caine - G8HFL
> -----------------------------
> Contact - http://lsces.co.uk/wiki/?page=contact
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk
> Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

---

## #82592 — Jan Ehrhardt — 2015-02-13T09:55:39+00:00

URL: https://externals.io/message/82381#82592 · In reply to: #82474

Lester Caine in php.internals (Wed, 11 Feb 2015 12:43:05 +0000):
>OK I've got a patch for master, but I know that the changes are not
>complete!
>
>http://hg.lsces.org.uk/hg/php-src/rev/8ec9101f59b6

This one might be a little bit more complete:
https://github.com/Jan-E/php-src/commit/8c920a22ac65da485eaf3d2fd27baf2b0406116e

Could you test that one? I did it as a sort of PHP7 exercise, but I do
not have Interbase running.

Jan

---

## #82617 — marius adrian popa — 2015-02-13T15:56:28+00:00

URL: https://externals.io/message/82381#82617 · In reply to: #82592

Thanks patch looks clean and It compiles , i will start testing it



> Lester Caine in php.internals (Wed, 11 Feb 2015 12:43:05 +0000):
> > […]
>
> This one might be a little bit more complete:
>
> https://github.com/Jan-E/php-src/commit/8c920a22ac65da485eaf3d2fd27baf2b0406116e
>
> Could you test that one? I did it as a sort of PHP7 exercise, but I do
> not have Interbase running.
>
> Jan

---

## #82620 — Jan Ehrhardt — 2015-02-13T16:40:04+00:00

URL: https://externals.io/message/82381#82620 · In reply to: #82617

marius adrian popa in php.internals (Fri, 13 Feb 2015 17:56:28 +0200):
>
>
> > […]
>
>Thanks patch looks clean and It compiles , i will start testing it

It still gives some warnings at compile time. Most of them are caused by

ib_link = (ibase_db_link *)zend_fetch_resource2_ex(IBG(default_link),\
	LE_LINK, le_link, le_plink);

warning C4024: 'zend_fetch_resource2_ex' : different types for formal
and actual parameter 1. I could not find a way to fix this.

A comparable warning in interbase.c - PHP_FUNCTION(ibase_gen_id) might
be easier to solve, I see now.

Jan

---

## #82626 — Lester Caine — 2015-02-13T17:10:56+00:00

URL: https://externals.io/message/82381#82626 · In reply to: #82620

> It still gives some warnings at compile time. Most of them are caused by
> 
> ib_link = (ibase_db_link *)zend_fetch_resource2_ex(IBG(default_link),\
> 	LE_LINK, le_link, le_plink);
> 
> warning C4024: 'zend_fetch_resource2_ex' : different types for formal
> and actual parameter 1. I could not find a way to fix this.
> 
> A comparable warning in interbase.c - PHP_FUNCTION(ibase_gen_id) might
> be easier to solve, I see now.

I'm sure it is just a mater of 'casting' the pointers used on the
interface to match the new PHP rules. I'll be having a go myself later
... got to earn some money first :)

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

---

## #83013 — Jan Ehrhardt — 2015-02-17T23:40:30+00:00

URL: https://externals.io/message/82381#83013 · In reply to: #82617

marius adrian popa in php.internals (Fri, 13 Feb 2015 17:56:28 +0200):
>Thanks patch looks clean and It compiles, i will start testing it

Apparently your tests were successful (?):
http://git.php.net/?p=php-src.git;a=commitdiff;h=8f968c5416e721983c0efda25ec1f393c8df662a

Jan

---

## #83019 — Lester Caine — 2015-02-18T02:12:34+00:00

URL: https://externals.io/message/82381#83019 · In reply to: #83013

> > […]
> Apparently your tests were successful (?):
> http://git.php.net/?p=php-src.git;a=commitdiff;h=8f968c5416e721983c0efda25ec1f393c8df662a

Adrian may have, but I've just wasted 2 hours trying to get the tests to
run and all I can get is 'Termsig=11' failures after it creates the test
database. But it is running happily on the test site
http://php7.lsces.org.uk/wiki/
The thing I would rather be working on is why the PHP5 versions are
running more queries on the database then the PHP7 build. The code and
database are identical ... only the PHP side is different.

But I need a few hours sleep ...

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
