php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70678 PHP7 returns true when false is expected
Submitted: 2015-10-09 14:21 UTC Modified: 2015-10-11 15:06 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: f dot bosch at genkgo dot nl Assigned: felipe (profile)
Status: Closed Package: XSLT related
PHP Version: 7.0.0RC4 OS: worker-linux-docker
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: f dot bosch at genkgo dot nl
New email:
PHP Version: OS:

 

 [2015-10-09 14:21 UTC] f dot bosch at genkgo dot nl
Description:
------------
If you are using php functions inside an XSL script and return 'false', then XSL sees it as 'true', and vice versa.

Test script:
---------------
PHP script

$xslDoc = new DOMDocument();
$xslDoc->load('Stubs/php-functions.xsl');

$xmlDoc = new DOMDocument();
$xmlDoc->load('Stubs/collection.xml');

$native = new \XSLTProcessor();
$native->importStylesheet($xslDoc);
$native->registerPHPFunctions();
$nativeResult = trim($native->transformToXML($xmlDoc));

$transpiler = new XsltProcessor();
$transpiler->importStylesheet($xslDoc);
$transpiler->registerPHPFunctions();
echo $transpiler->transformToXML($xmlDoc);

XML Document

<collection />

XSL Sheet

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl">
    
    <xsl:output method="xml"
                indent="no"
                omit-xml-declaration="yes"
                encoding="UTF-8"/>

    <xsl:template match="collection">
        <xsl:value-of select="php:functionString('strpos', 'Hello', 'World')" />
    </xsl:template>

</xsl:stylesheet>

Expected output: false
Actual output: true

Expected result:
----------------
false

Actual result:
--------------
true

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-10-09 14:23 UTC] f dot bosch at genkgo dot nl
It is not vice versa as been suggested in the original post.
 [2015-10-11 13:57 UTC] felipe@php.net
-Summary: PHP7 returns true when false is expected +Summary: PHP returns true when false is expected
 [2015-10-11 15:05 UTC] felipe@php.net
Automatic comment on behalf of felipensp@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8d12ff75132644006b394ab02c37944c48d6a920
Log: - Fixed bug #70678 (PHP7 returns true when false is expected)
 [2015-10-11 15:05 UTC] felipe@php.net
-Status: Open +Status: Closed
 [2015-10-11 15:06 UTC] felipe@php.net
-Summary: PHP returns true when false is expected +Summary: PHP7 returns true when false is expected -Assigned To: +Assigned To: felipe
 [2015-10-16 06:52 UTC] f dot bosch at genkgo dot nl
This bugfix was not merged with RC5. Will it be with the next RC?
 [2015-11-09 18:12 UTC] ab@php.net
Automatic comment on behalf of felipensp@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=23e625b3ad293cce4a1fc40a9027a8d9ca95847b
Log: Fixed bug #70678 (PHP7 returns true when false is expected)
 [2016-04-18 09:30 UTC] bwoebi@php.net
Automatic comment on behalf of felipensp@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8d12ff75132644006b394ab02c37944c48d6a920
Log: - Fixed bug #70678 (PHP7 returns true when false is expected)
 [2016-07-20 11:36 UTC] davey@php.net
Automatic comment on behalf of felipensp@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=20a384dfa924c6e0d7aa08e1f79d940047ffdb49
Log: Fixed bug #70678 (PHP7 returns true when false is expected)
 [2016-07-20 11:36 UTC] davey@php.net
Automatic comment on behalf of felipensp@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8d12ff75132644006b394ab02c37944c48d6a920
Log: - Fixed bug #70678 (PHP7 returns true when false is expected)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 04 18:01:31 2024 UTC