• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wfGetDb函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wfGetDb函数的典型用法代码示例。如果您正苦于以下问题:PHP wfGetDb函数的具体用法?PHP wfGetDb怎么用?PHP wfGetDb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wfGetDb函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute($subPage)
 {
     global $wgRequest, $wgUser;
     $zip = (int) $wgRequest->getVal('zip');
     $out = $this->getOutput();
     $this->setHeaders();
     $this->outputHeader();
     if ($wgRequest->getVal('store')) {
         $dbw = wfGetDb(DB_MASTER);
         $res = $dbw->insert('cl_errors', array('cle_zip' => $zip, 'cle_comment' => $wgRequest->getVal('comment')), __METHOD__, array());
         $out->addHtml('Thank you!');
     } else {
         $out->addHtml('<form method=post action="/wiki/Special:CongressFail">');
         $out->addHtml('<div>');
         $out->addHtml('<div>');
         if ($zip != 0) {
             $out->addHtml('ZIP Code (will be recorded): ' . $zip);
             $out->addHtml('<input type=hidden name=zip value=' . $zip . '>');
         } else {
             $out->addHtml('ZIP code: <input name=zip>');
         }
         $out->addHtml('</div>');
         $out->addHtml('Tell us what went wrong: <input type=text size=100 name=comment maxlength=255>');
         $out->addHtml('</div>');
         $out->addHtml('<div>');
         $out->addHtml('<input type=submit name=store value="Send Error Report">');
         $out->addHtml('</div>');
         $out->addHtml('</form>');
     }
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:30,代码来源:SpecialCongressFail.php


示例2: execute

 public function execute()
 {
     $dbw = wfGetDb(DB_MASTER);
     // Determining what groups the account was in before the change
     // would be difficult and unnecessary 99.9% of the time, so we just
     // assume the account was in no other groups
     $params = array('grant' => "\nbot", 'revoke' => "bot\n");
     $logrows = $dbw->select('logging', array('log_id', 'log_action'), array('log_type' => 'makebot', 'log_action' => array('grant', 'revoke')), __METHOD__);
     $count = $logrows->numRows();
     $this->output("Updating {$count} entries in the logging table\n");
     $batch = 0;
     foreach ($logrows as $row) {
         $dbw->update('logging', array('log_action' => 'rights', 'log_type' => 'rights', 'log_params' => $params[$row->log_action]), array('log_id' => $row->log_id), __METHOD__);
         $batch++;
         if ($batch == 100) {
             wfWaitForSlaves(5);
             $batch = 0;
         }
     }
     $rcrows = $dbw->select('recentchanges', array('rc_id', 'rc_log_action'), array('rc_log_type' => 'makebot', 'rc_log_action' => array('grant', 'revoke')), __METHOD__);
     $count = $rcrows->numRows();
     $this->output("Updating {$count} entries in the recentchanges table\n");
     foreach ($rcrows as $row) {
         $dbw->update('recentchanges', array('rc_log_action' => 'rights', 'rc_log_type' => 'rights', 'rc_params' => $params[$row->rc_log_action]), array('rc_id' => $row->rc_id), __METHOD__);
     }
     $this->output("Done!\n");
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:27,代码来源:migrateBotlog.php


示例3: execute

 /**
  * Extracts the title, token, and reason from the request parameters and invokes
  * the local delete() function with these as arguments. It does not make use of 
  * the delete function specified by Article.php. If the deletion succeeds, the 
  * details of the article deleted and the reason for deletion are added to the 
  * result object.
  */
 public function execute()
 {
     global $wgUser;
     $this->getMain()->requestWriteMode();
     $params = $this->extractRequestParams();
     $titleObj = NULL;
     if (!isset($params['title'])) {
         $this->dieUsageMsg(array('missingparam', 'title'));
     }
     if (!isset($params['token'])) {
         $this->dieUsageMsg(array('missingparam', 'token'));
     }
     $titleObj = Title::newFromText($params['title']);
     if (!$titleObj) {
         $this->dieUsageMsg(array('invalidtitle', $params['title']));
     }
     if (!$titleObj->exists()) {
         $this->dieUsageMsg(array('notanarticle'));
     }
     $articleObj = new Article($titleObj);
     $reason = isset($params['reason']) ? $params['reason'] : NULL;
     $dbw = wfGetDb(DB_MASTER);
     $dbw->begin();
     $retval = self::delete($articleObj, $params['token'], $reason);
     if (!empty($retval)) {
         // We don't care about multiple errors, just report one of them
         $this->dieUsageMsg(current($retval));
     }
     $dbw->commit();
     $r = array('title' => $titleObj->getPrefixedText(), 'reason' => $reason);
     $this->getResult()->addValue(null, $this->getModuleName(), $r);
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:39,代码来源:ApiDelete.php


示例4: send

 function send($recipients, $headers, $body)
 {
     $this->_sanitizeHeaders($headers);
     list($from, $textHeaders) = $this->prepareHeaders($headers);
     $priority = 0;
     if (isset($headers['X-Priority'])) {
         $priority = $headers['X-Priority'];
     }
     $category = '';
     if (isset($headers['X-Msg-Category'])) {
         $category = $headers['X-Msg-Category'];
     }
     global $wgCityId, $wgWikiaMailerDB;
     $wgCityId = $wgCityId == null ? 0 : $wgCityId;
     // fake city-id for contractor/staff.
     // FB:4431 Write mail to archive database now
     $dbw = wfGetDb(DB_MASTER, array(), $wgWikiaMailerDB);
     $dbw->begin(__METHOD__);
     foreach ($recipients as $recipient) {
         // TODO: SHOULD WE FILTER BASED ON BLOCKS / SPAMS HERE?  FOR NOW WE WILL LET SENDGRID HANDLE THAT.
         $dbw->insert(self::$MAIL_TABLE_NAME, array('src' => $from, 'subj' => $headers['Subject'], 'dst' => $recipient, 'hdr' => $textHeaders, 'msg' => $body, 'city_id' => $wgCityId, 'priority' => $priority, 'category' => $category), __METHOD__);
         // Add postback token so that we can verify that any postback actually comes from SendGrid.
         $emailId = $dbw->insertId();
         $postbackToken = wfGetEmailPostbackToken($emailId, $recipient);
         $textHeaders .= $this->sep . "X-CallbackToken: " . $postbackToken;
         $dbw->update(self::$MAIL_TABLE_NAME, array('hdr' => $textHeaders), array('id' => $emailId), __METHOD__);
         wfDebugLog("enotif", __METHOD__ . ": email added to database with data: {$recipient} {$from} {$headers['Subject']}", true);
     }
     $dbw->commit(__METHOD__);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:30,代码来源:wikiadb.php


示例5: execute

 public function execute()
 {
     $params = $this->extractRequestParams();
     $dbw = wfGetDb(DB_MASTER);
     $dbw->insert('cl_errors', array('cle_zip' => $params['zip'], 'cc_comment' => $params['comment']), __METHOD__, array());
     $this->getResult()->addValue(null, $this->getModuleName(), 'OK');
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:7,代码来源:ApiCongressLookup.php


示例6: __construct

 /**
  * Constructor
  *
  * @var $resourceType String The calling application or type of resource, conceptually like a namespace
  * @var $user User object, the current user
  * @var $expirationTime Integer (optional) How long should a checkout last, in seconds
  */
 public function __construct($resourceType, $user, $expirationTime = null)
 {
     // All database calls are to the master, since the whole point of this class is maintaining
     // concurrency. Most reads should come from cache anyway.
     $this->dbw = wfGetDb(DB_MASTER);
     $this->user = $user;
     // TODO: create a registry of all valid resourceTypes that client app can add to.
     $this->resourceType = $resourceType;
     $this->setExpirationTime($expirationTime);
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:17,代码来源:ConcurrencyCheck.php


示例7: getWikiArticles

function getWikiArticles()
{
    $searchpages = array("'Spam-blacklist'", "'Spam-whitelist'", "'Spam_blacklist'", "'Spam_whitelist'", "'External_links_whitelist'");
    $db = wfGetDb(DB_SLAVE);
    $res = $db->select(array('page'), array('page_id', 'page_title'), array('page_namespace	= 8', 'page_title in (' . implode(',', $searchpages) . ')'), 'count_average_title', array('ORDER BY' => 'page_id DESC'));
    $articles = array();
    while ($article = $res->fetchObject()) {
        $articles[$article->page_id] = $article->page_title;
    }
    return $articles;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:11,代码来源:blackListMessageChecks.php


示例8: newFromDBResult

 /**
  * Creates and returns a new SWLChangeSet instance from a database result
  * obtained by doing a select on swl_sets. 
  * 
  * @since 0.1
  * 
  * @param $set
  * 
  * @return SWLChangeSet
  */
 public static function newFromDBResult($set)
 {
     $changeSet = new SWLChangeSet(SMWDIWikiPage::newFromTitle(Title::newFromID($set->edit_page_id)), null, null, null, $set->spe_set_id, new SWLEdit($set->edit_page_id, $set->edit_user_name, $set->edit_time, $set->edit_id));
     $dbr = wfGetDb(DB_SLAVE);
     $changes = $dbr->select('swl_changes', array('change_id', 'change_property', 'change_old_value', 'change_new_value'), array('change_set_id' => $set->spe_set_id));
     foreach ($changes as $change) {
         $property = SMWDIProperty::doUnserialize($change->change_property, '__pro');
         $changeSet->addChange($property, SWLPropertyChange::newFromSerialization($property, $change->change_old_value, $change->change_new_value));
     }
     return $changeSet;
 }
开发者ID:nilsdornblut,项目名称:SemanticWatchlist,代码行数:21,代码来源:SWL_ChangeSet.php


示例9: __construct

 public function __construct($options)
 {
     // load command line options
     $this->options = $options;
     global $wgDBname;
     $this->force = isset($options['force']);
     $this->quick = isset($options['quick']);
     $this->databaseName = isset($options['database']) ? $options['database'] : $wgDBname;
     $this->db = wfGetDb(DB_SLAVE, array(), $this->databaseName);
     $this->walker = new DatabaseWalker_UsingShow($this->db);
     $this->script = new SqlScript();
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:12,代码来源:convert.php


示例10: displayDictionaryPage

 /**
  * Displays some shorts statistics about the dictionary page.
  *
  * @since 0.4
  *
  * @param Article $article
  * @param Title $title
  */
 protected static function displayDictionaryPage(Article &$article, Title $title)
 {
     global $wgOut, $wgLang, $wgUser, $egLiveTranslateLanguages;
     $dbr = wfGetDb(DB_SLAVE);
     $res = $dbr->select('live_translate_memories', array('memory_lang_count', 'memory_tu_count'), array('memory_location' => $title->getFullText()), array('LIMIT' => 1));
     foreach ($res as $tm) {
         break;
     }
     if ($tm->memory_tu_count == 0) {
         $wgOut->addWikiMsg('livetranslate-dictionary-empty');
     } else {
         $wgOut->addWikiMsg('livetranslate-dictionary-count', $wgLang->formatNum($tm->memory_tu_count), $wgLang->formatNum($tm->memory_lang_count));
         /*
         $notAllowedLanguages = array();
         
         foreach ( $tus[0]->getVariants() as $languageCode => $translations ) {
         	$languageCode = strtolower( $languageCode );
         	$mappings = LiveTranslateFunctions::getInputLangMapping();
         
         	if ( array_key_exists( $languageCode, $mappings ) ) {
         		$languageCode = $mappings[$languageCode];
         	}
         
         	if ( !in_array( $languageCode, $egLiveTranslateLanguages ) ) {
         		$notAllowedLanguages[] = $languageCode;
         	}
         }
         
         if ( count( $notAllowedLanguages ) > 0 ) {
         	$languages = Language::getLanguageNames( false );
         
         	foreach ( $notAllowedLanguages as &$notAllowedLang ) {
         		if ( array_key_exists( $notAllowedLang, $languages ) ) {
         			$notAllowedLang = $languages[$notAllowedLang];
         		}
         	}
         
         	$wgOut->addHTML(
         		Html::element(
         			'span',
         			array( 'style' => 'color:darkred' ),
         			wfMsgExt( 'livetranslate-dictionary-unallowed-langs', 'parsemag', $wgLang->listToText( $notAllowedLanguages ), count( $notAllowedLanguages ) )
         		)
         	);
         }
         */
     }
     if ($wgUser->isAllowed('managetms')) {
         $wgOut->addHTML(Html::element('a', array('href' => Title::newFromText('Special:LiveTranslate')->getInternalURL()), wfMsg('livetranslate-dictionary-goto-edit')));
     }
 }
开发者ID:JeroenDeDauw,项目名称:LiveTranslate,代码行数:59,代码来源:LiveTranslate.hooks.php


示例11: __construct

 public function __construct($title)
 {
     global $wgUser;
     $this->title = $title;
     $this->dbr =& wfGetDb(DB_SLAVE);
     $this->skin = $wgUser->getSkin();
     $this->families = array();
     $this->numSpouseFamilies = 0;
     $this->selfTag = '';
     $this->spouseTag = '';
     $this->stdPlaces = null;
     $this->prevLastFamilyEndpoint = null;
     $this->loadPedigree();
 }
开发者ID:k-hasan-19,项目名称:wiki,代码行数:14,代码来源:GetJSONData.php


示例12: execute

 public function execute()
 {
     global $wgUser;
     $this->getMain()->requestWriteMode();
     $params = $this->extractRequestParams();
     $titleObj = NULL;
     if (!isset($params['title'])) {
         $this->dieUsageMsg(array('missingparam', 'title'));
     }
     if (!isset($params['token'])) {
         $this->dieUsageMsg(array('missingparam', 'token'));
     }
     if (!$wgUser->isAllowed('undelete')) {
         $this->dieUsageMsg(array('permdenied-undelete'));
     }
     if ($wgUser->isBlocked()) {
         $this->dieUsageMsg(array('blockedtext'));
     }
     if (wfReadOnly()) {
         $this->dieUsageMsg(array('readonlytext'));
     }
     if (!$wgUser->matchEditToken($params['token'])) {
         $this->dieUsageMsg(array('sessionfailure'));
     }
     $titleObj = Title::newFromText($params['title']);
     if (!$titleObj) {
         $this->dieUsageMsg(array('invalidtitle', $params['title']));
     }
     // Convert timestamps
     if (!is_array($params['timestamps'])) {
         $params['timestamps'] = array($params['timestamps']);
     }
     foreach ($params['timestamps'] as $i => $ts) {
         $params['timestamps'][$i] = wfTimestamp(TS_MW, $ts);
     }
     $pa = new PageArchive($titleObj);
     $dbw = wfGetDb(DB_MASTER);
     $dbw->begin();
     $retval = $pa->undelete(isset($params['timestamps']) ? $params['timestamps'] : array(), $params['reason']);
     if (!is_array($retval)) {
         $this->dieUsageMsg(array('cannotundelete'));
     }
     $dbw->commit();
     $info['title'] = $titleObj->getPrefixedText();
     $info['revisions'] = $retval[0];
     $info['fileversions'] = $retval[1];
     $info['reason'] = $retval[2];
     $this->getResult()->addValue(null, $this->getModuleName(), $info);
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:49,代码来源:ApiUndelete.php


示例13: execute

 public function execute()
 {
     $start = intval($this->getOption('start', 0));
     $maxlag = intval($this->getOption('maxlag', 5));
     $dbr = wfGetDb(DB_SLAVE);
     $maxUserID = $dbr->selectField('user', 'MAX(user_id)', false);
     $this->output("Starting from user_id {$start} of {$maxUserID}\n");
     for ($i = $start; $i < $maxUserID; $i++) {
         $this->fixUser($i);
         if ($i % self::REPORTING_INTERVAL == 0) {
             $this->output("{$i}\n");
             wfWaitForSlaves($maxlag);
         }
     }
     $this->output("All done\n");
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:16,代码来源:post-switchover.php


示例14: execute

 public function execute()
 {
     if (!$this->hasArg()) {
         $this->error("No query specified. Specify the query as a command line parameter.", true);
     }
     $query = $this->getArg();
     $wait = $this->getOption('wait', 5);
     $n = 1;
     $dbw = wfGetDb(DB_MASTER);
     do {
         $this->output("Batch {$n}: ");
         $n++;
         $dbw->query($query, __METHOD__);
         $affected = $dbw->affectedRows();
         $this->output("{$affected} rows\n");
         wfWaitForSlaves($wait);
     } while ($affected > 0);
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:18,代码来源:runBatchedQuery.php


示例15: __construct

 public function __construct($options)
 {
     // load command line options
     $this->options = $options;
     global $wgDBname;
     //		$this->force = isset($options['force']);
     //		$this->quick = isset($options['quick']);
     $this->short = isset($options['short']);
     $this->verbose = isset($options['verbose']);
     $this->databaseName = isset($options['database']) ? $options['database'] : $wgDBname;
     $this->clusterName = isset($options['cluster']) ? $options['cluster'] : $this->databaseName;
     $this->db = wfGetDb(DB_SLAVE, array(), $this->clusterName);
     if (!$this->db->selectDB($this->databaseName)) {
         $this->db = false;
     }
     $this->walker = new DatabaseWalker_UsingShow($this->db);
     $this->script = new SqlScript();
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:18,代码来源:checktbl.php


示例16: EditOwn

function EditOwn($title, $user, $action, &$result)
{
    static $cache = array();
    global $wgEditOwnExcludedNamespaces, $wgEditOwnActions;
    if (!is_array($wgEditOwnExcludedNamespaces)) {
        // Prevent PHP from whining
        $wgEditOwnExcludedNamespaces = array();
    }
    if (!in_array($action, $wgEditOwnActions) || $user->isAllowed('editall') || in_array($title->getNamespace(), $wgEditOwnExcludedNamespaces)) {
        $result = null;
        return true;
    }
    if (isset($cache[$user->getName()][$title->getArticleId()])) {
        $result = $cache[$user->getName()][$title->getArticleId()];
        return is_null($result);
    }
    if (!$title->exists()) {
        // Creation is allowed
        $cache[$user->getName()][$title->getArticleId()] = null;
        $result = null;
        return true;
    }
    // Since there's no easy way to get the first revision,
    // we'll just do a DB query
    $dbr = wfGetDb(DB_SLAVE);
    $res = $dbr->select('revision', Revision::selectFields(), array('rev_page' => $title->getArticleId()), __METHOD__, array('ORDER BY' => 'rev_timestamp', 'LIMIT' => 1));
    $row = $dbr->fetchObject($res);
    if (!$row) {
        // Title with no revs, weird... allow creation
        $cache[$user->getName()][$title->getArticleId()] = null;
        $result = null;
        return true;
    }
    $rev = new Revision($row);
    if ($user->getName() == $rev->getRawUserText()) {
        $cache[$user->getName()][$title->getArticleId()] = null;
        $result = null;
        return true;
    }
    $cache[$user->getName()][$title->getArticleId()] = false;
    $result = false;
    return false;
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:43,代码来源:EditOwn.php


示例17: getPagesFrom

 private function getPagesFrom($source)
 {
     $dbr = wfGetDb(DB_SLAVE);
     $className = "{$source}Page";
     if (!class_exists($className)) {
         return array();
     }
     $queryPage = new $className();
     $sql = $dbr->limitResult($queryPage->getSQL(), self::LIMIT, 0);
     $res = $dbr->query($sql, __METHOD__ . "::{$source}");
     $pages = array();
     foreach ($res as $row) {
         $title = Title::newFromText($row->title, $row->namespace);
         if ($title instanceof Title && $title->getNamespace() == NS_MAIN) {
             $pages[] = $title->getText();
         }
     }
     return $pages;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:19,代码来源:AutoLinkerController.class.php


示例18: execute

 /**
  * Unblocks the specified user or provides the reason the unblock failed.
  */
 public function execute()
 {
     global $wgUser;
     $this->getMain()->requestWriteMode();
     $params = $this->extractRequestParams();
     if ($params['gettoken']) {
         $res['unblocktoken'] = $wgUser->editToken();
         $this->getResult()->addValue(null, $this->getModuleName(), $res);
         return;
     }
     if (is_null($params['id']) && is_null($params['user'])) {
         $this->dieUsageMsg(array('unblock-notarget'));
     }
     if (!is_null($params['id']) && !is_null($params['user'])) {
         $this->dieUsageMsg(array('unblock-idanduser'));
     }
     if (is_null($params['token'])) {
         $this->dieUsageMsg(array('missingparam', 'token'));
     }
     if (!$wgUser->matchEditToken($params['token'])) {
         $this->dieUsageMsg(array('sessionfailure'));
     }
     if (!$wgUser->isAllowed('block')) {
         $this->dieUsageMsg(array('cantunblock'));
     }
     if (wfReadOnly()) {
         $this->dieUsageMsg(array('readonlytext'));
     }
     $id = $params['id'];
     $user = $params['user'];
     $reason = is_null($params['reason']) ? '' : $params['reason'];
     $dbw = wfGetDb(DB_MASTER);
     $dbw->begin();
     $retval = IPUnblockForm::doUnblock($id, $user, $reason, $range);
     if (!empty($retval)) {
         $this->dieUsageMsg($retval);
     }
     $dbw->commit();
     $res['id'] = $id;
     $res['user'] = $user;
     $res['reason'] = $reason;
     $this->getResult()->addValue(null, $this->getModuleName(), $res);
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:46,代码来源:ApiUnblock.php


示例19: save

	/**
	 * Save a survey to the database
	 * @param $name string Survey name
	 * @param $survey array Survey configuration data
	 */
	public static function save( $name, $survey ) {
		global $wgRequest, $wgUser;
		$dbw = wfGetDb( DB_MASTER );
		$now = $dbw->timestamp();
		/*$cookieID = $wgRequest->getCookie( "vitals-survey" );
		if ( $cookieID == null ) {
			$cookieID = self::generateRandomCookieID();
			$wgRequest->response()->setcookie( "vitals-survey", $cookieID );
		}*/

		foreach ( $survey['questions'] as $question => $config ) {
			$dbw->insert(
				'prefswitch_survey',
				array_merge(
					array(
						'pss_user' => $wgUser->getId(),
						'pss_user_text' => $wgUser->getName(),
						'pss_timestamp' => $now,
						'pss_name' => $name,
						'pss_question' => $question,
					),
					call_user_func( array( self::$fieldTypes[$config['type']], 'save' ), $question, $wgRequest )
				),
				__METHOD__
			);
		}

		// pseudoquestion, logged in? IP address?
		$dbw->insert(
				'prefswitch_survey',
				array(
					'pss_user' => $wgUser->getId(),
					'pss_user_text' => $wgUser->getName(),
					'pss_timestamp' => $now,
					'pss_name' => $name,
					'pss_question' => "logged_in",
					'pss_answer' => $wgUser->isLoggedIn() ? "yes" : "no",
					'pss_answer_data' => wfGetIP(),
				),
				__METHOD__
			);
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:47,代码来源:SimpleSurvey.classes.php


示例20: execute

 public function execute()
 {
     global $wgUser;
     $this->getMain()->requestWriteMode();
     $params = $this->extractRequestParams();
     $titleObj = NULL;
     if (!isset($params['title'])) {
         $this->dieUsageMsg(array('missingparam', 'title'));
     }
     if (!isset($params['user'])) {
         $this->dieUsageMsg(array('missingparam', 'user'));
     }
     if (!isset($params['token'])) {
         $this->dieUsageMsg(array('missingparam', 'token'));
     }
     $titleObj = Title::newFromText($params['title']);
     if (!$titleObj) {
         $this->dieUsageMsg(array('invalidtitle', $params['title']));
     }
     if (!$titleObj->exists()) {
         $this->dieUsageMsg(array('notanarticle'));
     }
     $username = User::getCanonicalName($params['user']);
     if (!$username) {
         $this->dieUsageMsg(array('invaliduser', $params['user']));
     }
     $articleObj = new Article($titleObj);
     $summary = isset($params['summary']) ? $params['summary'] : "";
     $details = null;
     $dbw = wfGetDb(DB_MASTER);
     $dbw->begin();
     $retval = $articleObj->doRollback($username, $summary, $params['token'], $params['markbot'], $details);
     if (!empty($retval)) {
         // We don't care about multiple errors, just report one of them
         $this->dieUsageMsg(current($retval));
     }
     $dbw->commit();
     $current = $target = $summary = NULL;
     extract($details);
     $info = array('title' => $titleObj->getPrefixedText(), 'pageid' => $current->getPage(), 'summary' => $summary, 'revid' => $titleObj->getLatestRevID(), 'old_revid' => $current->getID(), 'last_revid' => $target->getID());
     $this->getResult()->addValue(null, $this->getModuleName(), $info);
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:42,代码来源:ApiRollback.php



注:本文中的wfGetDb函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wfGetIP函数代码示例发布时间:2022-05-23
下一篇:
PHP wfGetDB函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap