Skip to content

Instantly share code, notes, and snippets.

@bvibber
Created October 6, 2011 00:08
Show Gist options
  • Save bvibber/1266127 to your computer and use it in GitHub Desktop.
Save bvibber/1266127 to your computer and use it in GitHub Desktop.
Index: OpenSearchXml/ApiOpenSearchXml.php
===================================================================
--- OpenSearchXml/ApiOpenSearchXml.php (revision 99057)
+++ OpenSearchXml/ApiOpenSearchXml.php (working copy)
@@ -87,7 +87,11 @@
$srchres = PrefixSearch::titleSearch( $search, $limit, $namespaces );
- $items = array_filter( array_map( array( $this, 'formatItem' ), $srchres ) );
+ try {
+ $items = array_filter( array_map( array( $this, 'formatItem' ), $srchres ) );
+ } catch (Exception $e) {
+ wfDebugLog( 'bug27452', "exception in " . __METHOD__ . "'s array_map(): " . get_class($e) . ": " . $e->toString() );
+ }
$result = $this->getResult();
$result->addValue( null, 'version', '2.0' );
@@ -138,11 +142,15 @@
$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 {
+ wfDebugLog( 'bug27452', "empty \$thumb, would have fataled us" );
+ }
}
} else {
$item = array( 'Text' => array( '*' => $name ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment