Bug #53128 [Opn->Nab]: Gettext + NFS + atomic file replace = not handled
| From: | cmb@php.net | Date: | Mon, 25 Jan 2021 12:16:37 +0000 |
| Subject: | Bug #53128 [Opn->Nab]: Gettext + NFS + atomic file replace = not handled | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-231748@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=53128&edit=1
ID: 53128
Updated by: cmb@php.net
Reported by: skygreg at gmail dot com
Summary: Gettext + NFS + atomic file replace = not handled
-Status: Open
+Status: Not a bug
Type: Bug
Package: Gettext related
Operating System: Linux 2.6.35
PHP Version: 5.3.3
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
PHP does not reset libintl on request shutdown (besides that, to
my knowledge, that is not even possible, it would be bad for
production). That implies that translations may be cached by
libintl, and these translations may be returned on the next
request. If in some cases changed translations are read, but not
in others, that is not a PHP issue, but rather an upstream issue,
if at all.
Previous Comments:
------------------------------------------------------------------------
[2021-01-25 12:04:29] cmb@php.net
Related To: Bug #53986
------------------------------------------------------------------------
[2010-10-21 14:11:17] skygreg at gmail dot com
Description:
------------
Hi,
I'm facing a bug related to Gettext, Apache2 and mod_php, a NFS mount point and atomic .mo file
creation.
This problem doesn't occur on local file system, or while overwriting .mo files.
How to reproduce : put your gettext files (.mo) on a NFS share, change the translated phrase and
format them using a temporary file, to be an atomic change :
msgfmt -o /tmp/messages.mo /var/local/medias/small/data/test_gettext/en_GB/LC_MESSAGES/messages.po
&& mv /tmp/messages.mo
/var/local/medias/small/data/test_gettext/en_GB/LC_MESSAGES/messages.mo
I have to use atomic change, cause it is a high loaded server and if I didn't do that, the new
.mo file is partially read and cached, so I got partially translated phrases.
Test script:
---------------
<?php
$locale = 'en_GB';
$langue = substr($_GET['locale'], 0, 2);
//$bdpath = dirname($_SERVER['SCRIPT_FILENAME']);
$bdpath = '/var/local/medias/small/data/test_gettext'; // NFS mount point
bindtextdomain('messages', $bdpath);
textdomain('messages');
bind_textdomain_codeset('messages', 'UTF-8');
$local = setlocale ( LC_MESSAGES , $locale . '.utf8' );
putenv ( "LANG=" . $locale );
putenv ( "LANGUAGE=" . $locale );
$st = stat($bdpath."/".$locale."/LC_MESSAGES/messages.mo");
echo date("H:i:s")." inode: ".$st[1]." mtime: ".$st[8]." text:
"._("bonjour le monde")."\n";
Expected result:
----------------
HELLO WORLD
Actual result:
--------------
// if I rm the .mo files, some apache2 process display :
bonjour le monde
// else, I got the old phrase :
hello world
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=53128&edit=1