|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53128 Gettext + NFS + atomic file replace = not handled
Submitted: 2010-10-21 14:11 UTC Modified: 2021-01-25 12:16 UTC
From: skygreg at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: Gettext related
PHP Version: 5.3.3 OS: Linux 2.6.35
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: skygreg at gmail dot com
New email:
PHP Version: OS:


 [2010-10-21 14:11 UTC] skygreg at gmail dot com

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/ /var/local/medias/small/data/test_gettext/en_GB/LC_MESSAGES/messages.po && mv /tmp/ /var/local/medias/small/data/test_gettext/en_GB/LC_MESSAGES/

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:
$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);
bind_textdomain_codeset('messages', 'UTF-8');
$local = setlocale ( LC_MESSAGES ,  $locale . '.utf8' );
putenv ( "LANG=" . $locale );
putenv ( "LANGUAGE=" . $locale );
$st = stat($bdpath."/".$locale."/LC_MESSAGES/");
echo date("H:i:s")." inode: ".$st[1]." mtime: ".$st[8]." text: "._("bonjour le monde")."\n";

Expected result:

Actual result:
// if I rm the .mo files, some apache2 process display :
bonjour le monde
// else, I got the old phrase :
hello world


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-01-25 12:16 UTC]
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2021-01-25 12:16 UTC]
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.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Nov 26 22:03:16 2021 UTC