php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #53251
Patch fix_broken_bindtextdomain revision 2010-11-26 17:09 UTC by greno at verizon dot net
Patch Test_if_NULL_or_empty revision 2010-11-24 22:38 UTC by pajoye@php.net
Patch gettext.patch revision 2010-11-07 11:49 UTC by jeanseb at au-fil-du dot net
revision 2010-11-07 11:10 UTC by jeanseb at au-fil-du dot net

Patch gettext.patch for Gettext related Bug #53251

Patch version 2010-11-07 11:49 UTC

Return to Bug #53251 | Download this patch
This patch renders other patches obsolete

Obsolete patches:

Patch Revisions:

Developer: jeanseb@au-fil-du.net

Index: ext/gettext/tests/gettext_bindtextdomain-nulldir-alreadyset.phpt
===================================================================
--- ext/gettext/tests/gettext_bindtextdomain-nulldir-alreadyset.phpt	(révision 0)
+++ ext/gettext/tests/gettext_bindtextdomain-nulldir-alreadyset.phpt	(révision 0)
@@ -0,0 +1,18 @@
+--TEST--
+Test if bindtextdomain() return the previously set base directory for domain when dir is null.
+--SKIPIF--
+<?php
+if (!extension_loaded("gettext")) {
+    die("skip gettext extension is not loaded.\n");
+}
+--FILE--
+<?php
+chdir(dirname(__FILE__));
+$localeDir = dirname(__FILE__) . '/locale/';
+$domain1 = bindtextdomain('some-domain', $localeDir);
+$domain2 = bindtextdomain('some-domain', NULL);
+var_dump($domain1 == $domain2);
+--EXPECTF--
+bool(true)
+--CREDITS--
+Jean-Sébastien HEDDE <jeanseb@au-fil-du.net>
Index: ext/gettext/tests/gettext_bindtextdomain-nulldir.phpt
===================================================================
--- ext/gettext/tests/gettext_bindtextdomain-nulldir.phpt	(révision 0)
+++ ext/gettext/tests/gettext_bindtextdomain-nulldir.phpt	(révision 0)
@@ -0,0 +1,16 @@
+--TEST--
+Test if bindtextdomain() return the CWD when domain is not previously and dir is null.
+--SKIPIF--
+<?php
+if (!extension_loaded("gettext")) {
+    die("skip gettext extension is not loaded.\n");
+}
+--FILE--
+<?php
+chdir(dirname(__FILE__));
+$domain = bindtextdomain('some-domain', NULL);
+var_dump($domain == getcwd());
+--EXPECTF--
+bool(true)
+--CREDITS--
+Jean-Sébastien HEDDE <jeanseb@au-fil-du.net>
Index: ext/gettext/gettext.c
===================================================================
--- ext/gettext/gettext.c	(révision 305149)
+++ ext/gettext/gettext.c	(copie de travail)
@@ -264,11 +264,11 @@
 		if (!VCWD_REALPATH(dir, dir_name)) {
 			RETURN_FALSE;
 		}
-	} else if (!VCWD_GETCWD(dir_name, MAXPATHLEN)) {
-		RETURN_FALSE;
+    	retval = bindtextdomain(domain, dir_name);
+	} else {
+	    retval = bindtextdomain(domain, NULL);
 	}
 
-	retval = bindtextdomain(domain, dir_name);
 
 	RETURN_STRING(retval, 1);
 }
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 03 10:01:27 2024 UTC