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
 [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 30 17:01:29 2024 UTC