php-windows Digest 17 Aug 2013 20:11:10 -0000 Issue 4139
Topics (messages 31125 through 31132):
Next question about data output...<smile>
31125 by: Jacob Kruger
31126 by: Jacob Kruger
31129 by: Jacob Kruger
31130 by: Jacob Kruger
31131 by: Jacob Kruger
Re: php can't resolve 8.3 paths to unicode filenames, is that expected ?
31127 by: R. S.
31132 by: Lester Caine
Re: CLI Crash Bug
31128 by: Jan Ehrhardt
Administrivia:
To subscribe to the digest, e-mail:
php-windows-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-windows-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-wind...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On my development, windows machine, the memory_limit iniValue is set to 128M,
and on the production server - think linux box, it's set to 1280M, but, the bit
of script to render an image from database as image resource to browser, works
fine on my machine, but, on server, the following error occurs:
PHP Fatal error: Allowed memory size of 1342177280 bytes exhausted (tried to
allocate 4294967296
According to server log, it seems to be happening on the line where the
mysqli_statement tries to execute the query to retrieve a longblob value of
2.1Mb, but anyway.
I am making sure try to destroy any image resources, etc., am closing statement
object after executing it, etc. - and there aren't really any recursive loops
being executed, but, just a page instantiating an instance of a wrapper class,
which then refers to the imageManipulation object, to then pull the images
data out of the DB - thoughts?
TIA
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
--- End Message ---
--- Begin Message ---
Production server says following about version:
PHP Version 5.3.3-7+squeeze16
My local machine is running on XAMPP, with PHP 5.3.5.
Let me try out the memory_get_usage() [1] as well to see if can find out how
much memory is being used up, when, and by what part of process.
FWIW, here are the 3 pieces of exact code:
//requesting page:
if (isset($_GET["id"])) {
require("../imageManipulation.php");
require("../template.php");
$templ = new template ($_GET["id"]);
$templ->renderTemplate();
}//end of checking for querystring ID
exit;
//renderTemplate function in template class, inside template.php
public function renderTemplate($sDisposition="inline") {
if ($this->iID>0) {
$im = new image_manipulation;
$im->mysqliObj = $this->mysqliObj;
$imgOut = $im->dbGetImage("tbl_budget_templates", "b_image", $this->iID);
if (!(is_null($imgOut))) {
imagepng($imgOut, $this->sTempPath . "temp.png");
$sSize = strval(filesize($this->sTempPath . "temp.png"));
unlink($this->sTempPath . "temp.png");
header('HTTP/1.1 200 OK', True, 200);
header('Content-Type: image/png');
header('Content-Disposition: ' . $sDisposition . ';
filename="template.png"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . $sSize);
imagepng($imgOut);
imagedestroy($imgOut);
} else {
echo NULL;
}//end of checking if $imgOut != NULL
}//end of checking if iID>0
}//end of renderTemplate function
//and, dbGetImage function from image_manipulation
class-imageManipulation.php
function dbGetImage($sTableName, $sField, $iID) {
if (!is_null($this->mysqliObj)) {
$sSQL = sprintf("select %s from %s where id = %s;", $sField, $sTableName,
$iID);
$stmnt = $this->mysqliObj->prepare($sSQL);
$stmnt->execute(); //think this is command/action triggering issue
$stmnt->bind_result($bOut);
$stmnt->fetch();
$stmnt->close();
$imgOut = imagecreatefromstring($bOut);
unset($bOut);
return $imgOut;
imagedestroy($imgOut);
} else {
return NULL;
}
}//end of dbGetImage function
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
----- Original Message -----
From: "Sascha Meyer" <harlequ...@gmx.de>
To: "Jacob Kruger" <ja...@blindza.co.za>
Sent: Friday, August 16, 2013 8:57 AM
Subject: Aw: [PHP-WIN] Next question about data output...<smile>
Good morning Jacob,
could you check if memory has been eaten up before the mysqli_statement is
executed? memory_get_usage() [1] could help in that case. Are you using
different PHP versions on your local dev machine and on the production
server?
Best regards,
Sascha
[1] http://php.net/manual/en/function.memory-get-usage.php
Gesendet: Freitag, 16. August 2013 um 08:42 Uhr
Von: "Jacob Kruger" <ja...@blindza.co.za>
An: php-wind...@lists.php.net
Betreff: [PHP-WIN] Next question about data output...<smile>
On my development, windows machine, the memory_limit iniValue is set to
128M, and on the production server - think linux box, it's set to 1280M,
but, the bit of script to render an image from database as image resource
to browser, works fine on my machine, but, on server, the following error
occurs:
PHP Fatal error: Allowed memory size of 1342177280 bytes exhausted (tried
to allocate 4294967296
According to server log, it seems to be happening on the line where the
mysqli_statement tries to execute the query to retrieve a longblob value
of 2.1Mb, but anyway.
I am making sure try to destroy any image resources, etc., am closing
statement object after executing it, etc. - and there aren't really any
recursive loops being executed, but, just a page instantiating an
instance of a wrapper class, which then refers to the imageManipulation
object, to then pull the images data out of the DB - thoughts?
TIA
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
--- End Message ---
--- Begin Message ---
OK, seems what's causing issue is imagecreatefromstring(), since, directly
after retrieving longblob data from database, memory usage is:
3402136 = 3.*Mb
and, then immediately after that calling:
$imgOut = imagecreatefromstring($bOut);
and, return that $imgOut variable to calling function, before do anything
else, memory usage:
44063856 - 44Mb+
And, this is on my windows development machine, so seems issue is with
operations, and not machine specific, although not sure why it's working on
this machine, and not on production server.
Either way, think will, for now, switch image output rendering back to
simpler method that worked before, instead of using actual mysqli_statement,
and see if works as such - might also put the memory usage 'logging' in
there, to actually compare them, or something.
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
----- Original Message -----
From: "Sascha Meyer" <harlequ...@gmx.de>
To: "Jacob Kruger" <ja...@blindza.co.za>
Sent: Friday, August 16, 2013 8:57 AM
Subject: Aw: [PHP-WIN] Next question about data output...<smile>
Good morning Jacob,
could you check if memory has been eaten up before the mysqli_statement is
executed? memory_get_usage() [1] could help in that case. Are you using
different PHP versions on your local dev machine and on the production
server?
Best regards,
Sascha
[1] http://php.net/manual/en/function.memory-get-usage.php
Gesendet: Freitag, 16. August 2013 um 08:42 Uhr
Von: "Jacob Kruger" <ja...@blindza.co.za>
An: php-wind...@lists.php.net
Betreff: [PHP-WIN] Next question about data output...<smile>
On my development, windows machine, the memory_limit iniValue is set to
128M, and on the production server - think linux box, it's set to 1280M,
but, the bit of script to render an image from database as image resource
to browser, works fine on my machine, but, on server, the following error
occurs:
PHP Fatal error: Allowed memory size of 1342177280 bytes exhausted (tried
to allocate 4294967296
According to server log, it seems to be happening on the line where the
mysqli_statement tries to execute the query to retrieve a longblob value
of 2.1Mb, but anyway.
I am making sure try to destroy any image resources, etc., am closing
statement object after executing it, etc. - and there aren't really any
recursive loops being executed, but, just a page instantiating an
instance of a wrapper class, which then refers to the imageManipulation
object, to then pull the images data out of the DB - thoughts?
TIA
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
--- End Message ---
--- Begin Message ---
If I sort of combine all the relevant code - since it's currently a page
instantiating a classe called template, which then calls a function from
another sort of wrapperr class, it's effectively the following - will add
comments in to show where it might be changing context slightly - and, below
all of this, will include a dropbox link to 3 actual files themselves:
//start code - in template_image.php webpage
if (isset($_GET["id"])) {
//following line includes image_manipulation class code
require("../imageManipulation.php");
//and following line includes template class code
require("../template.php");
$templ = new template ($_GET["id"]);
$templ->renderTemplate();
//next piece of code, inside template class
//following comes out of renderTemplate function
if ($this->iID>0) { //$this->iID gets set during __construct
//this instantiates a reference to other wrapper class
$im = new image_manipulation;
$im->mysqliObj = $this->mysqliObj; //$this->mysqliObj is an instance of
mysqli
$imgOut = $im->dbGetImage("tbl_budget_templates", "b_image", $this->iID);
//here's the code inside the dbGetImage function inside the
image_manipulation class
if (!is_null($this->mysqliObj)) {
$sSQL = sprintf("select %s from %s where id = %s;", $sField, $sTableName,
$iID);
$stmnt = $this->mysqliObj->prepare($sSQL);
echo "just before execution: " . memory_get_usage() . "<br />\n";
$stmnt->execute();
echo "after execution: " . memory_get_usage() . "<br />\n";
$stmnt->bind_result($bOut);
$stmnt->fetch();
$stmnt->close();
echo "after execute and fetch: " . memory_get_usage() . "<br />\n";
//here's where the memory in use had jumped to over 4Mb
$imgOut = imagecreatefromstring($bOut);
unset($bOut);
return $imgOut;
imagedestroy($imgOut);
} else {
return NULL;
}
//back to code inside template class
echo "after retrieving img resource to template: " . memory_get_usage() .
"<br />\n";
if (!(is_null($imgOut))) {
imagepng($imgOut, $this->sTempPath . "temp.png");
$sSize = strval(filesize($this->sTempPath . "temp.png"));
unlink($this->sTempPath . "temp.png");
echo "after creating and deleting image file: " . memory_get_usage() . "<br
/>\n";
//commented out following rendering lines while testing memory usage
//header('HTTP/1.1 200 OK', True, 200);
//header('Content-Type: image/png');
//header('Content-Disposition: ' . $sDisposition . ';
filename="template.png"');
//header('Content-Transfer-Encoding: binary');
//header('Content-Length: ' . $sSize);
//imagepng($imgOut);
return memory_get_usage();
imagedestroy($imgOut);
} else {
echo NULL;
}//end of checking if $imgOut != NULL
}//end of checking if iID>0
//back to code in template_image.php
}//end of checking for querystring ID
//end of code
Here's the zip file with those three files in it, and, FWIW, image_template
is from a subfolder, called admin, and in the root folder of the site, along
with the two other class files, among various other pages, there's another
subfolder, called tempimg, to store temporary image output files in - it has
read/write permissions, but, no execute - just on principle:
https://dl.dropboxusercontent.com/u/13327195/tempCode.zip
And, not totally relevant, but, what used before to just render output
images was following - was the renderTemplate function mentioned above that
did it all itself - and it seemed to work alright, but, hadn't actually, as
of yet, stored any of the really large images in database on production
server at that stage:
public function renderTemplate($sDisposition="inline") {
if ($this->iID>0) {
$sSQL = sprintf("select b_image from tbl_budget_templates where id = %s and
b_image IS NOT NULL;", $this->iID);
$res = $this->mysqliObj->query($sSQL);
if ($res->num_rows>0) {
$row = $res->fetch_assoc();
header('HTTP/1.1 200 OK', True, 200);
header('Content-Type: image/png');
header('Content-Disposition: ' . $sDisposition . ';
filename="template.png"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . strlen($row["b_image"]));
imagepng(imagecreatefromstring($row["b_image"]));
} else {
echo "no record retrieved - " . $sSQL;
}
} else {
echo NULL;
}//end of checking if iID>0
}//end of renderTemplate function
Thanks
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
----- Original Message -----
From: "Sascha Meyer" <harlequ...@gmx.de>
To: "Jacob Kruger" <ja...@blindza.co.za>
Sent: Friday, August 16, 2013 1:39 PM
Subject: Aw: Re: [PHP-WIN] Next question about data output...<smile>
Jacob,
could you post the part of your code where the error occurs? Perhaps we
can optimize some of the code to reduce the amount of memory used by the
script.
Cheers,
Sascha
Gesendet: Freitag, 16. August 2013 um 12:15 Uhr
Von: "Jacob Kruger" <ja...@blindza.co.za>
An: "Sascha Meyer" <harlequ...@gmx.de>
Cc: php-wind...@lists.php.net
Betreff: Re: [PHP-WIN] Next question about data output...<smile>
OK, seems what's causing issue is imagecreatefromstring(), since,
directly
after retrieving longblob data from database, memory usage is:
3402136 = 3.*Mb
and, then immediately after that calling:
$imgOut = imagecreatefromstring($bOut);
and, return that $imgOut variable to calling function, before do anything
else, memory usage:
44063856 - 44Mb+
And, this is on my windows development machine, so seems issue is with
operations, and not machine specific, although not sure why it's working
on
this machine, and not on production server.
Either way, think will, for now, switch image output rendering back to
simpler method that worked before, instead of using actual
mysqli_statement,
and see if works as such - might also put the memory usage 'logging' in
there, to actually compare them, or something.
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
----- Original Message -----
From: "Sascha Meyer" <harlequ...@gmx.de>
To: "Jacob Kruger" <ja...@blindza.co.za>
Sent: Friday, August 16, 2013 8:57 AM
Subject: Aw: [PHP-WIN] Next question about data output...<smile>
> Good morning Jacob,
>
> could you check if memory has been eaten up before the mysqli_statement
> is
> executed? memory_get_usage() [1] could help in that case. Are you using
> different PHP versions on your local dev machine and on the production
> server?
>
> Best regards,
>
> Sascha
>
> [1] http://php.net/manual/en/function.memory-get-usage.php
>
>> Gesendet: Freitag, 16. August 2013 um 08:42 Uhr
>> Von: "Jacob Kruger" <ja...@blindza.co.za>
>> An: php-wind...@lists.php.net
>> Betreff: [PHP-WIN] Next question about data output...<smile>
>>
>> On my development, windows machine, the memory_limit iniValue is set
>> to
>> 128M, and on the production server - think linux box, it's set to
>> 1280M,
>> but, the bit of script to render an image from database as image
>> resource
>> to browser, works fine on my machine, but, on server, the following
>> error
>> occurs:
>> PHP Fatal error: Allowed memory size of 1342177280 bytes exhausted
>> (tried
>> to allocate 4294967296
>>
>> According to server log, it seems to be happening on the line where
>> the
>> mysqli_statement tries to execute the query to retrieve a longblob
>> value
>> of 2.1Mb, but anyway.
>>
>> I am making sure try to destroy any image resources, etc., am closing
>> statement object after executing it, etc. - and there aren't really
>> any
>> recursive loops being executed, but, just a page instantiating an
>> instance of a wrapper class, which then refers to the
>> imageManipulation
>> object, to then pull the images data out of the DB - thoughts?
>>
>> TIA
>>
>> Jacob Kruger
>> Blind Biker
>> Skype: BlindZA
>> '...fate had broken his body, but not his spirit...'
>>
>
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
For example, if now roll back to that older version of direct call to
database, just using mysqli's sort of direct query, instead of using the
mysqli_statement object, it does seem to try to render image, without
generating direct errors, FWIW - bit slow - and, trying to explain to sort
of site owner why he should use either smaller, or lower DPI images - but,
seems to work as such - even on production server, FWIW.
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
----- Original Message -----
From: "Sascha Meyer" <harlequ...@gmx.de>
To: "Jacob Kruger" <ja...@blindza.co.za>
Sent: Friday, August 16, 2013 1:39 PM
Subject: Aw: Re: [PHP-WIN] Next question about data output...<smile>
Jacob,
could you post the part of your code where the error occurs? Perhaps we
can optimize some of the code to reduce the amount of memory used by the
script.
Cheers,
Sascha
Gesendet: Freitag, 16. August 2013 um 12:15 Uhr
Von: "Jacob Kruger" <ja...@blindza.co.za>
An: "Sascha Meyer" <harlequ...@gmx.de>
Cc: php-wind...@lists.php.net
Betreff: Re: [PHP-WIN] Next question about data output...<smile>
OK, seems what's causing issue is imagecreatefromstring(), since,
directly
after retrieving longblob data from database, memory usage is:
3402136 = 3.*Mb
and, then immediately after that calling:
$imgOut = imagecreatefromstring($bOut);
and, return that $imgOut variable to calling function, before do anything
else, memory usage:
44063856 - 44Mb+
And, this is on my windows development machine, so seems issue is with
operations, and not machine specific, although not sure why it's working
on
this machine, and not on production server.
Either way, think will, for now, switch image output rendering back to
simpler method that worked before, instead of using actual
mysqli_statement,
and see if works as such - might also put the memory usage 'logging' in
there, to actually compare them, or something.
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
----- Original Message -----
From: "Sascha Meyer" <harlequ...@gmx.de>
To: "Jacob Kruger" <ja...@blindza.co.za>
Sent: Friday, August 16, 2013 8:57 AM
Subject: Aw: [PHP-WIN] Next question about data output...<smile>
> Good morning Jacob,
>
> could you check if memory has been eaten up before the mysqli_statement
> is
> executed? memory_get_usage() [1] could help in that case. Are you using
> different PHP versions on your local dev machine and on the production
> server?
>
> Best regards,
>
> Sascha
>
> [1] http://php.net/manual/en/function.memory-get-usage.php
>
>> Gesendet: Freitag, 16. August 2013 um 08:42 Uhr
>> Von: "Jacob Kruger" <ja...@blindza.co.za>
>> An: php-wind...@lists.php.net
>> Betreff: [PHP-WIN] Next question about data output...<smile>
>>
>> On my development, windows machine, the memory_limit iniValue is set
>> to
>> 128M, and on the production server - think linux box, it's set to
>> 1280M,
>> but, the bit of script to render an image from database as image
>> resource
>> to browser, works fine on my machine, but, on server, the following
>> error
>> occurs:
>> PHP Fatal error: Allowed memory size of 1342177280 bytes exhausted
>> (tried
>> to allocate 4294967296
>>
>> According to server log, it seems to be happening on the line where
>> the
>> mysqli_statement tries to execute the query to retrieve a longblob
>> value
>> of 2.1Mb, but anyway.
>>
>> I am making sure try to destroy any image resources, etc., am closing
>> statement object after executing it, etc. - and there aren't really
>> any
>> recursive loops being executed, but, just a page instantiating an
>> instance of a wrapper class, which then refers to the
>> imageManipulation
>> object, to then pull the images data out of the DB - thoughts?
>>
>> TIA
>>
>> Jacob Kruger
>> Blind Biker
>> Skype: BlindZA
>> '...fate had broken his body, but not his spirit...'
>>
>
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hello Pierre,
Friday, August 16, 2013, 5:38:01 AM, you wrote:
> and 'TESTUN~1.PHP' has unicode, created using CreateFileW with
> 'testunicode-ßäü123-öâ.php' as path. Fetch the 8.3 path and use it to
> open the file using php, works. In other words. exactly what your COM
> script does. Now, why you come to the conclusion that PHP can't open
> 8.3 path is a misery to me right now. It can and without issue.
It still seems you didn't read my examples, but this time your fresh mind
actually helped narrowing the problem and thanks
for that !
Indeed 'testunicode-ßäü123-öâ.php' works without
any issue. It seems that only some character ranges
are making php unable to get to the file, like russian or greek.
if you make files like:
testunicode-Ελλάδα or testunicode-Россия
Then php can't get handle to these files with errors like:
Warning: fopen(C:\TESTUN~3.PHP): failed to open stream: Invalid argument
in C:\test.php on line 7
And I say it again, all software I know doesn't have problem with greek and
russian letter in file name. All.
So the problem is even stranger. How the php filesystem function is ever
supposed to
know that the path contain unicode letter since it was given the shorth path.
And how is that 16b apps aren't making a fuss about it and supposedly also not
knowing unicode PHP does ?
It really looks like someone tried to implement unicode filename handling in PHP
but stopped in middle.
--- End Message ---
--- Begin Message ---
R. S. wrote:
if you make files like:
testunicode-Ελλάδα or testunicode-Россия
Then php can't get handle to these files with errors like:
RS ... Just out of curiosity does the problem ranges of alphabets fall outside
of the limited 'UTF16' range that M$ uses for 'wide strings'. I'm busy out at an
exhibition this weekend so only have limited access to my database, but I do
seem to recall that since wide strings are only 16 bit based, any character area
going into the 24bit region (3 byte) is not supported.
--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
--- End Message ---
--- Begin Message ---
Eric Stenson in php.windows (Thu, 25 Jul 2013 18:35:25 +0000):
>I've filed bug https://bugs.php.net/bug.php?id=65338 to track this
>issue. The root cause of the AV is when more than one module hooks the
>interned strings, a "wrong" value will be left in
>CG(interned_strings_start), which the Zend core thinks contains the
>value that it alloc'd during zend_interned_strings_init().
Later today PHP 5.5.2 will be released wih the bug fix. My builds are
already available at http://www.apachelounge.com/viewtopic.php?t=5520
Jan
--- End Message ---