Use NULL instead of 0 to indicate "no page" for cases where rc_cur_id is a FK.
authorGreg Sabino Mullane <greg@users.mediawiki.org>
Sun, 23 Jul 2006 01:13:56 +0000 (01:13 +0000)
committerGreg Sabino Mullane <greg@users.mediawiki.org>
Sun, 23 Jul 2006 01:13:56 +0000 (01:13 +0000)
includes/RecentChange.php

index a1352ce..4361ca3 100644 (file)
@@ -113,6 +113,11 @@ class RecentChange
                $this->mAttribs['rc_cur_time'] = $dbw->timestamp($this->mAttribs['rc_cur_time']);
                $this->mAttribs['rc_id'] = $dbw->nextSequenceValue( 'rc_rc_id_seq' );
 
+               ## If we are using foreign keys, an entry of 0 for the page_id will fail, so use NULL
+               if ( $dbw->cascadingDeletes() and $this->mAttribs['rc_cur_id']==0 ) {
+                       unset ( $this->mAttribs['rc_cur_id'] );
+               }
+
                # Insert new row
                $dbw->insert( 'recentchanges', $this->mAttribs, $fname );