php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4120 Method calls fail using -e command line option
Submitted: 2000-04-12 18:31 UTC Modified: 2000-07-04 21:16 UTC
From: Mark_Dixon at teamstudio dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0 Release Candidate 1 OS: NT
Private report: No CVE-ID: None
 [2000-04-12 18:31 UTC] Mark_Dixon at teamstudio dot com
Sample script, saved as class.php

<?php
class MyClass { 
  function myFunc( $arg ){ 
    echo $arg;
  } 
} 

$obj = new MyClass;  
$obj -> myFunc( "Hello, world" );  
?>

Running 'php class.php' works, 'php -e class.php' fails with 'Call to undefined function: ()'

The problem is the additional ZEND_EXT_FCALL_BEGIN op which gets in the way in do_begin_dynamic_function_call.  I'd humbly suggest modifying do_extended_fcall_begin to something like

void do_extended_fcall_begin(CLS_D)
{
	zend_op *opline;
	int last_op_number = get_next_op_number(CG(active_op_array))-1;
	
	if (!CG(extended_info)) {
		return;
	}
	
	opline = get_next_op(CG(active_op_array) CLS_CC);

	//	If the last instruction is ZEND_FETCH_OBJ_R then it's about to be converted to a
	//	ZEND_INIT_FCALL_BY_NAME in do_begin_dynamic_function_call.  So we need to slide the FETCH_OBJ_R
	//	up one and insert the EXT_FCALL_BEGIN before it.
	if (last_op_number>=0 && CG(active_op_array)->opcodes[last_op_number].opcode == ZEND_FETCH_OBJ_R) {
		memcpy( opline, &CG(active_op_array)->opcodes[last_op_number], sizeof( zend_op ) );
		opline = &CG(active_op_array)->opcodes[ last_op_number ];
	}

	opline->opcode = ZEND_EXT_FCALL_BEGIN;
	SET_UNUSED(opline->op1);
	SET_UNUSED(opline->op2);
}

Regards
Mark

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-04 21:16 UTC] andi at cvs dot php dot net
Fixed! Thanks.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 24 12:01:31 2024 UTC