jenkins-bot has submitted this change and it was merged.

Change subject: Fix ORMRow::insert() on PostgreSQL.
......................................................................


Fix ORMRow::insert() on PostgreSQL.

When inserting a new row, ORMRow explicitly passed NULL as the value for
the id field which in MySQL means "use next value in sequence", but in
PostgreSQL means "use NULL".  With this change, for id fields no value
is passed if it isn't set to non-null.  This fixes bug #43475.

This effectively bars the possibility to set the id field of an existing
row to NULL, but the current code already disallows any changes in id
fields.

Change-Id: I29d86fa6fc38ff1852821658e4927b4d7d4a72b6
---
M includes/db/ORMRow.php
1 file changed, 5 insertions(+), 0 deletions(-)

Approvals:
  Demon: Looks good to me, approved
  Jeroen De Dauw: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/includes/db/ORMRow.php b/includes/db/ORMRow.php
index 5c730fb..5fd99af 100644
--- a/includes/db/ORMRow.php
+++ b/includes/db/ORMRow.php
@@ -261,6 +261,11 @@
                        if ( array_key_exists( $name, $this->fields ) ) {
                                $value = $this->fields[$name];
 
+                               // Skip null id fields so that the DBMS can set 
the default.
+                               if ( $name === 'id' && is_null ( $value ) ) {
+                                       continue;
+                               }
+
                                switch ( $type ) {
                                        case 'array':
                                                $value = (array)$value;

-- 
To view, visit https://gerrit.wikimedia.org/r/41020
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I29d86fa6fc38ff1852821658e4927b4d7d4a72b6
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Tim Landscheidt <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Demon <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Tim Landscheidt <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to