https://www.mediawiki.org/wiki/Special:Code/MediaWiki/101938

Revision: 101938
Author:   reedy
Date:     2011-11-04 01:01:13 +0000 (Fri, 04 Nov 2011)
Log Message:
-----------
Add a bit more defensive programming

Added during debugging

Spacing

Modified Paths:
--------------
    trunk/extensions/OpenSearchXml/ApiOpenSearchXml.php

Modified: trunk/extensions/OpenSearchXml/ApiOpenSearchXml.php
===================================================================
--- trunk/extensions/OpenSearchXml/ApiOpenSearchXml.php 2011-11-04 01:00:06 UTC 
(rev 101937)
+++ trunk/extensions/OpenSearchXml/ApiOpenSearchXml.php 2011-11-04 01:01:13 UTC 
(rev 101938)
@@ -67,11 +67,11 @@
         */
        protected function inXmlMode() {
                $format = $this->validateFormat();
-               return ($format == 'xml' || $format == 'xmlfm');
+               return ( $format == 'xml' || $format == 'xmlfm' );
        }
 
        public function execute() {
-               if (!$this->inXmlMode()) {
+               if ( !$this->inXmlMode() ) {
                        // Pass back to the JSON defaults
                        parent::execute();
                        return;
@@ -138,11 +138,14 @@
                        $item['Url']['*'] = wfExpandUrl( $title->getFullUrl(), 
PROTO_CURRENT );
                        if( $image ) {
                                $thumb = $image->transform( array( 'width' => 
50, 'height' => 50 ), 0 );
-                               $item['Image'] = array(
-                                       'source' => wfExpandUrl( 
$thumb->getUrl(), PROTO_CURRENT ),
-                                       //alt
-                                       'width' => $thumb->getWidth(),
-                                       'height' => $thumb->getHeight() );
+                               if( $thumb ) {
+                                       $item['Image'] = array(
+                                               'source' => wfExpandUrl( 
$thumb->getUrl(), PROTO_CURRENT ),
+                                               //alt
+                                               'width' => $thumb->getWidth(),
+                                               'height' => $thumb->getHeight()
+                                       );
+                               }
                        }
                } else {
                        $item = array( 'Text' => array( '*' => $name ) );


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to