コード例 #1
0
	/**
	 * Loads poll description from DB specified by
	 * ($this->mArticleId, $this->mPollId).
	 * Optionally updates the DB, when poll tag attributes were changed.
	 */
	private function loadPid() {
		if ( $this->mArticleId === 0 ) {
			return;
		}
		$db = wfGetDB( DB_MASTER );
		if ( count( $row = qp_PollCache::load( $db ) ) > 0 ) {
			$this->pid = $row->pid;
			# some constructors don't supply all of the poll attributes,
			# get the values from DB in such case
			$updates_counter = 0;
			if ( $this->mOrderId === null ) {
				$this->mOrderId = $row->order_id;
				$updates_counter++;
			}
			if ( $this->dependsOn === null ) {
				$this->dependsOn = $row->dependance;
				$updates_counter++;
			}
			if ( $this->interpDBkey === null ) {
				$this->interpNS = $row->interpretation_namespace;
				$this->interpDBkey = $row->interpretation_title;
				$updates_counter++;
			}
			if ( $this->randomQuestionCount === null ) {
				$this->randomQuestionCount = $row->random_question_count;
				$updates_counter++;
			}
			if ( $updates_counter < 4 ) {
				# some attributes might have been changed in poll header,
				# update the cache
				qp_PollCache::store( $db, 'qp_PollCache' );
			}
		}
	}