php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60572 Can't make a optional callback arguments in extension
Submitted: 2011-12-20 09:52 UTC Modified: 2011-12-20 13:51 UTC
From: laruence@php.net Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.3.8 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
12 + 34 = ?
Subscribe to this entry?

 
 [2011-12-20 09:52 UTC] laruence@php.net
Description:
------------
following codes in extension didn't work as expected:
....
 zend_fcall_info fci = {0};
 zend_fcall_info_cache fci_cache;
...
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|f", &key, &klen, 
&fci, &fci_cache) {
         return;
     }

    if (!fci.size) {   
       // not a valid callback
    }


in PHP script:

php_ext_function("name", NULL);  

result in:
argument 2 not a valid callback...  

I haved tried set the arginfo with all_null.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-20 13:17 UTC] cataphract@php.net
-Status: Open +Status: Bogus
 [2011-12-20 13:17 UTC] cataphract@php.net
Optional means "accepting the argument was not given", not "accepting a NULL". To accept NULLs, you have to use !, otherwise the argument is coerced to whatever type you're expecting, which is not possible here.

so

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|f!", &key, &klen, 
&fci, &fci_cache) {
 [2011-12-20 13:51 UTC] laruence@php.net
ah, thanks cataphract.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 08 02:01:32 2024 UTC