Permalink
Browse files

Merge branch 'w48_MDL-30480_m19_dmlobjects' of git://github.com/skoda…

…k/moodle into MOODLE_19_STABLE
  • Loading branch information...
2 parents 79cf3f0 + 33314c7 commit 51c6d453e12c864b2396d57945239371c56b44e7 @stronk7 stronk7 committed Nov 29, 2011
Showing with 16 additions and 0 deletions.
  1. +16 −0 lib/dmllib.php
View
@@ -1448,6 +1448,14 @@ function insert_record($table, $dataobject, $returnid=true, $primarykey='id') {
if (is_array($dataobject)) {
debugging('Warning. Wrong call to insert_record(). $dataobject must be an object. array found instead', DEBUG_DEVELOPER);
$dataobject = (object)$dataobject;
+ } else if (is_object($dataobject)) {
+ // make sure there are no properties or private methods because we cast to array later,
+ // at the same time this undos the object references so that PHP 5 works the same as PHP 4,
+ // the main reason for this is BC after the dirty magic hack introduction
+ if ($properties = get_object_vars($dataobject)) {
+ $dataobject = (object)$properties;
+ }
+ unset($properties);
}
/// Temporary hack as part of phasing out all access to obsolete user tables XXX
@@ -1643,6 +1651,14 @@ function update_record($table, $dataobject) {
if (is_array($dataobject)) {
debugging('Warning. Wrong call to update_record(). $dataobject must be an object. array found instead', DEBUG_DEVELOPER);
$dataobject = (object)$dataobject;
+ } else if (is_object($dataobject)) {
+ // make sure there are no properties or private methods because we cast to array later,
+ // at the same time this undos the object references so that PHP 5 works the same as PHP 4,
+ // the main reason for this is BC after the dirty magic hack introduction
+ if ($properties = get_object_vars($dataobject)) {
+ $dataobject = (object)$properties;
+ }
+ unset($properties);
}
/// Extra protection against SQL injections

0 comments on commit 51c6d45

Please sign in to comment.