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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: laruence@php.net
New email:
PHP Version: OS:

 

 [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: Fri Apr 26 21:01:29 2024 UTC