Huji has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/315320

Change subject: Poll owner field exists with no default value
......................................................................

Poll owner field exists with no default value

Bug: T147824
Change-Id: I24b6cad9c364309e1772b15321f95152f62ab4f7
---
M includes/entities/Election.php
M includes/main/Store.php
M includes/pages/CreatePage.php
3 files changed, 20 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SecurePoll 
refs/changes/20/315320/1

diff --git a/includes/entities/Election.php b/includes/entities/Election.php
index ff0ef1d..2749639 100644
--- a/includes/entities/Election.php
+++ b/includes/entities/Election.php
@@ -91,6 +91,7 @@
                $this->startDate = $info['startDate'];
                $this->endDate = $info['endDate'];
                $this->authType = $info['auth'];
+               $this->owner = $info['owner'];
        }
 
        /**
diff --git a/includes/main/Store.php b/includes/main/Store.php
index 776e5ae..49d482e 100644
--- a/includes/main/Store.php
+++ b/includes/main/Store.php
@@ -40,6 +40,10 @@
         */
        function getEntityType( $id );
 
+       /**
+        * Get the user ID for current user.
+        */
+       function getUserId();
 
        /**
         * Get information about a set of elections, specifically the data that
@@ -168,7 +172,8 @@
                        'primaryLang' => 'el_primary_lang',
                        'startDate' => 'el_start_date',
                        'endDate' => 'el_end_date',
-                       'auth' => 'el_auth_type'
+                       'auth' => 'el_auth_type',
+                       'owner' => 'el_owner'
                );
 
                $info = array();
@@ -184,6 +189,11 @@
 
        function getDB( $index = DB_MASTER ) {
                return wfGetDB( $index );
+       }
+
+       function getUserId() {
+               global $wgUser;
+               return $wgUser->mId;
        }
 
        function getQuestionInfo( $electionId ) {
@@ -343,6 +353,11 @@
                        'is disabled.' );
        }
 
+       function getUserId() {
+               global $wgUser;
+               return $wgUser->mId;
+       }
+
        function callbackValidVotes( $electionId, $callback ) {
                if ( !isset( $this->votes[$electionId] ) ) {
                        return Status::newGood();
diff --git a/includes/pages/CreatePage.php b/includes/pages/CreatePage.php
index 11cca58..cfa9fab 100644
--- a/includes/pages/CreatePage.php
+++ b/includes/pages/CreatePage.php
@@ -456,6 +456,7 @@
                        'el_start_date' => $dbw->timestamp( 
$election->getStartDate() ),
                        'el_end_date' => $dbw->timestamp( 
$election->getEndDate() ),
                        'el_auth_type' => $election->authType,
+                       'el_owner' => $election->owner,
                );
                if ( $election->getId() < 0 ) {
                        $eId = self::insertEntity( $dbw, 'election' );
@@ -943,6 +944,7 @@
                $endDate = $date->format( 'YmdHis' );
 
                $this->lang = $formData['election_primaryLang'];
+               $owner = $this->getUserId();
 
                $eId = (int)$formData['election_id'] <= 0 ? --$curId : 
(int)$formData['election_id'];
                $this->eId = $eId;
@@ -956,6 +958,7 @@
                        'startDate' => wfTimestamp( TS_MW, $startDate ),
                        'endDate' => wfTimestamp( TS_MW, $endDate ),
                        'auth' => $this->remoteWikis ? 'remote-mw' : 'local',
+                       'owner' => $owner,
                        'questions' => array(),
                );
                $this->properties[$eId] = array(

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I24b6cad9c364309e1772b15321f95152f62ab4f7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SecurePoll
Gerrit-Branch: master
Gerrit-Owner: Huji <[email protected]>

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

Reply via email to