This commit is contained in:
Ilya Tregubov
2026-02-12 08:46:54 +01:00
2 changed files with 11 additions and 2 deletions
@@ -0,0 +1,7 @@
issueNumber: MDL-87158
notes:
tool_xmldb:
- message: >-
Generated `rename_field(...)` upgrade step code now checks for field
existence, to ensure it can be executed multiple times
type: changed
@@ -416,8 +416,10 @@ class view_table_php extends XMLDBAction {
// Launch the proper DDL
$result .= XMLDB_LINEFEED;
$result .= ' // Launch rename field ' . $field->getName() . '.' . XMLDB_LINEFEED;
$result .= ' $dbman->rename_field($table, $field, ' . "'" . 'NEWNAMEGOESHERE' . "'" . ');' . XMLDB_LINEFEED;
$result .= ' // Conditionally launch rename field ' . $field->getName() . '.' . XMLDB_LINEFEED;
$result .= ' if ($dbman->field_exists($table, $field)) {' . XMLDB_LINEFEED;
$result .= ' $dbman->rename_field($table, $field, ' . "'" . 'NEWNAMEGOESHERE' . "'" . ');' . XMLDB_LINEFEED;
$result .= ' }' . XMLDB_LINEFEED;
// Add the proper upgrade_xxxx_savepoint call
$result .= $this->upgrade_savepoint_php ($structure);