Weird PHP error: "Undefined variable: value"

Bug #1814511 reported by Martin Heide
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
php7.2 (Ubuntu)
Fix Released
Medium
Unassigned
Bionic
Triaged
Medium
Unassigned
php7.3 (Ubuntu)
Fix Released
Medium
Unassigned
Bionic
Won't Fix
Undecided
Unassigned

Bug Description

I observed a strange error when running PHPUnit tests with PHP 7.2 in Ubuntu 18.04.1 LTS.
In various files, there is the error "Undefined variable: value", although the variable is actually defined.

Very weird: It is actually the variable name "$value" that PHP does not like.
When changing the variable name from "$value" e.g. to "$valueFoo", the error disappears in that file, but will appear again in another file where there is also a variable called "$value".

I tried both with the latest PHPUnit version 7.5.2, and with Ubuntu's own package PHPUnit 6.5.5.

Using the latest PHP 7.2 from ppa:ondrej/php does not show this problem.

Is it possible that an outdated, buggy version of PHP 7.2 is used?
The build date is Sep 13 2018.

PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.10-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans

Thanks for your help!
Martin

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

These are some example errors that I get:

1) DH\CoreBundle\Tests\Service\DomainResolveServiceTest::testSubscriptionQueryIfNotInCache_enabled
Undefined variable: value

.../1_source/vendor/symfony/phpunit-bridge/DeprecationErrorHandler.php:108
.../1_source/src/DH/CoreBundle/Service/CacheService.php:154 (NOTE: variable "$value" is used here)
.../1_source/src/DH/CoreBundle/Service/DomainResolveService.php:180
.../1_source/src/DH/CoreBundle/Service/DomainResolveService.php:127
.../1_source/src/DH/CoreBundle/Tests/Service/DomainResolveServiceTest.php:256

---------------------------------
There was 1 error:

1) DH\CoreBundle\Tests\Service\SystemSettingsServiceTest::testSet
DH\CoreBundle\Export\Exception\DatabaseException: Query failure

.../1_source/src/DH/CoreBundle/Service/SystemSettingsService.php:75
.../1_source/src/DH/CoreBundle/Tests/Service/SystemSettingsServiceTest.php:44

Caused by
PHPUnit\Framework\Error\Notice: Undefined variable: value

.../1_source/vendor/symfony/phpunit-bridge/DeprecationErrorHandler.php:108
.../1_source/src/DH/CoreBundle/Service/SystemSettingsService.php:72 (NOTE: variable "$value" is used here)
.../1_source/src/DH/CoreBundle/Tests/Service/SystemSettingsServiceTest.php:44

---------------------------------
There were 7 errors:

1) DH\DataBundle\Tests\StorageModules\AmazonS3StorageTest::testReadFile
Undefined variable: value

.../1_source/vendor/symfony/phpunit-bridge/DeprecationErrorHandler.php:108
.../1_source/vendor/guzzle/guzzle/src/Guzzle/Service/Description/Operation.php:105 (NOTE: variable "$value" is used here)
.../1_source/vendor/guzzle/guzzle/src/Guzzle/Service/Command/AbstractCommand.php:300
.../1_source/vendor/guzzle/guzzle/src/Guzzle/Service/Command/AbstractCommand.php:68
.../1_source/src/DH/DataBundle/Tests/StorageModules/AmazonS3StorageTest.php:1461
.../1_source/src/DH/DataBundle/Tests/StorageModules/AmazonS3StorageTest.php:389

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

$ lsb_release -rd
Description: Ubuntu 18.04.1 LTS
Release: 18.04

$ sudo apt-cache policy pkgname php7.2
[sudo] password for faro:
php7.2:
  Installed: 7.2.10-0ubuntu0.18.04.1
  Candidate: 7.2.10-0ubuntu0.18.04.1
  Version table:
 *** 7.2.10-0ubuntu0.18.04.1 500
        500 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages
        100 /var/lib/dpkg/status
     7.2.3-1ubuntu1 500
        500 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages
N: Unable to locate package pkgname

ProblemType: Bug
DistroRelease: Ubuntu 18.04
Package: php7.2 7.2.10-0ubuntu0.18.04.1
ProcVersionSignature: Ubuntu 4.15.0-45.48-generic 4.15.18
Uname: Linux 4.15.0-45-generic x86_64
ApportVersion: 2.20.9-0ubuntu7.5
Architecture: amd64
CurrentDesktop: XFCE
Date: Mon Feb 4 08:35:12 2019
PackageArchitecture: all
SourcePackage: php7.2
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Martin Heide (heidemn) wrote :
Revision history for this message
Martin Heide (heidemn) wrote :

Additional hint: The same code lines don't trigger any errors when running in Apache - only from CLI.

Revision history for this message
Martin Heide (heidemn) wrote :

Another hint: The problem seems to appear only together with PHPUnit.
When running the same code parts from regular Symfony commands, the error does not occur.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Can you come up with a simple single .php script that shows the problem? That would help with diagnosing this and searching the upstream bug tracker, or even filing an upstream bug.

Changed in php7.2 (Ubuntu):
status: New → Incomplete
Revision history for this message
Martin Heide (heidemn) wrote :

Hi Andreas, so far I didn't succeed to generate a simple script to reproduce.
Will try to put more effort soon.

I suspect that the issue is similar to the following upstream bugs, but I couldn't reproduce them on my Ubuntu 18.04.1.

https://bugs.php.net/bug.php?id=76281
https://bugs.php.net/bug.php?id=76029

Revision history for this message
Bryce Harrington (bryce) wrote :

Hi Martin,

Ubuntu has now moved to php7.3. I presume whatever this issue was on the version of 7.2 we were carrying, 7.3 should have the required fix. But if you could doublecheck, it would be appreciated.

Otherwise, please do let us know if you can identify a simple script to reproduce the issue on 7.2, since even though we're now on 7.3, this problem potentially could be worth an SRU fix for bionic and other stable releases.

Changed in php7.3 (Ubuntu):
status: New → Incomplete
Revision history for this message
Martin Heide (heidemn) wrote :

Hi Bryce,
I just created an updated Docker image from the current state of ubuntu:19.10, using Ubuntu's "php7.3" package.
I could no longer reproduce the bug.

Will check again with the current state of ubuntu:18.04 + its "php7.2" package.

Best regards
Martin

Revision history for this message
Martin Heide (heidemn) wrote :

Hi again,
using ubuntu:18.04 + php7.2 in Docker, I can still reproduce the issue :-(
Same strange error messages, "Undefined variable: value".

Still I coulnd't find a minimal example yet.

For us this is not a high prio issue, since we're using the PPA provided by the PHP team.
And for the next Ubuntu LTS coming soon, I would expect that the bug doesn't appear again, since it no longer appears in ubuntu:19.10.

Best
Martin

Revision history for this message
Bryce Harrington (bryce) wrote :

Thanks for the testing, I'll update the bug states and priorities.

Changed in php7.3 (Ubuntu):
importance: Undecided → Medium
status: Incomplete → Fix Released
Changed in php7.2 (Ubuntu):
importance: Undecided → Medium
status: Incomplete → Triaged
Changed in php7.3 (Ubuntu Bionic):
status: New → Won't Fix
Changed in php7.2 (Ubuntu Bionic):
status: New → Triaged
importance: Undecided → Medium
Changed in php7.2 (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.