Yaron Koren has submitted this change and it was merged. Change subject: Small improvements to syntax and comments ......................................................................
Small improvements to syntax and comments Change-Id: Ifc1b1722a2d3efdaecf7562b211ccc571a37a153 --- M ED_ParserFunctions.php M ED_Utils.php 2 files changed, 14 insertions(+), 17 deletions(-) Approvals: Yaron Koren: Verified; Looks good to me, approved diff --git a/ED_ParserFunctions.php b/ED_ParserFunctions.php index accab12..9b55251 100644 --- a/ED_ParserFunctions.php +++ b/ED_ParserFunctions.php @@ -316,8 +316,8 @@ static function doForExternalTable( &$parser, $expression = '' ) { global $edgValues; - // get the variables used in this expression, get the number - // of values for each, and loop through + // Get the variables used in this expression, get the number + // of values for each, and loop through. $matches = array(); preg_match_all( '/{{{([^}]*)}}}/', $expression, $matches ); $variables = $matches[1]; @@ -464,8 +464,8 @@ $params = func_get_args(); array_shift( $params ); // we already know the $parser... - // get the variables used in this expression, get the number - // of values for each, and loop through + // Get the variables used in this expression, get the number + // of values for each, and loop through. $expression = implode( '|', $params ); $matches = array(); preg_match_all( '/{{{([^}]*)}}}/', $expression, $matches ); diff --git a/ED_Utils.php b/ED_Utils.php index 3fba289..c1103f8 100644 --- a/ED_Utils.php +++ b/ED_Utils.php @@ -266,7 +266,6 @@ return $values; } - static function getValueFromJSONArray( array $origArray, $path, $default = null ) { $current = $origArray; $token = strtok( $path, '.' ); @@ -281,14 +280,12 @@ return $current; } - /** * Handles #get_db_data for the non-relational database system * MongoDB. */ static function getMongoDBData( $db_server, $db_username, $db_password, $db_name, $from, $columns, $where, $sqlOptions, $otherParams ) { - - // construct connect string + // MongoDB login is done using a single string. $connect_string = "mongodb://"; if ( $db_username != '' ) { $connect_string .= $db_username . ':' . $db_password . '@'; @@ -299,19 +296,19 @@ $connect_string .= 'localhost:27017'; } - // use try catch to suppress error message that shows MongoDB connect string - // that may have sensitive information + // Use try/catch to suppress error messages, which would show + // the MongoDB connect string, which may have sensitive + // information. try { - $m = new MongoClient($connect_string); - } catch (Exception $e) { + $m = new MongoClient( $connect_string ); + } catch ( Exception $e ) { return wfMessage( "externaldata-db-could-not-connect" )->text(); } - // if working against a MongoDB replica set, it's OK to go to secondary/slaves - // should the primary go down + // If working against a MongoDB replica set, it's OK to go to + // secondary/slaves should the primary go down. MongoCursor::$slaveOkay = true; $db = $m->selectDB( $db_name ); - // MongoDB doesn't seem to have a way to check whether either // a database or a collection exists, so instead we'll use @@ -401,14 +398,14 @@ // If the exact path of the value was // specified using dots (e.g., "a.b.c"), // get the value that way. - $values[$column][] = self::getValueFromJSONArray( $doc, $column ); + $values[$column][] = self::getValueFromJSONArray( $doc, $column ); } elseif ( is_array( $doc[$column] ) ) { // If MongoDB returns an array for a column, // but the exact location of the value wasn't specified, // do some extra processing. if ( $column == 'geometry' && array_key_exists( 'coordinates', $doc['geometry'] ) ) { // Check if it's GeoJSON geometry: - // http://www.geojson.org/geojson-spec.html#geometry-objects + // http://www.geojson.org/geojson-spec.html#geometry-objects // If so, return it in a format that // the Maps extension can understand. $coordinates = $doc['geometry']['coordinates'][0]; -- To view, visit https://gerrit.wikimedia.org/r/76724 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ifc1b1722a2d3efdaecf7562b211ccc571a37a153 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ExternalData Gerrit-Branch: master Gerrit-Owner: Yaron Koren <yaro...@gmail.com> Gerrit-Reviewer: Yaron Koren <yaro...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits