Jump to content

Topic on Extension talk:HitCounters

WikiForMen (talkcontribs)

1. In HCUpdater.php the stuff around 'rename_table.sql' should be removed, because it is only needed in MediaWiki in Version 1.25.

2. In HitCounters.hooks.php the "$contLang->formatNum()" does not set the punctuation correctly in the internationalisation of the comma number:

		$totalViews = HitCounters::views() ?? 0;
		$extraStats = [
			'hitcounters-statistics-header-views' => [
				'hitcounters-statistics-views-total' => $totalViews,
				'hitcounters-statistics-views-peredit' => $contLang->formatNum(
					$totalViews
					? sprintf( '%.2f', $totalViews / SiteStats::edits() )
					: 0
				) ],
			'hitcounters-statistics-mostpopular' => self::getMostViewedPages( $statsPage )
		];

Moreover, it does not prevent the division by zero.

This should do the job accurately:

		$totalEdits = SiteStats::edits() ?? 0;
		$totalViews = HitCounters::views() ?? 0;
		$extraStats['hitcounters-statistics-header-views']
			['hitcounters-statistics-views-total'] = $totalViews;
		$extraStats['hitcounters-statistics-header-views']
			['hitcounters-statistics-views-peredit'] =
				( $totalEdits > 0 )
				? sprintf( '%.2f', $totalViews / $totalEdits )
				: 0;
				) ],
			'hitcounters-statistics-mostpopular' => self::getMostViewedPages( $statsPage )
		];

3. In SpecialPopularPages.php, what exactly is "getPrefixedText()" doing here?

		$link = $this->getLinkRenderer()->makeKnownLink(
			$title,
			$this->getContentLanguage()->convert( $title->getPrefixedText() )
		);

I guess, this is doing the job as well:

		$link = $this->getLinkRenderer()->makeKnownLink( $title )
		);

--WikiForMen (talk) 18:55, 4 October 2023 (UTC)

Pppery (talkcontribs)
Reply to "Code Review"