Ejemplo n.º 1
0
 public static function invalidateCache(&$article, &$user, $text, $summary, $minoredit, &$watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId)
 {
     $ids = array();
     $name = $article->mTitle->getText();
     list($key, $lang) = explode($name, 2);
     // check if this is a valid language variant
     if (Language::getLanguageName($lang) == '') {
         return true;
     }
     // match message to group here
     $groups = TranslateUtils::messageKeyToGroups($article->mTitle->getNamespace(), $key);
     if (empty($groups)) {
         // message does not belong to any recognized group
         return true;
     }
     foreach ($groups as $group) {
         /* @var $group MessageGroup */
         $ids[] = $group->getId();
     }
     $conds = array('gs_group' => $ids, 'gs_lang' => $lang);
     $dbw = wfGetDB(DB_MASTER);
     // @TODO maybe update instaed of delete
     $dbw->delete('groupstats', $conds, __METHOD__);
     return true;
 }
Ejemplo n.º 2
0
	public function getGroupIds() {
		if ( $this->groupIds === null ) {
			$this->groupIds = TranslateUtils::messageKeyToGroups( $this->getTitle()->getNamespace(), $this->getKey() );
		}
		return $this->groupIds;
	}
	public function indexOf( $row ) {
		// We need to check that there is only one user per day.
		if ( $this->opts['count'] === 'users' ) {
			$date = $this->formatTimestamp( $row->rc_timestamp );

			if ( isset( $this->usercache[$date][$row->rc_user_text] ) ) {
				return -1;
			} else {
				$this->usercache[$date][$row->rc_user_text] = 1;
			}
		}

		// Do not consider language-less pages.
		if ( strpos( $row->rc_title, '/' ) === false ) {
			return false;
		}

		// No filters, just one key to track.
		if ( !$this->groups && !$this->codes ) {
			return 'all';
		}

		// The key-building needs to be in sync with ::labels().
		list( $key, $code ) = TranslateUtils::figureMessage( $row->rc_title );

		$groups = array();
		$codes = array();

		if ( $this->groups ) {
			/*
			 * Get list of keys that the message belongs to, and filter
			 * out those which are not requested.
			 */
			$groups = TranslateUtils::messageKeyToGroups( $row->rc_namespace, $key );
			$groups = array_intersect( $this->groups, $groups );
		}

		if ( $this->codes ) {
			$codes = array( $code );
		}

		return $this->combineTwoArrays( $groups, $codes );
	}