Bug #70678 [Com]: PHP7 returns true when false is expected

From: Date: Fri, 16 Oct 2015 06:52:35 +0000
Subject: Bug #70678 [Com]: PHP7 returns true when false is expected
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196637@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70678&edit=1

 ID:                 70678
 Comment by:         f dot bosch at genkgo dot nl
 Reported by:        f dot bosch at genkgo dot nl
 Summary:            PHP7 returns true when false is expected
 Status:             Closed
 Type:               Bug
 Package:            XSLT related
 Operating System:   worker-linux-docker
 PHP Version:        7.0.0RC4
 Assigned To:        felipe
 Block user comment: N
 Private report:     N

 New Comment:

This bugfix was not merged with RC5. Will it be with the next RC?


Previous Comments:
------------------------------------------------------------------------
[2015-10-11 15:05:33] 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-09 14:23:04] f dot bosch at genkgo dot nl

It is not vice versa as been suggested in the original post.

------------------------------------------------------------------------
[2015-10-09 14:21:15] 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


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=70678&edit=1


Thread (3 messages)

« previous php.bugs (#196637) next »