r101938 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101937‎ | r101938 | r101939 >
Date:01:01, 4 November 2011
Author:reedy
Status:ok
Tags:
Comment:
Add a bit more defensive programming

Added during debugging

Spacing
Modified paths:
  • /trunk/extensions/OpenSearchXml/ApiOpenSearchXml.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenSearchXml/ApiOpenSearchXml.php
@@ -67,11 +67,11 @@
6868 */
6969 protected function inXmlMode() {
7070 $format = $this->validateFormat();
71 - return ($format == 'xml' || $format == 'xmlfm');
 71+ return ( $format == 'xml' || $format == 'xmlfm' );
7272 }
7373
7474 public function execute() {
75 - if (!$this->inXmlMode()) {
 75+ if ( !$this->inXmlMode() ) {
7676 // Pass back to the JSON defaults
7777 parent::execute();
7878 return;
@@ -138,11 +138,14 @@
139139 $item['Url']['*'] = wfExpandUrl( $title->getFullUrl(), PROTO_CURRENT );
140140 if( $image ) {
141141 $thumb = $image->transform( array( 'width' => 50, 'height' => 50 ), 0 );
142 - $item['Image'] = array(
143 - 'source' => wfExpandUrl( $thumb->getUrl(), PROTO_CURRENT ),
144 - //alt
145 - 'width' => $thumb->getWidth(),
146 - 'height' => $thumb->getHeight() );
 142+ if( $thumb ) {
 143+ $item['Image'] = array(
 144+ 'source' => wfExpandUrl( $thumb->getUrl(), PROTO_CURRENT ),
 145+ //alt
 146+ 'width' => $thumb->getWidth(),
 147+ 'height' => $thumb->getHeight()
 148+ );
 149+ }
147150 }
148151 } else {
149152 $item = array( 'Text' => array( '*' => $name ) );

Status & tagging log