<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet href="http://bugs.horde.org/themes/feed-rss.xsl" type="text/xsl"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
 <channel>
  <title>File/PDF.php - Bug since PHP 4.3.10 with certain locales</title>
  <pubDate>Sun, 07 Sep 2008 16:41:43 -0400</pubDate>
  <link>http://bugs.horde.org/ticket/4094</link>
  <atom:link rel="self" type="application/rss+xml" title="File/PDF.php - Bug since PHP 4.3.10 with certain locales" href="http://bugs.horde.org/ticket/4094/rss" />
  <description>File/PDF.php - Bug since PHP 4.3.10 with certain locales</description>

  
  
  <item>
   <title>I really got angry about this one (angry about PHP - not Hor</title>
   <description>I really got angry about this one (angry about PHP - not Horde):

PHP's Changelog for 4.3.10 contains a little note about &quot;Improved number
handling on non-English locales.&quot;

 -&gt; http://de.php.net/release_4_3_10.php

A small example is probably better than lots of words, so have a look at
this small piece of code:

  &lt;?php
  $float = 4.12;
  printf('%.2f &lt;=&gt; %.2F', $float, $float);
  setlocale(LC_ALL, 'de_DE.UTF-8');
  echo &quot;\n&quot;;
  printf('%.2f &lt;=&gt; %.2F', $float, $float);
  ?&gt;

And now have a look at it's output:

  4.12 &lt;=&gt; 4.12
  4,12 &lt;=&gt; 4.12

I really couldn't believe that this guys are able to do such intrusive changes
from one minor version to the next one... PHP is #*%#$~*!!!

It took me a lot of debugging to find out why File_PDF works in a stand-
alone script (without horde) and created &quot;illegal&quot; PDF files when called
from a Horde application.

I attached a little patch containing all the %f -&gt; %F replacements and also
other two not so important fixes:

- use of undefined $style in addPage()
- &quot;if ($font_family)&quot; -&gt; &quot;if (isset($font_family))&quot; - There should probably
   always be a font_family, so the appropiate NOTICE might never happen;
   but as while debugging I've seen it once I changed also this one

Regards,
Thomas Gelf</description>
   <pubDate>Thu, 29 Jun 2006 14:34:21 -0400</pubDate>
   <link>http://bugs.horde.org/ticket/4094#t21521</link>
  </item>
  <item>
   <title>This is no viable solution unfortunately. Because not only t</title>
   <description>This is no viable solution unfortunately. Because not only the behaviour of sprintf() has changed, but the %F type specifier has only been added with PHP 4.3.10. But Horde needs to work with PHP 4.3, File_PDF even with 4.2.</description>
   <pubDate>Mon, 03 Jul 2006 13:03:20 -0400</pubDate>
   <link>http://bugs.horde.org/ticket/4094#t21626</link>
  </item>
  <item>
   <title>You're right :-( They really did a GREAT job *grrrr*

So I</title>
   <description>You're right :-( They really did a GREAT job *grrrr*

So I would consider to either return an instance of one of two distinct
classes (PHP &gt;=4.3.10+ &amp; PHP5 vs PHP &lt;4.3.9) or to otherwise define
a FLOAT_TYPE constant (= $version_old ? 'f' : 'F') to be used in all the
sprintf strings.

Both are really ugly solutions - as too often with PHP :-(

I personally don't care about PHP &lt; 4.3.10 as I'm fortunately doing most
of my work on 5.1.x - but you're absolutely right, File_PDF has to do it's
work also for older PHP versions.

Do you consider one of my above suggestions viable?

Cheers,
Thomas Gelf</description>
   <pubDate>Mon, 03 Jul 2006 13:41:26 -0400</pubDate>
   <link>http://bugs.horde.org/ticket/4094#t21627</link>
  </item>
  <item>
   <title>A 3rd alternative would be to set the locale to en_US during</title>
   <description>A 3rd alternative would be to set the locale to en_US during the the sprintf() calls, but that would mean a lot of locale switching back and forth inside the methods. Not less ugly either.
A 4th would be to use a class method sprintf() that replaces /%\.\df/ with F if necessary.

I think the constant is the best solution, it has to be prefixed though, e.g. FILE_PDF_FLOAT, but that would make a lot of ugly code. 4) is probably the most elegant solution.</description>
   <pubDate>Wed, 05 Jul 2006 07:23:57 -0400</pubDate>
   <link>http://bugs.horde.org/ticket/4094#t21679</link>
  </item>
  <item>
   <title>Are you going to update your patch?</title>
   <description>Are you going to update your patch?</description>
   <pubDate>Fri, 04 Aug 2006 18:13:50 -0400</pubDate>
   <link>http://bugs.horde.org/ticket/4094#t22692</link>
  </item>
  <item>
   <title>Thomas, 

Thank you very, very much for this patch! It hel</title>
   <description>Thomas, 

Thank you very, very much for this patch! It helped me fix this difficult problem...

Mattias
</description>
   <pubDate>Tue, 10 Apr 2007 20:09:28 -0400</pubDate>
   <link>http://bugs.horde.org/ticket/4094#t31396</link>
  </item>
  <item>
   <title>Updated as suggested. Looks ugly but should be easy to remov</title>
   <description>Updated as suggested. Looks ugly but should be easy to remove once PHP &lt; 4.3.10 is not being supported anymore.</description>
   <pubDate>Wed, 12 Sep 2007 14:56:23 -0400</pubDate>
   <link>http://bugs.horde.org/ticket/4094#t36863</link>
  </item>
  <item>
   <title>Committed, thanks.</title>
   <description>Committed, thanks.</description>
   <pubDate>Fri, 14 Sep 2007 05:40:14 -0400</pubDate>
   <link>http://bugs.horde.org/ticket/4094#t36899</link>
  </item>
  

 </channel>
</rss>
