当前位置: 首页>>代码示例>>PHP>>正文


PHP wfWaitForSlaves函数代码示例

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


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

示例1: execute

 function execute()
 {
     $dbw = wfGetDB(DB_MASTER);
     $table = 'user_properties';
     $oldPropName = 'narayamDisable';
     $newPropName = 'narayamEnable';
     $this->output("Changing {$oldPropName} to {$newPropName}\n");
     $allIds = array();
     while (true) {
         $dbw->begin();
         $res = $dbw->select($table, array('up_user'), array('up_property' => $oldPropName, 'up_value' => 1), __METHOD__, array('LIMIT' => $this->mBatchSize, 'FOR UPDATE'));
         if (!$res->numRows()) {
             break;
         }
         $ids = array();
         foreach ($res as $row) {
             $ids[] = $row->up_user;
         }
         $dbw->update($table, array('up_property' => $newPropName, 'up_value' => 0), array('up_property' => $oldPropName, 'up_user' => $ids), __METHOD__);
         $dbw->commit();
         foreach ($ids as $id) {
             $user = User::newFromID($id);
             if ($user) {
                 $user->invalidateCache();
             }
         }
         wfWaitForSlaves(10);
     }
     $this->output("Old preference {$oldPropName} was migrated to {$newPropName}\n");
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:30,代码来源:FixNarayamDisablePref.php

示例2: execute

 public function execute()
 {
     global $wgEchoCluster;
     $this->output("Started processing... \n");
     $startUserId = 0;
     $count = $this->batchSize;
     while ($count === $this->batchSize) {
         $count = 0;
         $res = MWEchoEmailBatch::getUsersToNotify($startUserId, $this->batchSize);
         $updated = false;
         foreach ($res as $row) {
             $userId = intval($row->eeb_user_id);
             if ($userId && $userId > $startUserId) {
                 $emailBatch = MWEchoEmailBatch::newFromUserId($userId);
                 if ($emailBatch) {
                     $this->output("processing user_Id " . $userId . " \n");
                     $emailBatch->process();
                 }
                 $startUserId = $userId;
                 $updated = true;
             }
             $count++;
         }
         wfWaitForSlaves(false, false, $wgEchoCluster);
         // This is required since we are updating user properties in main wikidb
         wfWaitForSlaves();
         // double check to make sure that the id is updated
         if (!$updated) {
             break;
         }
     }
     $this->output("Completed \n");
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:33,代码来源:processEchoEmailBatch.php

示例3: execute

	public function execute() {
		$userName = 'The Thing That Should Not Be'; // <- targer username

		$user = new CentralAuthUser( $userName );
		if ( !$user->exists() ) {
			echo "Cannot unsuppress non-existent user {$userName}!\n";
			exit( 0 );
		}
		$userName = $user->getName(); // sanity
		$wikis = $user->listAttached(); // wikis with attached accounts
		foreach ( $wikis as $wiki ) {
			$lb = wfGetLB( $wiki );
			$dbw = $lb->getConnection( DB_MASTER, array(), $wiki );
			# Get local ID like $user->localUserData( $wiki ) does
			$localUserId = $dbw->selectField( 'user', 'user_id',
				array( 'user_name' => $userName ), __METHOD__ );

			$delUserBit = Revision::DELETED_USER;
			$hiddenCount = $dbw->selectField( 'revision', 'COUNT(*)',
				array( 'rev_user' => $localUserId, "rev_deleted & $delUserBit != 0" ), __METHOD__ );
			echo "$hiddenCount edits have the username hidden on \"$wiki\"\n";
			# Unsuppress username on edits
			if ( $hiddenCount > 0 ) {
				echo "Unsuppressed edits of attached account (local id $localUserId) on \"$wiki\"...";
				IPBlockForm::unsuppressUserName( $userName, $localUserId, $dbw );
				echo "done!\n\n";
			}
			$lb->reuseConnection( $dbw ); // not really needed
			# Don't lag too bad
			wfWaitForSlaves( 5 );
		}
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:32,代码来源:unsuppressCrossWiki.php

示例4: execute

 public function execute()
 {
     $db = wfGetDB(DB_MASTER);
     $start = $db->selectField('logging', 'MIN(log_id)', false, __METHOD__);
     if (!$start) {
         $this->output("Nothing to do.\n");
         return true;
     }
     $end = $db->selectField('logging', 'MAX(log_id)', false, __METHOD__);
     # Do remaining chunk
     $end += $this->mBatchSize - 1;
     $blockStart = $start;
     $blockEnd = $start + $this->mBatchSize - 1;
     while ($blockEnd <= $end) {
         $this->output("...doing log_id from {$blockStart} to {$blockEnd}\n");
         $cond = "log_id BETWEEN {$blockStart} AND {$blockEnd} AND log_user = user_id";
         $res = $db->select(array('logging', 'user'), array('log_id', 'user_name'), $cond, __METHOD__);
         $db->begin();
         foreach ($res as $row) {
             $db->update('logging', array('log_user_text' => $row->user_name), array('log_id' => $row->log_id), __METHOD__);
         }
         $db->commit();
         $blockStart += $this->mBatchSize;
         $blockEnd += $this->mBatchSize;
         wfWaitForSlaves(5);
     }
     if ($db->insert('updatelog', array('ul_key' => 'populate log_usertext'), __METHOD__, 'IGNORE')) {
         $this->output("log_usertext population complete.\n");
         return true;
     } else {
         $this->output("Could not insert log_usertext population row.\n");
         return false;
     }
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:34,代码来源:populateLogUsertext.php

示例5: doDBUpdates

 protected function doDBUpdates()
 {
     $db = $this->getDB(DB_MASTER);
     $start = $db->selectField('logging', 'MIN(log_id)', false, __METHOD__);
     if (!$start) {
         $this->output("Nothing to do.\n");
         return true;
     }
     $end = $db->selectField('logging', 'MAX(log_id)', false, __METHOD__);
     # Do remaining chunk
     $end += $this->mBatchSize - 1;
     $blockStart = $start;
     $blockEnd = $start + $this->mBatchSize - 1;
     while ($blockEnd <= $end) {
         $this->output("...doing log_id from {$blockStart} to {$blockEnd}\n");
         $cond = "log_id BETWEEN {$blockStart} AND {$blockEnd} AND log_user = user_id";
         $res = $db->select(array('logging', 'user'), array('log_id', 'user_name'), $cond, __METHOD__);
         $db->begin(__METHOD__);
         foreach ($res as $row) {
             $db->update('logging', array('log_user_text' => $row->user_name), array('log_id' => $row->log_id), __METHOD__);
         }
         $db->commit(__METHOD__);
         $blockStart += $this->mBatchSize;
         $blockEnd += $this->mBatchSize;
         wfWaitForSlaves();
     }
     $this->output("Done populating log_user_text field.\n");
     return true;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:29,代码来源:populateLogUsertext.php

示例6: prune

 protected function prune($table, $ts_column, $maxAge)
 {
     $dbw = wfGetDB(DB_MASTER);
     $expiredCond = "{$ts_column} < " . $dbw->addQuotes($dbw->timestamp(time() - $maxAge));
     $count = 0;
     while (true) {
         // Get the first $this->mBatchSize (or less) items
         $res = $dbw->select($table, $ts_column, $expiredCond, __METHOD__, array('ORDER BY' => "{$ts_column} ASC", 'LIMIT' => $this->mBatchSize));
         if (!$res->numRows()) {
             break;
             // all cleared
         }
         // Record the start and end timestamp for the set
         $blockStart = $dbw->addQuotes($res->fetchObject()->{$ts_column});
         $res->seek($res->numRows() - 1);
         $blockEnd = $dbw->addQuotes($res->fetchObject()->{$ts_column});
         $res->free();
         // Do the actual delete...
         $dbw->begin();
         $dbw->delete($table, array("{$ts_column} BETWEEN {$blockStart} AND {$blockEnd}"), __METHOD__);
         $count += $dbw->affectedRows();
         $dbw->commit();
         wfWaitForSlaves();
     }
     return $count;
 }
开发者ID:yusufchang,项目名称:app,代码行数:26,代码来源:purgeOldData.php

示例7: execute

 public function execute()
 {
     $dbw = wfGetDB(DB_MASTER);
     $rl = new ResourceLoader(ConfigFactory::getDefaultInstance()->makeConfig('main'));
     $moduleNames = $rl->getModuleNames();
     $moduleList = implode(', ', array_map(array($dbw, 'addQuotes'), $moduleNames));
     $limit = max(1, intval($this->getOption('batchsize', 500)));
     $this->output("Cleaning up module_deps table...\n");
     $i = 1;
     $modDeps = $dbw->tableName('module_deps');
     do {
         // $dbw->delete() doesn't support LIMIT :(
         $where = $moduleList ? "md_module NOT IN ({$moduleList})" : '1=1';
         $dbw->query("DELETE FROM {$modDeps} WHERE {$where} LIMIT {$limit}", __METHOD__);
         $numRows = $dbw->affectedRows();
         $this->output("Batch {$i}: {$numRows} rows\n");
         $i++;
         wfWaitForSlaves();
     } while ($numRows > 0);
     $this->output("done\n");
     $this->output("Cleaning up msg_resource table...\n");
     $i = 1;
     $mrRes = $dbw->tableName('msg_resource');
     do {
         $where = $moduleList ? "mr_resource NOT IN ({$moduleList})" : '1=1';
         $dbw->query("DELETE FROM {$mrRes} WHERE {$where} LIMIT {$limit}", __METHOD__);
         $numRows = $dbw->affectedRows();
         $this->output("Batch {$i}: {$numRows} rows\n");
         $i++;
         wfWaitForSlaves();
     } while ($numRows > 0);
     $this->output("done\n");
 }
开发者ID:mb720,项目名称:mediawiki,代码行数:33,代码来源:cleanupRemovedModules.php

示例8: processSynonym

	public function processSynonym( $synonym ) {
		$dbr = wfGetDB( DB_SLAVE );
		$pCount = 0;
		$vCount = 0;
		$this->output( "Fixing pages with template links to $synonym ...\n" );
		while ( true ) {
			$res = $dbr->select( 'templatelinks', array( 'tl_title', 'tl_from' ),
				array(
					'tl_namespace' => NS_TEMPLATE,
					'tl_title ' . $dbr->buildLike( $synonym, $dbr->anyString() )
				), __METHOD__,
				array( 'ORDER BY' => array( 'tl_title', 'tl_from' ), 'LIMIT' => $this->batchsize )
			);
			if ( $dbr->numRows( $res ) == 0 ) {
				// No more rows, we're done
				break;
			}

			$processed = array();
			foreach ( $res as $row ) {
				$vCount++;
				if ( isset( $processed[$row->tl_from] ) ) {
					// We've already processed this page, skip it
					continue;
				}
				RefreshLinks::fixLinksFromArticle( $row->tl_from );
				$processed[$row->tl_from] = true;
				$pCount++;
			}
			$this->output( "{$pCount}/{$vCount} pages processed\n" );
			wfWaitForSlaves();
		}
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:33,代码来源:cleanupBug31576.php

示例9: doImport

 /**
  * @param $fileHandle
  * @param DatabaseBase $db
  * @param ImportContext $importContext
  * @throws UnexpectedValueException
  */
 private function doImport($fileHandle, DatabaseBase $db, ImportContext $importContext)
 {
     $accumulator = array();
     $batchSize = $importContext->getBatchSize();
     $i = 0;
     $header = fgetcsv($fileHandle, 0, $importContext->getCsvDelimiter());
     //this is to get the csv-header
     $expectedHeader = array('pid1', 'qid1', 'pid2', 'count', 'probability', 'context');
     if ($header != $expectedHeader) {
         throw new UnexpectedValueException("provided csv-file does not match the expected format:\n" . join(',', $expectedHeader));
     }
     while (true) {
         $data = fgetcsv($fileHandle, 0, $importContext->getCsvDelimiter());
         if ($data == false || ++$i % $batchSize == 0) {
             $db->commit(__METHOD__, 'flush');
             wfWaitForSlaves();
             $db->insert($importContext->getTargetTableName(), $accumulator);
             if (!$importContext->isQuiet()) {
                 print "{$i} rows inserted\n";
             }
             $accumulator = array();
             if ($data == false) {
                 break;
             }
         }
         $qid1 = is_numeric($data[1]) ? $data[1] : 0;
         $accumulator[] = array('pid1' => $data[0], 'qid1' => $qid1, 'pid2' => $data[2], 'count' => $data[3], 'probability' => $data[4], 'context' => $data[5]);
     }
 }
开发者ID:siebrand,项目名称:PropertySuggester,代码行数:35,代码来源:BasicImporter.php

示例10: doDBUpdates

 public function doDBUpdates()
 {
     $force = $this->getOption('force');
     $db = $this->getDB(DB_MASTER);
     $this->output("Updating *_from_namespace fields in links tables.\n");
     $start = $this->getOption('lastUpdatedId');
     if (!$start) {
         $start = $db->selectField('page', 'MIN(page_id)', false, __METHOD__);
     }
     if (!$start) {
         $this->output("Nothing to do.");
         return false;
     }
     $end = $db->selectField('page', 'MAX(page_id)', false, __METHOD__);
     # Do remaining chunk
     $end += $this->mBatchSize - 1;
     $blockStart = $start;
     $blockEnd = $start + $this->mBatchSize - 1;
     while ($blockEnd <= $end) {
         $this->output("...doing page_id from {$blockStart} to {$blockEnd}\n");
         $cond = "page_id BETWEEN {$blockStart} AND {$blockEnd}";
         $res = $db->select('page', array('page_id', 'page_namespace'), $cond, __METHOD__);
         foreach ($res as $row) {
             $db->update('pagelinks', array('pl_from_namespace' => $row->page_namespace), array('pl_from' => $row->page_id), __METHOD__);
             $db->update('templatelinks', array('tl_from_namespace' => $row->page_namespace), array('tl_from' => $row->page_id), __METHOD__);
             $db->update('imagelinks', array('il_from_namespace' => $row->page_namespace), array('il_from' => $row->page_id), __METHOD__);
         }
         $blockStart += $this->mBatchSize - 1;
         $blockEnd += $this->mBatchSize - 1;
         wfWaitForSlaves();
     }
     return true;
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:33,代码来源:populateBacklinkNamespace.php

示例11: execute

 public function execute()
 {
     $count = 0;
     $oldGroup = $this->getArg(0);
     $newGroup = $this->getArg(1);
     $dbw = wfGetDB(DB_MASTER);
     $start = $dbw->selectField('user_groups', 'MIN(ug_user)', array('ug_group' => $oldGroup), __FUNCTION__);
     $end = $dbw->selectField('user_groups', 'MAX(ug_user)', array('ug_group' => $oldGroup), __FUNCTION__);
     if ($start === null) {
         $this->error("Nothing to do - no users in the '{$oldGroup}' group", true);
     }
     # Do remaining chunk
     $end += $this->mBatchSize - 1;
     $blockStart = $start;
     $blockEnd = $start + $this->mBatchSize - 1;
     // Migrate users over in batches...
     while ($blockEnd <= $end) {
         $this->output("Doing users {$blockStart} to {$blockEnd}\n");
         $dbw->begin();
         $dbw->update('user_groups', array('ug_group' => $newGroup), array('ug_group' => $oldGroup, "ug_user BETWEEN {$blockStart} AND {$blockEnd}"));
         $count += $dbw->affectedRows();
         $dbw->commit();
         $blockStart += $this->mBatchSize;
         $blockEnd += $this->mBatchSize;
         wfWaitForSlaves(5);
     }
     $this->output("Done! {$count} user(s) in group '{$oldGroup}' are now in '{$newGroup}' instead.\n");
 }
开发者ID:rocLv,项目名称:conference,代码行数:28,代码来源:migrateUserGroup.php

示例12: moveToExternal

function moveToExternal($cluster, $maxID)
{
    $fname = 'moveToExternal';
    $dbw =& wfGetDB(DB_MASTER);
    print "Moving {$maxID} text rows to external storage\n";
    $ext = new ExternalStoreDB();
    for ($id = 1; $id <= $maxID; $id++) {
        if (!($id % REPORTING_INTERVAL)) {
            print "{$id}\n";
            wfWaitForSlaves(5);
        }
        $row = $dbw->selectRow('text', array('old_flags', 'old_text'), array('old_id' => $id, "old_flags NOT LIKE '%external%'"), $fname);
        if (!$row) {
            # Non-existent or already done
            continue;
        }
        # Resolve stubs
        $flags = explode(',', $row->old_flags);
        if (in_array('object', $flags) && substr($row->old_text, 0, strlen(STUB_HEADER)) === STUB_HEADER) {
            resolveStub($id, $row->old_text, $row->old_flags);
            continue;
        }
        $url = $ext->store($cluster, $row->old_text);
        if (!$url) {
            print "Error writing to external storage\n";
            exit;
        }
        if ($row->old_flags === '') {
            $flags = 'external';
        } else {
            $flags = "{$row->old_flags},external";
        }
        $dbw->update('text', array('old_flags' => $flags, 'old_text' => $url), array('old_id' => $id), $fname);
    }
}
开发者ID:BackupTheBerlios,项目名称:openzaurus-svn,代码行数:35,代码来源:moveToExternal.php

示例13: execute

 public function execute()
 {
     $this->commit = $this->hasOption('commit');
     $dbr = $this->getDB(DB_SLAVE);
     $dbw = $this->getDB(DB_MASTER);
     $lastId = 0;
     do {
         $rows = $dbr->select('user', array('user_id', 'user_email'), array('user_id > ' . $dbr->addQuotes($lastId), 'user_email != ""', 'user_email_authenticated IS NULL'), __METHOD__, array('LIMIT' => $this->mBatchSize));
         $count = $rows->numRows();
         $badIds = array();
         foreach ($rows as $row) {
             if (!Sanitizer::validateEmail(trim($row->user_email))) {
                 $this->output("Found bad email: {$row->user_email} for user #{$row->user_id}\n");
                 $badIds[] = $row->user_id;
             }
             if ($row->user_id > $lastId) {
                 $lastId = $row->user_id;
             }
         }
         if ($badIds) {
             $badCount = count($badIds);
             if ($this->commit) {
                 $this->output("Removing {$badCount} emails from the database.\n");
                 $dbw->update('user', array('user_email' => ''), array('user_id' => $badIds), __METHOD__);
                 foreach ($badIds as $badId) {
                     User::newFromId($badId)->invalidateCache();
                 }
                 wfWaitForSlaves();
             } else {
                 $this->output("Would have removed {$badCount} emails from the database.\n");
             }
         }
     } while ($count !== 0);
     $this->output("Done.\n");
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:35,代码来源:removeInvalidEmails.php

示例14: doDBUpdates

 protected function doDBUpdates()
 {
     $dbw = $this->getDB(DB_MASTER);
     if (!$dbw->fieldExists('recentchanges', 'rc_source')) {
         $this->error('rc_source field in recentchanges table does not exist.');
     }
     $start = $dbw->selectField('recentchanges', 'MIN(rc_id)', false, __METHOD__);
     if (!$start) {
         $this->output("Nothing to do.\n");
         return true;
     }
     $end = $dbw->selectField('recentchanges', 'MAX(rc_id)', false, __METHOD__);
     $end += $this->mBatchSize - 1;
     $blockStart = $start;
     $blockEnd = $start + $this->mBatchSize - 1;
     $updatedValues = $this->buildUpdateCondition($dbw);
     while ($blockEnd <= $end) {
         $cond = "rc_id BETWEEN {$blockStart} AND {$blockEnd}";
         $dbw->update('recentchanges', [$updatedValues], ["rc_source = ''", "rc_id BETWEEN {$blockStart} AND {$blockEnd}"], __METHOD__);
         $this->output(".");
         wfWaitForSlaves();
         $blockStart += $this->mBatchSize;
         $blockEnd += $this->mBatchSize;
     }
     $this->output("\nDone.\n");
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:26,代码来源:populateRecentChangesSource.php

示例15: execute

 public function execute()
 {
     $user = 'MediaWiki default';
     $reason = 'No longer required';
     $this->output("Checking existence of old default messages...");
     $dbr = wfGetDB(DB_SLAVE);
     $res = $dbr->select(array('page', 'revision'), array('page_namespace', 'page_title'), array('page_namespace' => NS_MEDIAWIKI, 'page_latest=rev_id', 'rev_user_text' => 'MediaWiki default'));
     if ($dbr->numRows($res) == 0) {
         # No more messages left
         $this->output("done.\n");
         return;
     }
     # Deletions will be made by $user temporarly added to the bot group
     # in order to hide it in RecentChanges.
     global $wgUser;
     $wgUser = User::newFromName($user);
     $wgUser->addGroup('bot');
     # Handle deletion
     $this->output("\n...deleting old default messages (this may take a long time!)...", 'msg');
     $dbw = wfGetDB(DB_MASTER);
     foreach ($res as $row) {
         if (function_exists('wfWaitForSlaves')) {
             wfWaitForSlaves(5);
         }
         $dbw->ping();
         $title = Title::makeTitle($row->page_namespace, $row->page_title);
         $article = new Article($title);
         $dbw->begin();
         $article->doDeleteArticle($reason);
         $dbw->commit();
     }
     $this->output('done!', 'msg');
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:33,代码来源:deleteDefaultMessages.php


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