php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80644 Missing resource causes subsequent get() calls to fail
Submitted: 2021-01-18 22:18 UTC Modified: 2021-01-19 14:15 UTC
From: rdueck at mcmillan-mcgee dot com Assigned: nikic (profile)
Status: Closed Package: *Languages/Translation
PHP Version: 8.0.1 OS: Ubuntu 16.04.7 LTS
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: rdueck at mcmillan-mcgee dot com
New email:
PHP Version: OS:

 

 [2021-01-18 22:18 UTC] rdueck at mcmillan-mcgee dot com
Description:
------------
Upgrading from 7.4.14 to 8.0.1 changes the behaviour of ResourceBundle::get($index). If a non-existent $index is requested, get($index) returns null, and all subsequent calls to get() also return null, even for $index values that exist.

Test script:
---------------
<?php
file_put_contents('en.txt','en { "exists" {"found"} }');
shell_exec('genrb en.txt');
$r = new ResourceBundle('en.res', __DIR__);
$r->get('does_not_exist');
if($r->get('exists') === null) echo "Error\n";
else echo "Ok\n";
// cleanup
unlink('en.txt');
unlink('en.res');

Expected result:
----------------
Ok

Actual result:
--------------
Error

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-01-19 13:51 UTC] nikic@php.net
-Status: Open +Status: Verified
 [2021-01-19 14:15 UTC] nikic@php.net
-Assigned To: +Assigned To: nikic
 [2021-01-19 14:15 UTC] nikic@php.net
Okay, this is pretty subtle. The code used RESOURCEBUNDLE_METHOD_FETCH_OBJECT previously, which apparently performs an implicit reset of the error state. When the code was migrated to zend_object, that reset was lost.
 [2021-01-19 14:21 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=05d168013a2be5e85c43f0d6c92aeab899e7952b
Log: Fixed bug #80644: ResourceBundle::get() doesn't reset error state
 [2021-01-19 14:21 UTC] nikic@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 09 20:01:28 2024 UTC