Exemplo n.º 1
0
 /**
  * @brief main entry point
  */
 public function execute()
 {
     global $wgExternalSharedDB;
     $dbw = wfGetDB(DB_MASTER, array(), $wgExternalSharedDB);
     // handler to wikifactory tables
     // take all users with founderemailsenabled option
     wfOut("Getting users with founderemailsenabled option set...\n");
     $sth = $dbw->select(array("user_properties"), array("up_user", "up_value"), array("up_property" => "founderemailsenabled"), __METHOD__);
     while ($row = $dbw->fetchObject($sth)) {
         // now check if user founded any wiki
         $sth2 = $dbw->select(array("city_list"), array("city_id", "city_founding_user"), array("city_founding_user" => $row->up_user));
         $user = User::newFromId($row->up_user);
         if ($user) {
             wfOut("Found user {$user->getId()} with user name {$user->getName()}\n");
             $changed = false;
             while ($city = $dbw->fetchObject($sth2)) {
                 $city_id = $city->city_id;
                 if (!$this->hasOption('dry')) {
                     $user->setOption("founderemails-joins-{$city_id}", $row->up_value);
                     $user->setOption("founderemails-edits-{$city_id}", $row->up_value);
                     $user->setOption("founderemails-views-digest-{$city_id}", $row->up_value);
                     $user->setOption("founderemails-complete-digest-{$city_id}", $row->up_value);
                     if ($this->hasOption('remove')) {
                         // hack, User object doesn't have method for resetting option
                         unset($user->mOptions["founderemailsenabled"]);
                     }
                     $changed = true;
                 }
                 wfOut("\tset founderemails-joins-{$city_id} to {$row->up_value}\n");
                 wfOut("\tset founderemails-edits-{$city_id} to {$row->up_value}\n");
                 wfOut("\tset founderemails-views-digest-{$city_id} to {$row->up_value}\n");
                 wfOut("\tset founderemails-complete-digest-{$city_id} to {$row->up_value}\n");
             }
             if ($changed) {
                 $user->saveSettings();
             }
         }
     }
 }
Exemplo n.º 2
0
<?php

/**
 * @package MediaWiki
 * @addtopackage maintenance
 *
 * @author Krzysztof Krzyżaniak <*****@*****.**>
 */
ini_set("include_path", dirname(__FILE__) . "/../../../maintenance/");
require_once "commandLine.inc";
$sitemap = new SitemapPage();
$namespaces = $sitemap->getNamespacesList();
wfOut("Caching {$wgDBname} ({$wgCityId}) for {$sitemap->mCacheTime} sec.\n");
/*
 * DPL causes some problems while parsing wiki text ( Video description )
 * so let's unset DPL parser hooks for maintenance script
 */
$key = array_search("ExtDynamicPageList::setupDPL", $wgHooks['ParserFirstCallInit']);
if ($key > 0) {
    unset($wgHooks['ParserFirstCallInit'][$key]);
}
$indexes = array();
foreach ($namespaces as $namespace) {
    echo "Caching namespace {$namespace}...";
    $indexes[$namespace] = $sitemap->cachePages($namespace);
    echo " pages " . count($indexes[$namespace]);
    echo " done\n";
    $includeVideo = (bool) F::app()->wg->EnableVideoSitemaps;
    if ($includeVideo && $namespace != NS_FILE) {
        $includeVideo = false;
    }
Exemplo n.º 3
0
 public static function makeUoiUserNotUnique()
 {
     $db = wfGetDB(DB_MASTER);
     if (!$db->tableExists('user_openid')) {
         return;
     }
     $info = $db->fieldInfo('user_openid', 'uoi_user');
     if (!$info->isMultipleKey()) {
         wfOut("Making uoi_user filed not unique...");
         $db->sourceFile(dirname(__FILE__) . '/patch-uoi_user-not-unique.sql');
         wfOut(" done.\n");
     } else {
         wfOut("...uoi_user field is already not unique.\n");
     }
 }
Exemplo n.º 4
0
function wfEditStats($options = array())
{
    global $wgExternalDatawareDB, $wgDBname;
    $m = array();
    $count_edits = $count_content_edits = 0;
    $count_editors = $count_content_editors = 0;
    $count_anons = $count_content_anons = 0;
    $dbr = wfGetDB(DB_SLAVE, 'blobs', $wgExternalDatawareDB);
    ###################
    wfOut("\nCounting total edits...");
    $conditions = array("pe_date" => $options['date']);
    $oRow = $dbr->selectRow(array("page_edits"), array("sum(pe_all_count) as all_count"), $conditions, __METHOD__);
    if ($oRow) {
        $count_edits = intval($oRow->all_count);
    }
    ###################
    wfOut("\nCounting total content namespaces edits...");
    $conditions['pe_is_content'] = 1;
    $oRow = $dbr->selectRow(array("page_edits"), array("sum(pe_all_count) as all_count"), $conditions, __METHOD__);
    if ($oRow) {
        $count_content_edits = intval($oRow->all_count);
    }
    ###################
    wfOut("\nCounting total editors...");
    $conditions = array("pc_date" => $options['date']);
    $oRow = $dbr->selectRow(array("page_editors"), array("sum(pc_all_count) as all_count"), $conditions, __METHOD__);
    if ($oRow) {
        $count_editors = intval($oRow->all_count);
    }
    ###################
    wfOut("\nCounting total content editors...");
    $conditions['pc_is_content'] = 1;
    $oRow = $dbr->selectRow(array("page_editors"), array("sum(pc_all_count) as all_count"), $conditions, __METHOD__);
    if ($oRow) {
        $count_content_editors = intval($oRow->all_count);
    }
    ###################
    wfOut("\nCounting total anons...");
    $conditions = array("pc_date" => $options['date'], "pc_user_id" => 0);
    $oRow = $dbr->selectRow(array("page_editors"), array("sum(pc_all_count) as all_count"), $conditions, __METHOD__);
    if ($oRow) {
        $count_anons = intval($oRow->all_count);
    }
    ###################
    wfOut("\nCounting total content editors...");
    $conditions['pc_is_content'] = 1;
    $oRow = $dbr->selectRow(array("page_editors"), array("sum(pc_all_count) as all_count"), $conditions, __METHOD__);
    if ($oRow) {
        $count_content_anons = intval($oRow->all_count);
    }
    ###################
    wfOut("\nUpdating page statistics...");
    $dbw = wfGetDB(DB_MASTER, array(), $wgExternalDatawareDB);
    $values = array('pe_edits' => $count_edits, 'pe_content_edits' => $count_content_edits, 'pe_editors' => $count_editors, 'pe_content_editors' => $count_content_editors, 'pe_anon_editors' => $count_anons, 'pe_anon_content_editors' => $count_content_anons);
    $conds = array('pe_date' => $options['date']);
    $dbw->delete('page_edits_month', $conds, __METHOD__);
    $dbw->insert('page_edits_month', array_merge($values, $conds), __METHOD__);
    ###################
    # make other stats
    wfOut("\nRegenerate editors/pages statistics to memc...(for home page stats) ");
    for ($i = 1; $i <= 7; $i++) {
        wfOut("\nTop 10 most edited pages (per editors) in last {$i} days  ... ");
        WikiaGlobalStats::getPagesEditors($i, 10, true, true, false, true);
        WikiaGlobalStats::getPagesEditors($i, 10, true, false, false, true);
        wfOut("\nTop 5 most edited pages (per editors) in last {$i} days ... ");
        WikiaGlobalStats::getPagesEditors($i, 5, true, true, false, true);
        WikiaGlobalStats::getPagesEditors($i, 5, true, false, false, true);
    }
    for ($i = 1; $i <= 7; $i++) {
        wfOut("\nTop 10 most edited pages in last {$i} days  ... ");
        WikiaGlobalStats::getEditedArticles($i, 10, true, true);
        wfOut("\nTop 5 most edited pages in last {$i} days ... ");
        WikiaGlobalStats::getEditedArticles($i, 5, true, true);
        wfOut("\\Number of words in last {$i} days ... ");
        WikiaGlobalStats::countWordsInLastDays($i, 1);
    }
    #$memkey = wfMemcKey( "WS:getPagesEditors", 3, 10, 1, 0, 0 );
    #echo "memkey = $memkey \n";
    #echo print_r( $wgMemc->get( $memkey ), true );
    wfOut("\ndone.\n");
}
Exemplo n.º 5
0
 private function doPopulateCategory($begin, $maxlag, $throttle, $force)
 {
     $dbw = wfGetDB(DB_MASTER);
     if (!$force) {
         $row = $dbw->selectRow('updatelog', '1', array('ul_key' => 'populate category'), __FUNCTION__);
         if ($row) {
             $this->output("Category table already populated.  Use php " . "maintenance/populateCategory.php\n--force from the command line " . "to override.\n");
             return true;
         }
     }
     $maxlag = intval($maxlag);
     $throttle = intval($throttle);
     $force = (bool) $force;
     if ($begin !== '') {
         $where = 'cl_to > ' . $dbw->addQuotes($begin);
     } else {
         $where = null;
     }
     $i = 0;
     while (true) {
         # Find which category to update
         $row = $dbw->selectRow('categorylinks', 'cl_to', $where, __FUNCTION__, array('ORDER BY' => 'cl_to'));
         if (!$row) {
             # Done, hopefully.
             break;
         }
         $name = $row->cl_to;
         $where = 'cl_to > ' . $dbw->addQuotes($name);
         # Use the row to update the category count
         $cat = Category::newFromName($name);
         if (!is_object($cat)) {
             $this->output("The category named {$name} is not valid?!\n");
         } else {
             $cat->refreshCounts();
         }
         ++$i;
         if (!($i % self::REPORTING_INTERVAL)) {
             $this->output("{$name}\n");
             wfWaitForSlaves($maxlag);
         }
         usleep($throttle * 1000);
     }
     if ($dbw->insert('updatelog', array('ul_key' => 'populate category'), __FUNCTION__, 'IGNORE')) {
         wfOut("Category population complete.\n");
         return true;
     } else {
         wfOut("Could not insert category population row.\n");
         return false;
     }
 }
}
$missing = array();
// from logging
$dbr = wfGetDB(DB_MASTER);
$sth = $dbr->query("select log_user from logging where log_user not in ( select user_id from `wikicities_{$wgDBcluster}`.`user` )");
while ($row = $dbr->fetchObject($sth)) {
    if ($row->log_user != 0) {
        $missing[] = $row->log_user;
    }
}
// from revision
$sth = $dbr->query("select rev_user from revision where rev_user not in ( select user_id from `wikicities_{$wgDBcluster}`.`user` )");
while ($row = $dbr->fetchObject($sth)) {
    if ($row->rev_user != 0) {
        $missing[] = $row->rev_user;
    }
}
$missing = array_unique($missing);
$dbr = wfGetDB(DB_SLAVE, array(), $wgExternalSharedDB);
// main wikicities
$dbw = wfGetDB(DB_MASTER, array(), "wikicities_{$wgDBcluster}");
// local wikicities for cluster
foreach ($missing as $user_id) {
    wfOut("{$user_id} missing on wikicities_{$wgDBcluster}\n");
    $sth = $dbr->select(array("`user`"), array("*"), array("user_id" => $user_id), __METHOD__);
    $user = $dbr->fetchRow($sth);
    $user = array("user_id" => $user["user_id"], "user_name" => $user["user_name"], "user_real_name" => $user["user_real_name"], "user_password" => $user["user_password"], "user_newpassword" => $user["user_newpassword"], "user_email" => $user["user_email"], "user_options" => $user["user_options"], "user_touched" => $user["user_touched"], "user_token" => $user["user_token"], "user_email_authenticated" => $user["user_email_authenticated"], "user_email_token" => $user["user_email_token"], "user_email_token_expires" => $user["user_email_token_expires"], "user_registration" => $user["user_registration"], "user_newpass_time" => $user["user_newpass_time"], "user_editcount" => $user["user_editcount"], "user_birthdate" => $user["user_birthdate"]);
    if ($dbw->insert("user", $user, __METHOD__)) {
        wfOut("{$user["user_id"]} {$user["user_name"]} copied.\n");
    }
}
Exemplo n.º 7
0
$where = array( "user_options not like '%skin=wowwiki%' and user_options not like '%skin=monaco%' and user_options not like '%skin=oasis%' and user_options not like '%skin=monobook%' and user_options not like '%skin=lostbook%'" );

if( isset( $options[ "user-id"] ) ) {
    $where = array( "user_id" => $options[ "user-id"] );
}

$dbr = WikiFactory::db( DB_SLAVE );
$sth = $dbr->select(
	array( "user" ),
	array( "user_id", "user_name" ),
	$where,
	__METHOD__,
	$limits
);

while( $row = $dbr->fetchObject( $sth ) ) {
	$user = User::newFromId( $row->user_id );
	if( $user ) {
		/**
		 * not needed but maybe user changed something meanwhile
		 */
		if( $user->getOption( "skin" ) === "" ) {
			wfOut ("Moving {$user->getName()} ({$user->getId()}) skin preferences from {$user->getOption( "skin" )} to oasis\n");
			$user->setOption( "skin", "oasis" );
			$user->saveSettings();
			$user->invalidateCache();
		}
	}
}
Exemplo n.º 8
0
 * @package MediaWiki
 * @addtopackage maintenance
 * @author eloy@wikia
 *
 * change user_options entry for skin from monaco to oasis
 *
 */
$optionsWithArgs = array('limit', "user-id");
ini_set("include_path", dirname(__FILE__) . "/..");
require_once "commandLine.inc";
$limits = isset($options["limit"]) ? array("LIMIT" => $options["limit"]) : array();
$where = array("user_options not like '%skin=wowwiki%' and user_options not like '%skin=monaco%' and user_options not like '%skin=oasis%' and user_options not like '%skin=monobook%' and user_options not like '%skin=lostbook%'");
if (isset($options["user-id"])) {
    $where = array("user_id" => $options["user-id"]);
}
$dbr = WikiFactory::db(DB_SLAVE);
$sth = $dbr->select(array("user"), array("user_id", "user_name"), $where, __METHOD__, $limits);
while ($row = $dbr->fetchObject($sth)) {
    $user = User::newFromId($row->user_id);
    if ($user) {
        /**
         * not needed but maybe user changed something meanwhile
         */
        if ($user->getGlobalPreference("skin") === "") {
            wfOut("Moving {$user->getName()} ({$user->getId()}) skin preferences from {$user->getGlobalPreference("skin")} to oasis\n");
            $user->setGlobalPreference("skin", "oasis");
            $user->saveSettings();
            $user->invalidateCache();
        }
    }
}