php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79749 Object of class FFI could not be converted to bool in a simple if
Submitted: 2020-06-27 20:57 UTC Modified: 2020-06-29 11:41 UTC
From: kelunik@php.net Assigned:
Status: Closed Package: *Extensibility Functions
PHP Version: 8.0Git-2020-06-27 (Git) OS: Ubuntu
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: kelunik@php.net
New email:
PHP Version: OS:

 

 [2020-06-27 20:57 UTC] kelunik@php.net
Description:
------------
This works on PHP 7.4 and also works on PHP 8 with other objects like new \stdClass.

Test script:
---------------
<?php
// create FFI object, loading libc and exporting function printf()
$ffi = FFI::cdef(
    "int printf(const char *format, ...);", // this is regular C declaration
    "libc.so.6");
// call C printf()
$ffi->printf("Hello %s!\n", "world");
if ($ffi) {
    print 'ok';
}



Expected result:
----------------
Hello world!
ok

Actual result:
--------------
Hello world!
PHP Recoverable fatal error:  Object of class FFI could not be converted to bool in /home/kelunik/test.php on line 8

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-06-28 05:27 UTC] kelunik@php.net
-Package: Scripting Engine problem +Package: ffi
 [2020-06-28 05:28 UTC] kelunik@php.net
-Package: ffi +Package: Scripting Engine problem
 [2020-06-29 11:41 UTC] cmb@php.net
-Status: Open +Status: Verified -Package: Scripting Engine problem +Package: *Extensibility Functions
 [2020-06-29 11:44 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #79749: Converting FFI instances to bool fails
On GitHub:  https://github.com/php/php-src/pull/5776
Patch:      https://github.com/php/php-src/pull/5776.patch
 [2020-06-29 14:03 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=aca621cf926cf86fd186395d3877fc63b65f3d16
Log: Fix #79749: Converting FFI instances to bool fails
 [2020-06-29 14:03 UTC] cmb@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 22:01:31 2024 UTC