ApiHelp: Avoid header for example, when there no examples
authorumherirrender <umherirrender_de.wp@web.de>
Sun, 26 May 2013 18:48:17 +0000 (20:48 +0200)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 28 May 2013 15:37:41 +0000 (15:37 +0000)
When writing a new extension the source:

public function getExamples() {
return array(
//TODO
);
}

would produce a empty "Example:" header on the help page. Avoid this, by
changing the condition to check for truthy instead of false and empty
string.

Change-Id: I67ecacbbac66b97ed96412abf79b49aebe0ebdbf

includes/api/ApiBase.php

index 7e7365f..c8b05e8 100644 (file)
@@ -304,7 +304,7 @@ abstract class ApiBase extends ContextSource {
                        }
 
                        $examples = $this->getExamples();
-                       if ( $examples !== false && $examples !== '' ) {
+                       if ( $examples ) {
                                if ( !is_array( $examples ) ) {
                                        $examples = array(
                                                $examples