/** * Stores data from current qp_PollStore instance to memory cache, * and optionally to DB. * @param $db null - will store only to memory cache (assumes that * DB is already in sync with qp_PollStore, thus only * the memory cache has to be set); * instance of DB_MASTER - will store to DB as well; * @param $className1, ... $classNameN - one or more PHP class names * that will be instantiated to store their partial data from * current qp_PollStore; * */ static function store( /* $db, $className1, ... $classNameN */ ) { $args = func_get_args(); self::$db = array_shift( $args ); foreach ( $args as $className ) { $self = new $className(); if ( !($self instanceof self ) ) { throw new MWException( 'className parameter has to be a name of ' . __CLASS__ . ' or it\'s ancestors in ' . __METHOD__ ); } if ( self::$db === null ) { ## store only to memory cache, DB is assumed to be already ## in sync with self::$store # update self from qp_PollStore properties # (prepare for memory cache update) $self->updateFromPollStore(); # store $this->memc_rows into memory cache $self->setMemc(); } else { # store both to DB and to memory cache $self->storePolymorph(); } } }
/** * Complete storage of user vote into DB. Final stage of successful poll POST. * When current poll wasn't previousely voted yet, it also creates poll structure * in DB */ function setUserVote() { if ( $this->hasQuestions() && $this->last_uid !== null && $this->mCompletedPostData === 'complete' ) { $this->interpretVote(); # warning: transaction should include minimal set of carefully monitored methods $db = wfGetDB( DB_MASTER ); $db->begin(); qp_PollCache::store( $db, 'qp_QuestionCache', 'qp_CategoryCache', 'qp_ProposalCache' ); if ( $this->interpResult->hasToBeStored() ) { $this->setAnswers( $db ); } $db->commit(); $this->voteDone = true; } }