Skip to content

Commit

Permalink
Added clone function to get around the differences in object handling…
Browse files Browse the repository at this point in the history
… between php4 and php5.
  • Loading branch information
gustav_delius committed Mar 16, 2005
1 parent 55ab4eb commit f52d48d
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion lib/moodlelib.php
Expand Up @@ -2197,7 +2197,7 @@ function authenticate_user_login($username, $password) {

} else {
add_to_log(0, 'login', 'error', $_SERVER['HTTP_REFERER'], $username);
error_log('[client '.$_SERVER['REMOTE_ADDR']."] $CFG->wwwroot Failed Login: $username ".$_SERVER['HTTP_USER_AGENT']);
error_log('[client '.$_SERVER['REMOTE_ADDR']."] $CFG->wwwroot Failed Login: $username ".$_SERVER['HTTP_USER_AGENT']);
return false;
}
}
Expand Down Expand Up @@ -5542,6 +5542,27 @@ function html_entity_decode($string) {
}
}

/**
* The clone keyword is only supported from PHP 5 onwards.
* The behaviour of $obj2 = $obj1 differs fundamentally
* between PHP 4 and PHP 5. In PHP 4 a copy of $obj1 was
* created, in PHP 5 $obj1 is referenced. To create a copy
* in PHP 5 the clone keyword was introduced. This function
* simulates this behaviour for PHP < 5.0.0.
* See also: http://mjtsai.com/blog/2004/07/15/php-5-object-references/
*
* @param object $obj
* @return object
*/
if(!check_php_version('5.0.0')) {
// the eval is needed to prevent PHP 5 from getting a parse error!
eval('
function clone($obj) {
return $obj;
}
');
}

/**
* If new messages are waiting for the current user, then return
* Javascript code to create a popup window
Expand Down

0 comments on commit f52d48d

Please sign in to comment.