r76139 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76138‎ | r76139 | r76140 >
Date:20:47, 5 November 2010
Author:hashar
Status:ok (Comments)
Tags:
Comment:
Fix PHP warning in tag cloud when there is no tag

The tag cloud system use max() on an array of tags. When there is no
tag, it is equivalent to max( array() ) which raise a warning.
Added a message instead :b
Modified paths:
  • /trunk/extensions/CodeReview/CodeReview.i18n.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/CodeTagListView.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/WordCloud.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeReview.i18n.php
@@ -31,6 +31,7 @@
3232 'code-authors' => 'authors',
3333 'code-status' => 'states',
3434 'code-tags' => 'tags',
 35+ 'code-tags-no-tags' => 'No tags exist in this repository.',
3536 'code-authors-text' => 'Below is a list of repo authors in order of commit name. Local wiki accounts are shown in parentheses. Data may be cached.',
3637 'code-author-haslink' => 'This author is linked to the wiki user $1',
3738 'code-author-orphan' => 'This author has no link with a wiki account',
Index: trunk/extensions/CodeReview/ui/CodeTagListView.php
@@ -12,8 +12,13 @@
1313 $name = $this->mRepo->getName();
1414 $list = $this->mRepo->getTagList();
1515
16 - $tc = new WordCloud( $list, array( $this, 'linkCallback' ) );
17 - $wgOut->addHTML( $tc->showCloud() );
 16+ if( 0 === count( $list ) ) {
 17+ $wgOut->addWikiText( wfMsg( 'code-tags-no-tags' ) );
 18+ } else {
 19+ # Show a cloud made of tags
 20+ $tc = new WordCloud( $list, array( $this, 'linkCallback' ) );
 21+ $wgOut->addHTML( $tc->showCloud() );
 22+ }
1823 }
1924
2025 public function linkCallback( $tag, $weight ) {
Index: trunk/extensions/CodeReview/ui/WordCloud.php
@@ -85,6 +85,9 @@
8686 * @return String
8787 */
8888 public function showCloud() {
 89+ if( 0 === count( $this->wordsArray ) ) {
 90+ return;
 91+ }
8992 $this->shuffleCloud();
9093 $max = max( $this->wordsArray );
9194 if( is_array( $this->wordsArray ) ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r76381Shorter method to add a wiki message to the output...hashar07:22, 9 November 2010

Comments

#Comment by Nikerabbit (talk | contribs)   21:10, 5 November 2010

+$wgOut->addWikiText( wfMsg( 'code-tags-no-tags' ) ); Nowdays we use

$wgOut->addWikiMsg( 'code-tags-no-tags' );
#Comment by Hashar (talk | contribs)   07:23, 9 November 2010

Resolved in r76381. Resetting to new.

Status & tagging log