php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78639 mysql_xdevapi\CollectionFind::limit returns bool with Zend OPcache enabled
Submitted: 2019-10-06 19:26 UTC Modified: 2021-09-09 10:44 UTC
From: shaun at shaunfreeman dot name Assigned:
Status: Open Package: MySQL related
PHP Version: 7.3.10 OS: Ubuntu 18.04
Private report: No CVE-ID: None
 [2019-10-06 19:26 UTC] shaun at shaunfreeman dot name
Description:
------------
I have come across a bug when OPcache is enabled. I am using Ubuntu 18.04 and PHP 7.3.10. When OPcache is enabled then mysql_xdevapi\CollectionFind::limit and mysql_xdevapi\CollectionFind::offset return bool instead of an mysql_xdevapi\CollectionFind instance.

When OPcache is not loaded then I get the expected result. I am running PHP-FPM on a unix socket with Nginx
My configure command is

./configure --prefix=/usr/local/php7.3 \
--with-config-file-path=/usr/local/php7.3/etc \
--with-config-file-scan-dir=/usr/local/php7.3/etc/conf.d \
--disable-cgi \
--enable-fpm \
--enable-bcmath \
--with-curl \
--enable-exif \
--with-gd \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--enable-intl \
--enable-mbstring \
--enable-mysqlnd \
--with-mysqli \
--with-pdo-mysql \
--with-mysql-sock=/var/run/mysqld/mysqld.sock \
--with-openssl \
--with-tidy=/usr/local \
--enable-zip \
--with-libzip \
--with-zlib \
--with-zlib-dir


Test script:
---------------
$session = getSession("mysqlzx://dbuser:!OneTwo3@localhost:33060");

$schema = $session->getSchema('dbname');
$collection = $schema->getCollection('posts');

$result = $collection->find()
    ->offset(0)
    ->limit(2)
    ->execute();


print "<pre>";
print_r($result->fetchAll());

Expected result:
----------------
Array
(
    [0] => Array
        (
            [_id] => 02eb5585a3d74645883b200caa70852f
            [title] => Title 1
            [author] => Shaun Freeman
            [content] => Content 1
            [dateCreated] => Array
                (
                    [date] => 2019-10-06 17:30:15.466565
                    [timezone] => UTC
                    [timezone_type] => 3
                )

        )

    [1] => Array
        (
            [_id] => 40089f7d6154426cb28300d05d1ace5c
            [title] => Title 3
            [author] => Shaun Freeman
            [content] => Content 3
            [dateCreated] => Array
                (
                    [date] => 2019-10-06 17:30:59.344370
                    [timezone] => UTC
                    [timezone_type] => 3
                )

        )

)


Actual result:
--------------
Fatal error: Uncaught Error: Call to a member function limit() on bool in /home/projects/public/expressive-xdevapi-demo/public/xdevapi.php:20 Stack trace: #0 {main} thrown in /home/projects/public/expressive-xdevapi-demo/public/xdevapi.php on line 20

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-10-07 15:11 UTC] nikic@php.net
Two things to try:

 * Run with opcache.protect_memory=1. Does this result in a segfault?
 * Run with opcache.optimization_level=0. Does this fix the issue?
 [2019-10-08 07:10 UTC] shaun at shaunfreeman dot name
opcache.protect_memory=1 nothing seems to change, result is the same.

with opcache.optimization_level=0, that fixes the issue and the right result is returned, no errors.
 [2021-09-09 10:44 UTC] cmb@php.net
Is this still an issue with any of the actively supported PHP
versions[1]?

[1] <https://www.php.net/supported-versions.php>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC