Use call_user_func_array() instead of call_user_func() when need to permit arg by reference

This commit is contained in:
Benjamin Renard 2017-04-28 10:22:01 +02:00
parent 8deb9a8508
commit 251cb2b0e2
7 changed files with 19 additions and 19 deletions

View file

@ -44,7 +44,7 @@ if(LSsession :: startLSsession()) {
}
if (isset($_GET['valid']) || $config['noConfirmation']) {
LStemplate :: assign('pagetitle',$title);
if (call_user_func($config['function'],$LSsearch)) {
if (call_user_func_array($config['function'],array(&$LSsearch))) {
if ($config['disableOnSuccessMsg']!=true) {
if ($config['onSuccessMsgFormat']) {
LSsession :: addInfo(getFData(__($config['onSuccessMsgFormat']),$objectname));

View file

@ -190,7 +190,7 @@ class LSattr_ldap_password extends LSattr_ldap {
return $clearPassword;
break;
case 'function':
return call_user_func($this -> config['ldap_options']['encode_function'], $this -> attribute -> ldapObject, $clearPassword);
return call_user_func_array($this -> config['ldap_options']['encode_function'], array(&$this -> attribute -> ldapObject, $clearPassword));
break;
}
LSerror :: addErrorCode('LSattr_ldap_password_01',$this -> config['ldap_options']['encode']);

View file

@ -495,7 +495,7 @@ class LSattribute {
function generateValue() {
$value=false;
if (function_exists($this -> config['generate_function'])) {
$value=call_user_func($this -> config['generate_function'],$this -> ldapObject);
$value=call_user_func_array($this -> config['generate_function'],array(&$this -> ldapObject));
}
else if (isset($this -> config['generate_value_format'])) {
$value = $this -> ldapObject -> getFData($this -> config['generate_value_format']);
@ -649,7 +649,7 @@ class LSattribute {
}
foreach($funcs as $func) {
if(function_exists($func)) {
if(!call_user_func($func, $this -> ldapObject)) {
if(!call_user_func_array($func, array(&$this -> ldapObject))) {
$return = false;
}
}
@ -666,7 +666,7 @@ class LSattribute {
$obj = new $e['class']();
if (method_exists($obj,$e['fct'])) {
try {
call_user_func(array($obj, $e['fct']), $e['params']);
call_user_func_array(array($obj, $e['fct']), array(&$e['params']));
}
catch(Exception $er) {
$return = false;
@ -686,7 +686,7 @@ class LSattribute {
else {
if (function_exists($e['fct'])) {
try {
call_user_func($e['fct'], $e['params']);
call_user_func_array($e['fct'], array(&$e['params']));
}
catch(Exception $er) {
LSdebug("Event ".$event." : Erreur durant l'execution de la function ".$e['fct']);
@ -705,7 +705,7 @@ class LSattribute {
foreach ($this -> _objectEvents[$event] as $e) {
if (method_exists($e['obj'],$e['meth'])) {
try {
call_user_func(array($e['obj'], $e['meth']),$e['params']);
call_user_func_array(array($e['obj'], $e['meth']),array(&$e['params']));
}
catch(Exception $er) {
$return = false;

View file

@ -362,7 +362,7 @@ class LSform {
foreach($this -> _rules[$element] as $rule) {
$ruleType="LSformRule_".$rule['name'];
LSsession :: loadLSclass($ruleType);
if (! call_user_func(array( $ruleType,'validate') , $value, $rule['options'], $this -> getElement($element))) {
if (! call_user_func_array(array( $ruleType,'validate') , array($value, $rule['options'], $this -> getElement($element)))) {
$retval=false;
$this -> setElementError($this -> elements[$element],$rule['options']['msg']);
}

View file

@ -43,7 +43,7 @@ class LSformRule_callable extends LSformRule {
*/
function validate($value,$option,$formElement) {
if (is_callable($option['callable'])) {
return call_user_func($option['callable'],$value,$option,$formElement);
return call_user_func_array($option['callable'],array($value,$option,&$formElement));
}
else {
LSerror :: addErrorCode('LSformRule_callable_01');

View file

@ -524,7 +524,7 @@ class LSldapObject {
// Validation par fonction externe
else if(isset($test['function'])) {
if (function_exists($test['function'])) {
if(!call_user_func($test['function'],$this)) {
if(!call_user_func_array($test['function'],array(&$this))) {
if ($LSform) $LSform -> setElementError($attr,$msg_error);
$retval = false;
}
@ -1693,7 +1693,7 @@ class LSldapObject {
}
foreach($funcs as $func) {
if(function_exists($func)) {
if(!call_user_func($func,$this)) {
if(!call_user_func_array($func,array(&$this))) {
$return = false;
LSerror :: addErrorCode('LSldapObject_07',array('func' => $func,'event' => $event));
}
@ -1713,7 +1713,7 @@ class LSldapObject {
$obj = new $e['class']();
if (method_exists($obj,$e['fct'])) {
try {
call_user_func(array($obj,$e['fct']),$e['param']);
call_user_func_array(array($obj,$e['fct']),array(&$e['param']));
}
catch(Exception $er) {
LSerror :: addErrorCode('LSldapObject_10',array('class' => $e['class'],'meth' => $e['fct'],'event' => $event));
@ -1733,7 +1733,7 @@ class LSldapObject {
else {
if (function_exists($e['fct'])) {
try {
call_user_func($e['fct'],$e['param']);
call_user_func_array($e['fct'],array(&$e['param']));
}
catch(Exception $er) {
LSerror :: addErrorCode('LSldapObject_27',array('func' => $e['fct'],'event' => $event));
@ -1753,7 +1753,7 @@ class LSldapObject {
foreach ($this -> _objectEvents[$event] as $e) {
if (method_exists($e['obj'],$e['meth'])) {
try {
call_user_func(array($e['obj'], $e['meth']),$e['param']);
call_user_func_array(array($e['obj'], $e['meth']),array(&$e['param']));
}
catch(Exception $er) {
LSerror :: addErrorCode('LSldapObject_29',array('meth' => $e['meth'],'event' => $event));

View file

@ -46,7 +46,7 @@ class LSrelation {
$objRel = new $this -> config['LSobject']();
if (isset($this -> config['list_function'])) {
if (method_exists($this -> config['LSobject'],$this -> config['list_function'])) {
return call_user_func(array($objRel, $this -> config['list_function']), $this -> obj);
return call_user_func_array(array($objRel, $this -> config['list_function']), array(&$this -> obj));
}
LSerror :: addErrorCode('LSrelations_01',array('function' => $this -> config['list_function'], 'action' => _('listing related objects'), 'relation' => $this -> relationName));
return False;
@ -69,7 +69,7 @@ class LSrelation {
$objRel = new $this -> config['LSobject']();
if (isset($this -> config['getkeyvalue_function'])) {
if (method_exists($this -> config['LSobject'],$this -> config['getkeyvalue_function'])) {
return call_user_func(array($objRel, $this -> config['getkeyvalue_function']), $this -> obj);
return call_user_func_array(array($objRel, $this -> config['getkeyvalue_function']), array(&$this -> obj));
}
LSerror :: addErrorCode('LSrelations_01',array('function' => $this -> config['getkeyvalue_function'], 'action' => _('getting key value'), 'relation' => $this -> relationName));
}
@ -115,7 +115,7 @@ class LSrelation {
public function removeRelationWithObject($objRel) {
if (isset($this -> config['remove_function'])) {
if (method_exists($this -> config['LSobject'],$this -> config['remove_function'])) {
return call_user_func(array($objRel, $this -> config['remove_function']),$this -> obj);
return call_user_func_array(array($objRel, $this -> config['remove_function']),array(&$this -> obj));
}
LSerror :: addErrorCode('LSrelations_01',array('function' => $this -> config['remove_function'], 'action' => _('deleting'), 'relation' => $this -> relationName));
return False;
@ -132,7 +132,7 @@ class LSrelation {
public function renameRelationWithObject($objRel,$oldKeyValue) {
if (isset($this -> config['rename_function'])) {
if (method_exists($objRel,$this -> config['rename_function'])) {
return call_user_func(array($objRel, $this -> config['rename_function']), $this -> obj, $oldKeyValue);
return call_user_func_array(array($objRel, $this -> config['rename_function']), array(&$this -> obj, $oldKeyValue));
}
LSerror :: addErrorCode('LSrelations_01',array('function' => $this -> config['rename_function'], 'action' => _('renaming'), 'relation' => $this -> relationName));
return False;
@ -151,7 +151,7 @@ class LSrelation {
$objRel = new $this -> config['LSobject']();
if (isset($this -> config['update_function'])) {
if (method_exists($objRel,$this -> config['update_function'])) {
return call_user_func(array($objRel, $this -> config['update_function']), $this -> obj, $listDns);
return call_user_func_array(array($objRel, $this -> config['update_function']), array(&$this -> obj, $listDns));
}
LSerror :: addErrorCode('LSrelations_01',array('function' => $this -> config['update_function'], 'action' => _('updating'), 'relation' => $this -> relationName));
}