php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34253 COM binary object/array issue (question marks?)
Submitted: 2005-08-25 18:31 UTC Modified: 2020-02-16 04:22 UTC
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: inny at core dot fetchnet dot org Assigned: cmb (profile)
Status: No Feedback Package: COM related
PHP Version: 5.1.0RC1 OS: Windows 2000
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: inny at core dot fetchnet dot org
New email:
PHP Version: OS:

 

 [2005-08-25 18:31 UTC] inny at core dot fetchnet dot org
Description:
------------
I was translating the following script: http://demis.inny.org/temp/wms.asp.txt
http://demis.inny.org/temp/wms.php.txt is a non-functional translation I had at that time.

If $QueryString ($_SERVER['QUERY_STRING']) contained the proper variables/values, the WMSServer would return a byte-stream/array/whatever (I'm no genius at COM and such) containing a map-image.

http://demis.inny.org/temp/wms.php.txt would return, instead of the image, 8 question marks (????????). I solved this by changing echo($content); into the following:

if (substr($contenttype, 0, 5) == 'image') {
  $image = null;
  foreach ($content As $obj) { // $obj will contain 1 byte each time, echo'ing it would print a decimal which in turn represents an ASCII value. hence chr();
    $image .= chr($obj);
  }
  echo($image);
} else {
	echo($content);
}

But this doesn't seem too resource-efficient to me (a run of foreach for every byte), and I doubt it's an intended work-around (the ?'s really got me puzzled, I'd have expected an error message).


Anyway, seeing as I needed to use chr(); with foreach, this seems related to a fixed bug #15782: http://bugs.php.net/bug.php?id=15782

Maybe you were aware of all of this.. Maybe not. Cheers.

Reproduce code:
---------------
$WMSService = new COM("DemisWMSConnect.Service");
$MapServer = $WMSService->WMS($wms);

if (!is_object($MapServer)) {
	dosomestuffand();
	die();
} else {
	$content     = new VARIANT(null);
	$contenttype = new VARIANT(null);
	$return = $MapServer->WMSRequest($QueryString, $content, $contenttype);
	header('Content-type: '.$contenttype);
	echo($content);
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-25 18:37 UTC] inny at core dot fetchnet dot org
FYI, source of a now-operational version here:

http://demis.inny.org/temp/wms_working.php.txt

Non-operational script as .phps file:

http://demis.inny.org/temp/wms.phps
 [2005-08-26 11:16 UTC] inny at core dot fetchnet dot org
I was adding support for PHP4 to the script, which made me wonder: if binary arrays are meant to be received like this, what would be the fastest way to reformat them?

	foreach ($content As $obj) {
	// or foreach($content->value As $obj) in PHP4
	  $image .= chr($obj);
	}
	echo($image);

or maybe something like

	function rchr($v, $w) {
	  $v .= chr($w);
	  return($v);
	}
	$image = array_reduce($content, rchr);
	// or $image = array_reduce($content->value, rchr); in PHP4

or something else?

Thanks.
 [2005-08-26 11:56 UTC] inny at core dot fetchnet dot org
"Amusingly" enough, the array_reduce method didn't work for PHP5. I guess that makes sense though.

-- Oh don't worry, I'm having lots of fun (on my own) in my own little thread already.
 [2005-08-26 15:01 UTC] sniper@php.net
Assigned to maintainer.

 [2006-09-04 10:51 UTC] najath at onlnet dot com
hi i am using 5.1 PHP and MYSQL

my project is to store images and retrive binary values and convert to an image format again 

i have inserted the binary values to the feild and i have retrived also but always i am getting the binarys not the image. plesae help me 


print ("<img src=". $row['bi']."/>");
 [2013-12-13 07:45 UTC] wez@php.net
-Status: Assigned +Status: Open -Assigned To: wez +Assigned To:
 [2020-02-07 08:32 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-02-07 08:32 UTC] cmb@php.net
Well, the given URLs are no longer available, and the COM object
appears to be a custom one, so I can only guess that the value in
question is a byte array (VT_ARRAY|VT_UI1), what can be confirmed
using variant_get_type().  If so, converting to string (implied by
echo) does not work and has to be worked around (see bug #41388).
 [2020-02-16 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 12:01:27 2024 UTC