r23195 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23194‎ | r23195 | r23196 >
Date:03:47, 22 June 2007
Author:greg
Status:old
Tags:
Comment:
Don't try to access array if it's empty.
Modified paths:
  • /trunk/extensions/BreadCrumbs/BreadCrumbsFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/BreadCrumbs/BreadCrumbsFunctions.php
@@ -25,11 +25,13 @@
2626 if( isset( $_SESSION['BreadCrumbs'] ) ) $m_BreadCrumbs = $_SESSION['BreadCrumbs'];
2727 # cache index of last element:
2828 $m_count = count( $m_BreadCrumbs ) - 1;
29 -
 29+
3030 # check for doubles:
31 - if( $m_BreadCrumbs[ $m_count ] != $wgTitle->getPrefixedText() ) {
32 - # reduce the array set, remove older elements:
33 - $m_BreadCrumbs = array_slice( $m_BreadCrumbs, ( 1 - $wgBreadCrumbsCount ) );
 31+ if( $m_count < 1 || $m_BreadCrumbs[ $m_count ] != $wgTitle->getPrefixedText() ) {
 32+ if( $m_count >= 1) {
 33+ # reduce the array set, remove older elements:
 34+ $m_BreadCrumbs = array_slice( $m_BreadCrumbs, ( 1 - $wgBreadCrumbsCount ) );
 35+ }
3436 # add new page:
3537 array_push( $m_BreadCrumbs, $wgTitle->getPrefixedText() );
3638 }
@@ -37,7 +39,7 @@
3840 $_SESSION['BreadCrumbs'] = $m_BreadCrumbs;
3941 # update cache:
4042 $m_count = count( $m_BreadCrumbs ) - 1;
41 -
 43+
4244 # acquire a skin object:
4345 $m_skin =& $wgUser->getSkin();
4446 # build the breadcrumbs trail:
@@ -48,11 +50,11 @@
4951 }
5052 $m_trail .= '</div>';
5153 $wgOut->addHTML( $m_trail );
52 -
 54+
5355 # invalidate internal MediaWiki cache:
5456 $wgTitle->invalidateCache();
5557 $wgUser->invalidateCache();
56 -
 58+
5759 # Return true to let the rest work:
5860 return true;
5961 }

Status & tagging log