php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36248 CURLOPT_HEADERFUNCTION, couldn't set the function in the class (works in 5.1)
Submitted: 2006-02-01 17:39 UTC Modified: 2007-01-12 16:38 UTC
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: Admin at relax-info dot com Assigned: iliaa
Status: Closed Package: cURL related
PHP Version: 4.4.2 OS: WIN XP SP2
Private report: No CVE-ID:
 [2006-02-01 17:39 UTC] Admin at relax-info dot com
Description:
------------
Couldn't set the name of a callback function where the callback function exists in a class, array($this, 'callback_function'). Apache die ...


Reproduce code:
---------------
class CURL
{
var $_ch;
.....
$this->_ch = curl_init();
..
curl_setopt($this->_ch, CURLOPT_HEADERFUNCTION, array($this, '_header_callback'));
..
}

Expected result:
----------------
The name of a callback function can be method of class
array($this, 'callback_function')

Actual result:
--------------
Apache die ...

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-01 17:40 UTC] Admin at relax-info dot com
Sorry, callback function example...
	function _header_callback($ch, $header)
	{
//		print_r($header);
	}
 [2006-02-01 17:43 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.


 [2006-02-01 17:55 UTC] Admin at relax-info dot com
I am truncate all comment from my class and delete other method than not assign with problem

<?php
class CURL
{
	var $url;
	var $header = false;
	var $returntransfer = false;
	var $_ch = null;

	function CURL($url = '')
	{
		$this->url = $url;
	}
	

	function init()
	{
		$this->_ch = curl_init();
		// ...
	}

	function execute()
	{
		//	defauukt setup
		curl_setopt($this->_ch, CURLOPT_URL, $this->url);
		
		// HEADER
		if ($this->header)
		{
			curl_setopt($this->_ch, CURLOPT_HEADER, true);	
			curl_setopt($this->_ch, CURLOPT_HEADERFUNCTION, array($this, '_header_callback');	
		}

		// exec
		$result = curl_exec($this->_ch);
		// ..

		return $result;	
	}
	
	function _header_callback($ch, $header)
	{
		return strlen($header);
	}
}
// EXAMPLE ---------------------
	$url = 'http://www.relax-info.com';
	
	$curl = new CURL($url);
	if ($curl->init())
	{
		$curl->returntransfer = true;
		$curl->header = true;
		
		$result = $curl->execute();
		print_r($result);
	}
	else echo $curl->get_error();
?>
 [2006-02-01 21:18 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php for Win32

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.

Works perfectly fine here.
 [2006-02-02 19:59 UTC] Admin at relax-info dot com
Ok, I then shall install MSVC6 and other debug packs.
Now I give you the reference to my class with an example.

Server: Apache/1.3.31 (Win32) PHP/4.4.2
X-Powered-By: PHP/4.4.2
Transfer-Encoding: chunked

http://relax-info.com/data/file/curl.class.php.rar - example and class

With best regards, X-MAN :)
 [2006-02-13 19:49 UTC] tony2001@php.net
Assigned to the maintainer.
 [2007-01-12 16:38 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 16 18:01:53 2014 UTC