From: stronk7 Date: Thu, 12 Oct 2006 12:28:36 +0000 (+0000) Subject: Small change in rename_field() so objects won't become modified at all X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=906eebf6ad5dc6287bab77c84a484af10a84b453;p=moodle.git Small change in rename_field() so objects won't become modified at all in the process. Merged from MOODLE_17_STABLE --- diff --git a/lib/xmldb/classes/generators/mssql/mssql.class.php b/lib/xmldb/classes/generators/mssql/mssql.class.php index 5b6c7073a3..9d92171b9d 100644 --- a/lib/xmldb/classes/generators/mssql/mssql.class.php +++ b/lib/xmldb/classes/generators/mssql/mssql.class.php @@ -229,10 +229,12 @@ class XMLDBmssql extends XMLDBgenerator { if ($xmldb_field->getEnum()) { /// Drop the current enum (not needed, it has been dropped before for msqql (in getRenameFieldSQL) //$results = array_merge($results, $this->getDropEnumSQL($xmldb_table, $xmldb_field)); - /// Change field name - $xmldb_field->setName($newname); + /// Change field name (over a clone to avoid some potential problems later) + $new_xmldb_field = clone($xmldb_field); + $new_xmldb_field->setName($newname); + /// Recreate the enum - $results = array_merge($results, $this->getCreateEnumSQL($xmldb_table, $xmldb_field)); + $results = array_merge($results, $this->getCreateEnumSQL($xmldb_table, $new_xmldb_field)); } return $results; diff --git a/lib/xmldb/classes/generators/oci8po/oci8po.class.php b/lib/xmldb/classes/generators/oci8po/oci8po.class.php index 97d462e49e..41d5144dc1 100644 --- a/lib/xmldb/classes/generators/oci8po/oci8po.class.php +++ b/lib/xmldb/classes/generators/oci8po/oci8po.class.php @@ -214,10 +214,11 @@ class XMLDBoci8po extends XMLDBgenerator { if ($xmldb_field->getEnum()) { /// Drop the current enum $results = array_merge($results, $this->getDropEnumSQL($xmldb_table, $xmldb_field)); - /// Change field name - $xmldb_field->setName($newname); + /// Change field name (over a clone to avoid some potential problems later) + $new_xmldb_field = clone($xmldb_field); + $new_xmldb_field->setName($newname); /// Recreate the enum - $results = array_merge($results, $this->getCreateEnumSQL($xmldb_table, $xmldb_field)); + $results = array_merge($results, $this->getCreateEnumSQL($xmldb_table, $new_xmldb_field)); } return $results; diff --git a/lib/xmldb/classes/generators/postgres7/postgres7.class.php b/lib/xmldb/classes/generators/postgres7/postgres7.class.php index e24e7c48f1..6cf983b5fb 100644 --- a/lib/xmldb/classes/generators/postgres7/postgres7.class.php +++ b/lib/xmldb/classes/generators/postgres7/postgres7.class.php @@ -370,10 +370,11 @@ class XMLDBpostgres7 extends XMLDBgenerator { if ($xmldb_field->getEnum()) { /// Drop the current enum $results = array_merge($results, $this->getDropEnumSQL($xmldb_table, $xmldb_field)); - /// Change field name - $xmldb_field->setName($newname); + /// Change field name (over a clone to avoid some potential problems later) + $new_xmldb_field = clone($xmldb_field); + $new_xmldb_field->setName($newname); /// Recreate the enum - $results = array_merge($results, $this->getCreateEnumSQL($xmldb_table, $xmldb_field)); + $results = array_merge($results, $this->getCreateEnumSQL($xmldb_table, $new_xmldb_field)); } return $results;