[MediaWiki-commits] [Gerrit] Add autofocus option on #forminput - change (mediawiki...SemanticForms)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/156164 Change subject: Add autofocus option on #forminput .. Add autofocus option on #forminput Implement HTML5 autofocus option, allowing the user to type without manually focusing on the forminput control. Change-Id: Ia99a12d4cf3ccfa148354228ef1e2d1294597027 --- M includes/SF_ParserFunctions.php 1 file changed, 6 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticForms refs/changes/64/156164/1 diff --git a/includes/SF_ParserFunctions.php b/includes/SF_ParserFunctions.php index 4807a00..9bdb28e 100644 --- a/includes/SF_ParserFunctions.php +++ b/includes/SF_ParserFunctions.php @@ -189,6 +189,7 @@ $positionalParameters = false; $inAutocompletionSource = ''; $inRemoteAutocompletion = false; + $inAutofocus = false; $inSize = 25; $classStr = ; $inPlaceholder = ; @@ -235,6 +236,8 @@ $autocompletion_type = 'namespace'; } elseif ( $param_name == 'remote autocompletion' ) { $inRemoteAutocompletion = true; +} elseif ( $param_name == null $value == 'autofocus' ) { +$inAutofocus = true; } elseif ( $param_name == 'placeholder' ) { $inPlaceholder = $value; } elseif ( $param_name == null $value == 'popup' ) { @@ -278,6 +281,9 @@ if ( $wgHtml5 ) { $formInputAttrs['placeholder'] = $inPlaceholder; + if ( $inAutofocus ) { + $formInputAttrs['autofocus'] = 'autofocus'; + } } // Now apply the necessary settings and Javascript, depending -- To view, visit https://gerrit.wikimedia.org/r/156164 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia99a12d4cf3ccfa148354228ef1e2d1294597027 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/SemanticForms Gerrit-Branch: master Gerrit-Owner: Jqnatividad joel.nativi...@ontodia.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Added CSS id selector to forminput button - change (mediawiki...SemanticForms)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/155628 Change subject: Added CSS id selector to forminput button .. Added CSS id selector to forminput button makes it easier to style forminput button Change-Id: Ibd72e7236d2700c10f80a687226e960567bfe215 --- M includes/SF_ParserFunctions.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticForms refs/changes/28/155628/1 diff --git a/includes/SF_ParserFunctions.php b/includes/SF_ParserFunctions.php index 1b760cd..d7d0fb9 100644 --- a/includes/SF_ParserFunctions.php +++ b/includes/SF_ParserFunctions.php @@ -343,7 +343,7 @@ $button_str = ( $inButtonStr != '' ) ? $inButtonStr : wfMessage( 'sf_formstart_createoredit' )-escaped(); $str .= END - input type=submit value=$button_str //p + input type=submit value=$button_str id=inputbutton_$input_num//p /form END; -- To view, visit https://gerrit.wikimedia.org/r/155628 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibd72e7236d2700c10f80a687226e960567bfe215 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/SemanticForms Gerrit-Branch: master Gerrit-Owner: Jqnatividad joel.nativi...@ontodia.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Blinking error messages The blink tag is dead. But our use... - change (mediawiki...SemanticForms)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/154881 Change subject: Blinking error messages The blink tag is dead. But our user complains that the error messages are non-obvious in the form. Used HTML5 animation. .. Blinking error messages The blink tag is dead. But our user complains that the error messages are non-obvious in the form. Used HTML5 animation. Change-Id: Iba7dd2dad330a043cbc05453ae6200513a57 --- M skins/SemanticForms.css 1 file changed, 30 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticForms refs/changes/81/154881/1 diff --git a/skins/SemanticForms.css b/skins/SemanticForms.css index da3878f..cb85ceb 100644 --- a/skins/SemanticForms.css +++ b/skins/SemanticForms.css @@ -91,7 +91,37 @@ span.errorMessage { color: red; +animation-name: blinker; +animation-duration: 1s; +animation-iteration-count: infinite; +animation-timing-function: steps(2, start); + +-webkit-animation-name: blinker; +-webkit-animation-duration: 1s; +-webkit-animation-iteration-count: infinite; +-webkit-animation-timing-function: steps(2, start); + +-moz-animation-name: blinker; +-moz-animation-duration: 1s; +-moz-animation-iteration-count: infinite; +-moz-animation-timing-function: steps(2, start); } +@keyframes blinker { +80% { +visibility: hidden; +} +} +@-webkit-keyframes blinker { +80% { +visibility: hidden; +} +} +@-moz-keyframes blinker { +80% { +visibility: hidden; +} +} + .multipleTemplateInstance { background-color: #dd; border: 1px solid #cc; -- To view, visit https://gerrit.wikimedia.org/r/154881 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iba7dd2dad330a043cbc05453ae6200513a57 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/SemanticForms Gerrit-Branch: master Gerrit-Owner: Jqnatividad joel.nativi...@ontodia.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Refactored SMWSQLStore3 long string handling - change (mediawiki...SemanticDrilldown)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/146861 Change subject: Refactored SMWSQLStore3 long string handling .. Refactored SMWSQLStore3 long string handling Faster implementation per MYSQL profiling, since octet_length is an expensive operation. Change-Id: I68b958f312d5fc95f41b542f5a09677cd76a0275 --- M includes/SD_Filter.php M specials/SD_BrowseData.php 2 files changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticDrilldown refs/changes/61/146861/1 diff --git a/includes/SD_Filter.php b/includes/SD_Filter.php index 55d1a33..9c46560 100644 --- a/includes/SD_Filter.php +++ b/includes/SD_Filter.php @@ -175,7 +175,7 @@ $this-db_value_field = 'o_serialized'; } else { // string, text, code $this-db_table_name = 'smw_di_blob'; - $this-db_value_field = '(CASE WHEN octet_length(o_blob) 1 THEN CONVERT(o_blob using utf8) ELSE o_hash END)'; + $this-db_value_field = '(IF(o_blob IS NULL, o_hash, CONVERT(o_blob using utf8)))'; } } else { // Things used to be so simple... diff --git a/specials/SD_BrowseData.php b/specials/SD_BrowseData.php index b0c1436..b7a7e15 100644 --- a/specials/SD_BrowseData.php +++ b/specials/SD_BrowseData.php @@ -361,7 +361,7 @@ $sql .= \n AND $property_field = (SELECT MAX(smw_id) FROM $smwIDs WHERE smw_title = '$property_value' AND smw_namespace = $prop_ns) AND ; if ( $af-filter-property_type === 'date' ) { $value_field = SUBSTRING(a$i.$value_field, 3); - } elseif (strncmp($value_field, '(CASE WHEN', 10) == 0) { + } elseif (strncmp($value_field, '(IF(o_blob IS NULL', 18) === 0) { $value_field = str_replace('o_', a$i.o_, $value_field); } else { $value_field = a$i.$value_field; -- To view, visit https://gerrit.wikimedia.org/r/146861 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I68b958f312d5fc95f41b542f5a09677cd76a0275 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/SemanticDrilldown Gerrit-Branch: master Gerrit-Owner: Jqnatividad joel.nativi...@ontodia.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Added long-string handling - change (mediawiki...SemanticDrilldown)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/146009 Change subject: Added long-string handling .. Added long-string handling When long strings in smw_di_blob are displayed, display readable value, not the value with the hash suffix. Change-Id: I413a75ebaf3c28cf935aa0afebc25ba241e3473a --- M includes/SD_Filter.php M specials/SD_BrowseData.php 2 files changed, 3 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticDrilldown refs/changes/09/146009/1 diff --git a/includes/SD_Filter.php b/includes/SD_Filter.php index 580d486..55d1a33 100644 --- a/includes/SD_Filter.php +++ b/includes/SD_Filter.php @@ -175,7 +175,7 @@ $this-db_value_field = 'o_serialized'; } else { // string, text, code $this-db_table_name = 'smw_di_blob'; - $this-db_value_field = 'o_hash'; + $this-db_value_field = '(CASE WHEN octet_length(o_blob) 1 THEN CONVERT(o_blob using utf8) ELSE o_hash END)'; } } else { // Things used to be so simple... diff --git a/specials/SD_BrowseData.php b/specials/SD_BrowseData.php index a2e64b8..b0c1436 100644 --- a/specials/SD_BrowseData.php +++ b/specials/SD_BrowseData.php @@ -361,6 +361,8 @@ $sql .= \n AND $property_field = (SELECT MAX(smw_id) FROM $smwIDs WHERE smw_title = '$property_value' AND smw_namespace = $prop_ns) AND ; if ( $af-filter-property_type === 'date' ) { $value_field = SUBSTRING(a$i.$value_field, 3); + } elseif (strncmp($value_field, '(CASE WHEN', 10) == 0) { + $value_field = str_replace('o_', a$i.o_, $value_field); } else { $value_field = a$i.$value_field; } -- To view, visit https://gerrit.wikimedia.org/r/146009 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I413a75ebaf3c28cf935aa0afebc25ba241e3473a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/SemanticDrilldown Gerrit-Branch: master Gerrit-Owner: Jqnatividad joel.nativi...@ontodia.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Corrected regex to handle unix domain socket and IPV4 format... - change (mediawiki/core)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/104751 Change subject: Corrected regex to handle unix domain socket and IPV4 formats. IPV6 is not supported for now. .. Corrected regex to handle unix domain socket and IPV4 formats. IPV6 is not supported for now. Change-Id: I92263183ebd21fcb6a13e83b2193d5ddb92659b4 --- M includes/objectcache/MemcachedClient.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/51/104751/1 diff --git a/includes/objectcache/MemcachedClient.php b/includes/objectcache/MemcachedClient.php index 9c0c638..79c5187 100644 --- a/includes/objectcache/MemcachedClient.php +++ b/includes/objectcache/MemcachedClient.php @@ -729,7 +729,7 @@ * @access private */ function _connect_sock( $sock, $host ) { - list( $ip, $port ) = preg_split('/(?!\w):(?=\d)/' , $host ); + list( $ip, $port ) = preg_split('/:(?=\d)/' , $host ); $sock = false; $timeout = $this-_connect_timeout; $errno = $errstr = null; -- To view, visit https://gerrit.wikimedia.org/r/104751 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I92263183ebd21fcb6a13e83b2193d5ddb92659b4 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Jqnatividad joel.nativi...@ontodia.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] changed memcached server parsing to allow for local unix dom... - change (mediawiki/core)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/104663 Change subject: changed memcached server parsing to allow for local unix domain socket connections to local memcached (e.g. unix:///var/run/memcached/memcached.sock:0 ) noticeably increases memcached mediawiki performance .. changed memcached server parsing to allow for local unix domain socket connections to local memcached (e.g. unix:///var/run/memcached/memcached.sock:0 ) noticeably increases memcached mediawiki performance Change-Id: Ie08c151caa09eb0a4269df88965d71c2367c398b --- M includes/objectcache/MemcachedClient.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/63/104663/1 diff --git a/includes/objectcache/MemcachedClient.php b/includes/objectcache/MemcachedClient.php index f0a9128..9c0c638 100644 --- a/includes/objectcache/MemcachedClient.php +++ b/includes/objectcache/MemcachedClient.php @@ -729,7 +729,7 @@ * @access private */ function _connect_sock( $sock, $host ) { - list( $ip, $port ) = explode( ':', $host ); + list( $ip, $port ) = preg_split('/(?!\w):(?=\d)/' , $host ); $sock = false; $timeout = $this-_connect_timeout; $errno = $errstr = null; -- To view, visit https://gerrit.wikimedia.org/r/104663 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie08c151caa09eb0a4269df88965d71c2367c398b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Jqnatividad joel.nativi...@ontodia.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] added $edgSuppressNoLocalVarMsg flag; added MongoDB memcache... - change (mediawiki...ExternalData)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/104472 Change subject: added $edgSuppressNoLocalVarMsg flag; added MongoDB memcached support; removed deprecated MongoDB slaveOkay flag; refactored collection exists logic; added isset check to suppress PHP Notice in apache error log .. added $edgSuppressNoLocalVarMsg flag; added MongoDB memcached support; removed deprecated MongoDB slaveOkay flag; refactored collection exists logic; added isset check to suppress PHP Notice in apache error log Change-Id: I14f019c5cec113ba2950d393e50b6df0957435ac --- M ED_ParserFunctions.php M ED_Utils.php 2 files changed, 25 insertions(+), 18 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ExternalData refs/changes/72/104472/1 diff --git a/ED_ParserFunctions.php b/ED_ParserFunctions.php index c8e09f8..550cbcc 100644 --- a/ED_ParserFunctions.php +++ b/ED_ParserFunctions.php @@ -265,9 +265,9 @@ * Render the #external_value parser function */ static function doExternalValue( $parser, $local_var = '' ) { - global $edgValues; + global $edgValues, $edgSuppressNoLocalVarMsg; if ( ! array_key_exists( $local_var, $edgValues ) ) { - return Error: no local variable \$local_var\ was set.; + return $edgSuppressNoLocalVarMsg ? '' : Error: no local variable \$local_var\ was set.; } elseif ( is_array( $edgValues[$local_var] ) ) { return $edgValues[$local_var][0]; } else { diff --git a/ED_Utils.php b/ED_Utils.php index 7fc0944..5cc28ec 100644 --- a/ED_Utils.php +++ b/ED_Utils.php @@ -286,6 +286,19 @@ * MongoDB. */ static function getMongoDBData( $db_server, $db_username, $db_password, $db_name, $from, $columns, $where, $sqlOptions, $otherParams ) { + global $wgMainCacheType, $wgMemc, $edgMemCachedMongoDBSeconds; + +// use MEMCACHED if configured to cache mongodb queries +if ($wgMainCacheType === CACHE_MEMCACHED $edgMemCachedMongoDBSeconds 0) { + // check if cache entry exists + $mckey = wfMemcKey( 'mongodb', $from, md5(json_encode($otherParams) . json_encode($columns) . $where . json_encode($sqlOptions) . $db_name . $db_server)); + $values = $wgMemc-get( $mckey ); + + if ($values !== false) { + return $values; + } +} + // MongoDB login is done using a single string. // When specifying extra connect string options (e.g. replicasets,timeout, etc.), // use $db_server to pass these values @@ -308,23 +321,13 @@ } 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. - 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 - // getCollectionNames() to check for both. - $collectionNames = $db-getCollectionNames(); - if ( count( $collectionNames ) == 0 ) { - return wfMessage( externaldata-db-could-not-connect )-text(); - } - - if ( !in_array( $from, $collectionNames ) ) { - return wfMessage( externaldata-db-unknown-collection )-text(); - } + // Check if collection exists + if ($db-system-namespaces-findOne(array('name'=$db_name . . . $from)) === null){ +return wfMessage( externaldata-db-unknown-collection:)-text() . $db_name . . . $from; +} $collection = new MongoCollection( $db, $from ); @@ -416,7 +419,7 @@ // specified using dots (e.g., a.b.c), // get the value that way. $values[$column][] = self::getValueFromJSONArray( $doc, $column ); - } elseif ( is_array( $doc[$column] ) ) { + } elseif ( isset( $doc[$column] ) 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. @@ -438,11 +441,15 @@ } } else {
[MediaWiki-commits] [Gerrit] Expanded connect string comments; fully implemented Aggregat... - change (mediawiki...ExternalData)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/78319 Change subject: Expanded connect string comments; fully implemented Aggregation Framework .. Expanded connect string comments; fully implemented Aggregation Framework Change-Id: I8d71c25e76a8d58e5505c9743e67eb43668af0f7 --- M ED_Utils.php 1 file changed, 23 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ExternalData refs/changes/19/78319/1 diff --git a/ED_Utils.php b/ED_Utils.php index c1103f8..becd33a 100644 --- a/ED_Utils.php +++ b/ED_Utils.php @@ -286,6 +286,9 @@ */ static function getMongoDBData( $db_server, $db_username, $db_password, $db_name, $from, $columns, $where, $sqlOptions, $otherParams ) { // MongoDB login is done using a single string. + // When specifying extra connect string options (e.g. replicasets,timeout, etc.), + // use $db_server to pass these values + // see http://docs.mongodb.org/manual/reference/connection-string $connect_string = mongodb://; if ( $db_username != '' ) { $connect_string .= $db_username . ':' . $db_password . '@'; @@ -326,12 +329,18 @@ $findArray = array(); $aggregateArray = array(); - // Was a direct MongoDB find query JSON string provided? - // If so, use that. - if ( array_key_exists( 'find query', $otherParams ) ) { + // Was an aggregation pipeline command issued? + if ( array_key_exists('aggregate', $otherParams ) ) { + // The 'aggregate' parameter should be an array of + // aggregation JSON pipeline commands. // Note to users: be sure to use spaces between curly - // brackets in the 'find' JSON so as not to trip up the + // brackets in the 'aggregate' JSON so as not to trip up the // MW parser. + $aggregateArray = json_decode ($otherParams['aggregate'], true); + } elseif ( array_key_exists( 'find query', $otherParams ) ) { + // Otherwise, was a direct MongoDB find query JSON string provided? + // If so, use that. As with 'aggregate' JSON, use spaces + // between curly brackets $findArray = json_decode ($otherParams['find query'], true); } elseif ( $where != '' ) { // If not, turn the SQL of the where= parameter into @@ -367,7 +376,7 @@ } } - // Do the same for the order= parameter. + // Do the same for the order= parameter as the where= parameter $sortArray = array(); if ( $sqlOptions['ORDER BY'] != '' ) { $sortElements = explode( ',', $sqlOptions['ORDER BY'] ); @@ -386,11 +395,18 @@ // Get the data! if ( array_key_exists( 'aggregate', $otherParams ) ) { - $resultsCursor = $collection-aggregate( $aggregateArray ); + if ( $sqlOptions['ORDER BY'] != '') { + $aggregateArray[] = array( '$sort' = $sortArray ); + } + if ( $sqlOptions['LIMIT'] != '' ) { + $aggregateArray[] = array( '$limit' = intval( $sqlOptions['LIMIT'] ) ); + } + $aggregateResult = $collection-aggregate( $aggregateArray ); + $resultsCursor = $aggregateResult['result']; } else { $resultsCursor = $collection-find( $findArray, $columns )-sort( $sortArray )-limit( $sqlOptions['LIMIT'] ); } - + $values = array(); foreach ( $resultsCursor as $doc ) { foreach ( $columns as $column ) { -- To view, visit https://gerrit.wikimedia.org/r/78319 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8d71c25e76a8d58e5505c9743e67eb43668af0f7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ExternalData Gerrit-Branch: master Gerrit-Owner: Jqnatividad joel.nativi...@ontodia.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Expanded MongoDB connect string comments; fully implemented ... - change (mediawiki...ExternalData)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/77825 Change subject: Expanded MongoDB connect string comments; fully implemented MongoDB aggregation framework support .. Expanded MongoDB connect string comments; fully implemented MongoDB aggregation framework support Change-Id: Ie55e8ad7c8731065bc21e857133b8d831725433c --- M ED_Utils.php 1 file changed, 23 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ExternalData refs/changes/25/77825/1 diff --git a/ED_Utils.php b/ED_Utils.php index c1103f8..becd33a 100644 --- a/ED_Utils.php +++ b/ED_Utils.php @@ -286,6 +286,9 @@ */ static function getMongoDBData( $db_server, $db_username, $db_password, $db_name, $from, $columns, $where, $sqlOptions, $otherParams ) { // MongoDB login is done using a single string. + // When specifying extra connect string options (e.g. replicasets,timeout, etc.), + // use $db_server to pass these values + // see http://docs.mongodb.org/manual/reference/connection-string $connect_string = mongodb://; if ( $db_username != '' ) { $connect_string .= $db_username . ':' . $db_password . '@'; @@ -326,12 +329,18 @@ $findArray = array(); $aggregateArray = array(); - // Was a direct MongoDB find query JSON string provided? - // If so, use that. - if ( array_key_exists( 'find query', $otherParams ) ) { + // Was an aggregation pipeline command issued? + if ( array_key_exists('aggregate', $otherParams ) ) { + // The 'aggregate' parameter should be an array of + // aggregation JSON pipeline commands. // Note to users: be sure to use spaces between curly - // brackets in the 'find' JSON so as not to trip up the + // brackets in the 'aggregate' JSON so as not to trip up the // MW parser. + $aggregateArray = json_decode ($otherParams['aggregate'], true); + } elseif ( array_key_exists( 'find query', $otherParams ) ) { + // Otherwise, was a direct MongoDB find query JSON string provided? + // If so, use that. As with 'aggregate' JSON, use spaces + // between curly brackets $findArray = json_decode ($otherParams['find query'], true); } elseif ( $where != '' ) { // If not, turn the SQL of the where= parameter into @@ -367,7 +376,7 @@ } } - // Do the same for the order= parameter. + // Do the same for the order= parameter as the where= parameter $sortArray = array(); if ( $sqlOptions['ORDER BY'] != '' ) { $sortElements = explode( ',', $sqlOptions['ORDER BY'] ); @@ -386,11 +395,18 @@ // Get the data! if ( array_key_exists( 'aggregate', $otherParams ) ) { - $resultsCursor = $collection-aggregate( $aggregateArray ); + if ( $sqlOptions['ORDER BY'] != '') { + $aggregateArray[] = array( '$sort' = $sortArray ); + } + if ( $sqlOptions['LIMIT'] != '' ) { + $aggregateArray[] = array( '$limit' = intval( $sqlOptions['LIMIT'] ) ); + } + $aggregateResult = $collection-aggregate( $aggregateArray ); + $resultsCursor = $aggregateResult['result']; } else { $resultsCursor = $collection-find( $findArray, $columns )-sort( $sortArray )-limit( $sqlOptions['LIMIT'] ); } - + $values = array(); foreach ( $resultsCursor as $doc ) { foreach ( $columns as $column ) { -- To view, visit https://gerrit.wikimedia.org/r/77825 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie55e8ad7c8731065bc21e857133b8d831725433c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ExternalData Gerrit-Branch: master Gerrit-Owner: Jqnatividad joel.nativi...@ontodia.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Expanded MongoDB connect string comments; fully implemented ... - change (mediawiki...ExternalData)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/77643 Change subject: Expanded MongoDB connect string comments; fully implemented MongoDB aggregation framework support .. Expanded MongoDB connect string comments; fully implemented MongoDB aggregation framework support Change-Id: I73203b6feb6b3b8df851fd3b83df81bbfebfe4d9 --- M ED_Utils.php 1 file changed, 33 insertions(+), 18 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ExternalData refs/changes/43/77643/1 diff --git a/ED_Utils.php b/ED_Utils.php index 3fba289..4758583 100644 --- a/ED_Utils.php +++ b/ED_Utils.php @@ -287,8 +287,10 @@ * 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. + // When specifying extra connect string options (e.g. replicasets,timeout, etc.), + // use $db_server to pass these values + // see http://docs.mongodb.org/manual/reference/connection-string $connect_string = mongodb://; if ( $db_username != '' ) { $connect_string .= $db_username . ':' . $db_password . '@'; @@ -299,19 +301,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 @@ -329,12 +331,18 @@ $findArray = array(); $aggregateArray = array(); - // Was a direct MongoDB find query JSON string provided? - // If so, use that. - if ( array_key_exists( 'find query', $otherParams ) ) { + // Was an aggregation pipeline command issued? + if ( array_key_exists('aggregate', $otherParams ) ) { + // The 'aggregate' parameter should be an array of + // aggregation JSON pipeline commands. // Note to users: be sure to use spaces between curly - // brackets in the 'find' JSON so as not to trip up the + // brackets in the 'aggregate' JSON so as not to trip up the // MW parser. + $aggregateArray = json_decode ($otherParams['aggregate'], true); + } elseif ( array_key_exists( 'find query', $otherParams ) ) { + // Otherwise, was a direct MongoDB find query JSON string provided? + // If so, use that. As with 'aggregate' JSON, use spaces + // between curly brackets $findArray = json_decode ($otherParams['find query'], true); } elseif ( $where != '' ) { // If not, turn the SQL of the where= parameter into @@ -370,7 +378,7 @@ } } - // Do the same for the order= parameter. + // Do the same for the order= parameter as the where= parameter $sortArray = array(); if ( $sqlOptions['ORDER BY'] != '' ) { $sortElements = explode( ',', $sqlOptions['ORDER BY'] ); @@ -389,11 +397,18 @@ // Get the data! if ( array_key_exists( 'aggregate', $otherParams ) ) { - $resultsCursor = $collection-aggregate( $aggregateArray ); + if ( $sqlOptions['ORDER BY'] != '') { + $aggregateArray[] = array( '$sort' = $sortArray ); + } + if (
[MediaWiki-commits] [Gerrit] added urldecode support when parsing name to GeoSearch API. ... - change (mediawiki...GeoData)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/76926 Change subject: added urldecode support when parsing name to GeoSearch API. This allows using spaces (%20), underscores (%5F) and other special characters when specifying the name extra parameter. .. added urldecode support when parsing name to GeoSearch API. This allows using spaces (%20), underscores (%5F) and other special characters when specifying the name extra parameter. Change-Id: Ida346d35bb7e7a328bff82daa543009a2ae250ae --- M api/ApiQueryGeoSearchDb.php 1 file changed, 4 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GeoData refs/changes/26/76926/1 diff --git a/api/ApiQueryGeoSearchDb.php b/api/ApiQueryGeoSearchDb.php index d21ce65..042d744 100644 --- a/api/ApiQueryGeoSearchDb.php +++ b/api/ApiQueryGeoSearchDb.php @@ -73,8 +73,11 @@ foreach( $params['prop'] as $prop ) { if ( isset( Coord::$fieldMapping[$prop] ) isset( $row-{Coord::$fieldMapping[$prop]} ) ) { $field = Coord::$fieldMapping[$prop]; + // If prop is name, urldecode + if ( $prop === 'name' ) { + $vals[$prop] = urldecode($row-$field); // Don't output default globe - if ( !( $prop === 'globe' $row-$field === $wgDefaultGlobe ) ) { + } elseif ( !( $prop === 'globe' $row-$field === $wgDefaultGlobe ) ) { $vals[$prop] = $row-$field; } } -- To view, visit https://gerrit.wikimedia.org/r/76926 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ida346d35bb7e7a328bff82daa543009a2ae250ae Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/GeoData Gerrit-Branch: master Gerrit-Owner: Jqnatividad joel.nativi...@ontodia.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] added connect exception handling to suppress error message t... - change (mediawiki...ExternalData)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/75249 Change subject: added connect exception handling to suppress error message that may reveal sensitive info - e.g. the entire MongoDB connect string; turned on MongoCursor::$slaveOkay so ED will use secondary/slaves in a replica set should the primary/master MongoDB instan .. added connect exception handling to suppress error message that may reveal sensitive info - e.g. the entire MongoDB connect string; turned on MongoCursor::$slaveOkay so ED will use secondary/slaves in a replica set should the primary/master MongoDB instance go down. Change-Id: I346b870d40439fa76875ec91ae4a11957b2278a7 --- M ED_Utils.php 1 file changed, 12 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ExternalData refs/changes/49/75249/1 diff --git a/ED_Utils.php b/ED_Utils.php index 797f39c..3fba289 100644 --- a/ED_Utils.php +++ b/ED_Utils.php @@ -299,9 +299,20 @@ $connect_string .= 'localhost:27017'; } - $m = new MongoClient($connect_string); + // use try catch to suppress error message that shows MongoDB connect string + // that may have sensitive information + try { + $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 + 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 // getCollectionNames() to check for both. -- To view, visit https://gerrit.wikimedia.org/r/75249 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I346b870d40439fa76875ec91ae4a11957b2278a7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ExternalData Gerrit-Branch: master Gerrit-Owner: Jqnatividad joel.nativi...@ontodia.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Added try catch block around MongoClient call to suppress MW... - change (mediawiki...ExternalData)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/72156 Change subject: Added try catch block around MongoClient call to suppress MW error message that shows the entire MongoDB connection string when a connection can't be established. .. Added try catch block around MongoClient call to suppress MW error message that shows the entire MongoDB connection string when a connection can't be established. Change-Id: Id6a4b5476c0eab70290b6c7a88f5253e9fc22bbe --- M ED_Utils.php 1 file changed, 5 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ExternalData refs/changes/56/72156/1 diff --git a/ED_Utils.php b/ED_Utils.php index 797f39c..6e359f6 100644 --- a/ED_Utils.php +++ b/ED_Utils.php @@ -299,7 +299,11 @@ $connect_string .= 'localhost:27017'; } - $m = new MongoClient($connect_string); + try { + $m = new MongoClient($connect_string); + } catch (Exception $e) { + return wfMessage( externaldata-db-could-not-connect )-text(); + } $db = $m-selectDB( $db_name ); // MongoDB doesn't seem to have a way to check whether either -- To view, visit https://gerrit.wikimedia.org/r/72156 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id6a4b5476c0eab70290b6c7a88f5253e9fc22bbe Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ExternalData Gerrit-Branch: master Gerrit-Owner: Jqnatividad joel.nativi...@ontodia.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Added cache seconds parameter to #get_web_data to add per ... - change (mediawiki...ExternalData)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/71722 Change subject: Added cache seconds parameter to #get_web_data to add per query cache settings. Some APIs are fairly static (e.g. Wikipedia places) and some are very dynamic (e.g. Craiglists listings) and having one global cache expire time was insufficient. .. Added cache seconds parameter to #get_web_data to add per query cache settings. Some APIs are fairly static (e.g. Wikipedia places) and some are very dynamic (e.g. Craiglists listings) and having one global cache expire time was insufficient. Change-Id: I7e7b24f985c019fbcdcf16c765a55f5f2059773e --- M ED_ParserFunctions.php M ED_Utils.php 2 files changed, 15 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ExternalData refs/changes/22/71722/1 diff --git a/ED_ParserFunctions.php b/ED_ParserFunctions.php index 752b4a7..accab12 100644 --- a/ED_ParserFunctions.php +++ b/ED_ParserFunctions.php @@ -115,7 +115,7 @@ * Render the #get_web_data parser function */ static function doGetWebData( $parser ) { - global $edgCurPageName, $edgValues; + global $edgCurPageName, $edgValues, $edgCacheExpireTime; // If we're handling multiple pages, reset $edgValues // when we move from one page to another. @@ -164,8 +164,15 @@ return; } + if ( array_key_exists( 'cache seconds', $args) ) { + // set cache expire time + $cacheExpireTime = $args['cache seconds']; + } else { + $cacheExpireTime = $edgCacheExpireTime; + } + $postData = array_key_exists( 'post data', $args ) ? $args['post data'] : ''; - $external_values = EDUtils::getDataFromURL( $url, $format, $mappings, $postData ); + $external_values = EDUtils::getDataFromURL( $url, $format, $mappings, $postData, $cacheExpireTime ); if ( is_string( $external_values ) ) { // It's an error message - just display it on the // screen. diff --git a/ED_Utils.php b/ED_Utils.php index 45e7744..797f39c 100644 --- a/ED_Utils.php +++ b/ED_Utils.php @@ -699,10 +699,10 @@ return $values; } - static function fetchURL( $url, $post_vars = array(), $get_fresh = false, $try_count = 1 ) { + static function fetchURL( $url, $post_vars = array(), $cacheExpireTime = 0, $get_fresh = false, $try_count = 1 ) { $dbr = wfGetDB( DB_SLAVE ); global $edgStringReplacements, $edgCacheTable, - $edgCacheExpireTime, $edgAllowSSL; + $edgAllowSSL; if ( $post_vars ) { return Http::post( $url, array( 'postData' = $post_vars ) ); @@ -729,7 +729,7 @@ // check the cache (only the first 254 chars of the url) $row = $dbr-selectRow( $edgCacheTable, '*', array( 'url' = substr( $url, 0, 254 ) ), 'EDUtils::fetchURL' ); - if ( $row ( ( time() - $row-req_time ) $edgCacheExpireTime ) ) { + if ( $row ( ( time() - $row-req_time ) $cacheExpireTime ) ) { $get_fresh = true; } @@ -746,7 +746,7 @@ return ''; } $try_count++; - return self::fetchURL( $url, $post_vars, $get_fresh, $try_count ); + return self::fetchURL( $url, $post_vars, $cacheExpireTime, $get_fresh, $try_count ); } if ( $page != '' ) { $dbw = wfGetDB( DB_MASTER ); @@ -788,8 +788,8 @@ } } - static public function getDataFromURL( $url, $format, $mappings, $postData = null ) { - $url_contents = self::fetchURL( $url, $postData ); + static public function getDataFromURL( $url, $format, $mappings, $postData = null, $cacheExpireTime ) { + $url_contents = self::fetchURL( $url, $postData, $cacheExpireTime ); // exit if there's nothing there if ( empty( $url_contents ) ) return array(); -- To view, visit https://gerrit.wikimedia.org/r/71722 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7e7b24f985c019fbcdcf16c765a55f5f2059773e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ExternalData Gerrit-Branch: master Gerrit-Owner: Jqnatividad joel.nativi...@ontodia.com ___ MediaWiki-commits mailing list
[MediaWiki-commits] [Gerrit] Added dot notation support for retrieving values from compou... - change (mediawiki...ExternalData)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/71255 Change subject: Added dot notation support for retrieving values from compound MongoDB result documents; added MongoDB aggregate mode .. Added dot notation support for retrieving values from compound MongoDB result documents; added MongoDB aggregate mode Change-Id: I9f2f01e381e74baa62faea0c65da8d7c1b9e23b4 --- M ED_ParserFunctions.php M ED_Utils.php 2 files changed, 37 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ExternalData refs/changes/55/71255/1 diff --git a/ED_ParserFunctions.php b/ED_ParserFunctions.php index 2bc8c92..752b4a7 100644 --- a/ED_ParserFunctions.php +++ b/ED_ParserFunctions.php @@ -253,7 +253,9 @@ $groupBy = ( array_key_exists( 'group by', $args ) ) ? $args['group by'] : null; $sqlOptions = array( 'LIMIT' = $limit, 'ORDER BY' = $orderBy, 'GROUP BY' = $groupBy ); $otherParams = array(); - if ( array_key_exists( 'find query', $args ) ) { + if ( array_key_exists('aggregate', $args ) ) { + $otherParams['aggregate'] = $args['aggregate']; + } elseif ( array_key_exists( 'find query', $args ) ) { $otherParams['find query'] = $args['find query']; } $mappings = EDUtils::paramToArray( $data ); // parse the data arg into mappings diff --git a/ED_Utils.php b/ED_Utils.php index 543d347..e7c8c02 100644 --- a/ED_Utils.php +++ b/ED_Utils.php @@ -266,6 +266,24 @@ return $values; } + + static function dotresolve(array $arrayName, $path, $default = null) + { + $current = $arrayName; + $token = strtok($path, '.'); + + while ($token !== false) { + if (!isset($current[$token])) { + return $default; + } + $current = $current[$token]; + $token = strtok('.'); + } + + return $current; + } + + /** * Handles #get_db_data for the non-relational database system * MongoDB. @@ -301,6 +319,7 @@ $collection = new MongoCollection( $db, $from ); $findArray = array(); + $aggregateArray = array(); // Was a direct MongoDB find query JSON string provided? // If so, use that. if ( array_key_exists( 'find query', $otherParams ) ) { @@ -360,19 +379,26 @@ } // Get the data! - $resultsCursor = $collection-find( $findArray, $columns )-sort( $sortArray )-limit( $sqlOptions['LIMIT'] ); + if ( array_key_exists( 'aggregate', $otherParams ) ) { + $resultsCursor = $collection-aggregate( $aggregateArray ); + } else { + $resultsCursor = $collection-find( $findArray, $columns )-sort( $sortArray )-limit( $sqlOptions['LIMIT'] ); + } $values = array(); foreach ( $resultsCursor as $doc ) { foreach ( $columns as $column ) { - // If MongoDB returns an array for a column, - // do some extra processing. - if ( is_array( $doc[$column] ) ) { - // Check if it's GeoJSON geometry: - // http://www.geojson.org/geojson-spec.html#geometry-objects - // If so, return it in a format that - // the Maps extension can understand. + if ( strstr($column, .) ) { + // If the user specified dot notation to retrieve values from the MongoDB result array + $values[$column][] = self::dotresolve($doc, $column); + } elseif ( is_array( $doc[$column] ) ) { + // If MongoDB returns an array for a column, but the user didnt specify dot notation + // 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 + // If so, return it in a format that + // the Maps extension can understand. $coordinates = $doc['geometry']['coordinates'][0];
[MediaWiki-commits] [Gerrit] Added dot notation support for retrieving values from compou... - change (mediawiki...ExternalData)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/69557 Change subject: Added dot notation support for retrieving values from compound MongoDB result documents .. Added dot notation support for retrieving values from compound MongoDB result documents Change-Id: I1ce049587d5b7a7024fb89dd6278299c90d2947a --- M ED_Utils.php 1 file changed, 28 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ExternalData refs/changes/57/69557/1 diff --git a/ED_Utils.php b/ED_Utils.php index 543d347..9a0c2a5 100644 --- a/ED_Utils.php +++ b/ED_Utils.php @@ -266,6 +266,24 @@ return $values; } + + static function dotresolve(array $a, $path, $default = null) + { + $current = $a; + $p = strtok($path, '.'); + + while ($p !== false) { + if (!isset($current[$p])) { + return $default; + } + $current = $current[$p]; + $p = strtok('.'); + } + + return $current; + } + + /** * Handles #get_db_data for the non-relational database system * MongoDB. @@ -365,14 +383,17 @@ $values = array(); foreach ( $resultsCursor as $doc ) { foreach ( $columns as $column ) { - // If MongoDB returns an array for a column, - // do some extra processing. - if ( is_array( $doc[$column] ) ) { - // Check if it's GeoJSON geometry: - // http://www.geojson.org/geojson-spec.html#geometry-objects - // If so, return it in a format that - // the Maps extension can understand. + if ( strstr($column, .) ) { + // If the user specified dot notation to retrieve values from the MongoDB result array + $values[$column][] = self::dotresolve($doc, $column); + } elseif ( is_array( $doc[$column] ) ) { + // If MongoDB returns an array for a column, but the user didnt specify dot notation + // 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 + // If so, return it in a format that + // the Maps extension can understand. $coordinates = $doc['geometry']['coordinates'][0]; $coordinateStrings = array(); foreach ( $coordinates as $coordinate ) { -- To view, visit https://gerrit.wikimedia.org/r/69557 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1ce049587d5b7a7024fb89dd6278299c90d2947a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ExternalData Gerrit-Branch: master Gerrit-Owner: Jqnatividad joel.nativi...@ontodia.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Added support for MongoDB aggregate function. - change (mediawiki...ExternalData)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/69342 Change subject: Added support for MongoDB aggregate function. .. Added support for MongoDB aggregate function. Change-Id: I2ba299a8976e444ee9bed0200b0cad2b97f06db6 --- M ED_ParserFunctions.php M ED_Utils.php 2 files changed, 11 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ExternalData refs/changes/42/69342/1 diff --git a/ED_ParserFunctions.php b/ED_ParserFunctions.php index 2bc8c92..8b3e60e 100644 --- a/ED_ParserFunctions.php +++ b/ED_ParserFunctions.php @@ -255,6 +255,8 @@ $otherParams = array(); if ( array_key_exists( 'find query', $args ) ) { $otherParams['find query'] = $args['find query']; + } elseif ( array_key_exists('aggregate', $args )) { + $otherParams['aggregate'] = $args['aggregate']; } $mappings = EDUtils::paramToArray( $data ); // parse the data arg into mappings diff --git a/ED_Utils.php b/ED_Utils.php index 543d347..150e9c5 100644 --- a/ED_Utils.php +++ b/ED_Utils.php @@ -301,6 +301,7 @@ $collection = new MongoCollection( $db, $from ); $findArray = array(); + $aggregateArray = array(); // Was a direct MongoDB find query JSON string provided? // If so, use that. if ( array_key_exists( 'find query', $otherParams ) ) { @@ -308,6 +309,9 @@ // brackets in the 'find' JSON so as not to trip up the // MW parser. $findArray = json_decode ($otherParams['find query'], true); + } elseif ( array_key_exists( 'aggregate', $otherParams )) { + // in mongodb aggregation framework mode + $aggregateArray = json_decode ($otherParams['aggregate'], true); } elseif ( $where != '' ) { // If not, turn the SQL of the where= parameter into // a find array for MongoDB. Note that this approach @@ -360,7 +364,11 @@ } // Get the data! - $resultsCursor = $collection-find( $findArray, $columns )-sort( $sortArray )-limit( $sqlOptions['LIMIT'] ); + if ( array_key_exists( 'aggregate', $otherParams )) { + $resultsCursor = $collection-aggregate( $aggregateArray ); + } else { + $resultsCursor = $collection-find( $findArray, $columns )-sort( $sortArray )-limit( $sqlOptions['LIMIT'] ); + } $values = array(); foreach ( $resultsCursor as $doc ) { -- To view, visit https://gerrit.wikimedia.org/r/69342 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2ba299a8976e444ee9bed0200b0cad2b97f06db6 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ExternalData Gerrit-Branch: master Gerrit-Owner: Jqnatividad joel.nativi...@ontodia.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] set SMWDIProperty show flag of subobjects to false to suppre... - change (mediawiki...SemanticMediaWiki)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/64878 Change subject: set SMWDIProperty show flag of subobjects to false to suppress display in factbox. Doesn't make sense to show subobjects in factbox since the display name is non-unique. .. set SMWDIProperty show flag of subobjects to false to suppress display in factbox. Doesn't make sense to show subobjects in factbox since the display name is non-unique. Change-Id: I664f4d078e8bf8f53a89fff6901995036a6144b7 --- M includes/dataitems/SMW_DI_Property.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticMediaWiki refs/changes/78/64878/1 diff --git a/includes/dataitems/SMW_DI_Property.php b/includes/dataitems/SMW_DI_Property.php index edba9ff..d9fa6da 100644 --- a/includes/dataitems/SMW_DI_Property.php +++ b/includes/dataitems/SMW_DI_Property.php @@ -375,7 +375,7 @@ '_SKEY' = array( '__key', false ), // sort key of a page '_SF_DF' = array( '__spf', true ), // Semantic Form's default form property '_SF_AF' = array( '__spf', true ), // Semantic Form's alternate form property - '_SOBJ' = array( '_wpg', true ), // has subobject + '_SOBJ' = array( '_wpg', false ), // has subobject '_ASK' = array( '_wpg', false ), // has query '_ASKST' = array( '_cod', true ), // has query string '_ASKFO' = array( '_str', true ), // has query format -- To view, visit https://gerrit.wikimedia.org/r/64878 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I664f4d078e8bf8f53a89fff6901995036a6144b7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/SemanticMediaWiki Gerrit-Branch: 1.8.x Gerrit-Owner: Jqnatividad joel.nativi...@ontodia.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Added extended handling of MongoDB results. If an answer col... - change (mediawiki...ExternalData)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/63858 Change subject: Added extended handling of MongoDB results. If an answer column is an array, return as JSON. If an answer column is a GeoJSON geometry, return as a string Maps can understand, i.e. latlong pairs delimited by colons. Otherwise, return as usual - as a strin .. Added extended handling of MongoDB results. If an answer column is an array, return as JSON. If an answer column is a GeoJSON geometry, return as a string Maps can understand, i.e. latlong pairs delimited by colons. Otherwise, return as usual - as a string literal. Change-Id: If4198035f06ee8134620457cbb8e00a67f01cd0f --- M ED_Utils.php 1 file changed, 19 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ExternalData refs/changes/58/63858/1 diff --git a/ED_Utils.php b/ED_Utils.php index a4df405..cfcb1c4 100644 --- a/ED_Utils.php +++ b/ED_Utils.php @@ -356,7 +356,25 @@ $values = array(); foreach ( $resultsCursor as $doc ) { foreach ( $columns as $column ) { - $values[$column][] = $doc[$column]; + // if MongoDB returns an array for a column, do some extra processing + if (is_array($doc[$column])) { + // check if its GeoJSON geometry. http://www.geojson.org/geojson-spec.html#geometry-objects + // If so, return it in a format that Maps can understand + if ($column == 'geometry' array_key_exists('coordinates', $doc['geometry'])) { + $coordinates = $doc['geometry']['coordinates'][0]; + $sgeometry = ''; + foreach ($coordinates as $coordinate) { + $sgeometry .= $coordinate[1] . ',' . $coordinate[0] . ':'; + } + $values[$column][] = substr($sgeometry,0,strlen($sgeometry)-1); + } else { + // just return it as a JSON string - the lingua franca of MongoDB + $values[$column][] = json_encode($doc[$column]); + } + } else { + // its a simple literal + $values[$column][] = $doc[$column]; + } } } -- To view, visit https://gerrit.wikimedia.org/r/63858 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If4198035f06ee8134620457cbb8e00a67f01cd0f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ExternalData Gerrit-Branch: master Gerrit-Owner: Jqnatividad joel.nativi...@ontodia.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Incorporated Yaron's suggestion to use a separate parameter ... - change (mediawiki...ExternalData)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/62819 Change subject: Incorporated Yaron's suggestion to use a separate parameter to capture MongoDB Find Query. The new parm, is appropriately named find query. Also changed str_replace with str_ireplace for matching AND LIKE in parsing MongoDB where. .. Incorporated Yaron's suggestion to use a separate parameter to capture MongoDB Find Query. The new parm, is appropriately named find query. Also changed str_replace with str_ireplace for matching AND LIKE in parsing MongoDB where. Change-Id: I9438fa2dc54d9c3d3f1de1eec984b998ee4f3093 --- M ED_ParserFunctions.php M ED_Utils.php 2 files changed, 38 insertions(+), 41 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ExternalData refs/changes/19/62819/1 diff --git a/ED_ParserFunctions.php b/ED_ParserFunctions.php index 93c0f05..44a3919 100644 --- a/ED_ParserFunctions.php +++ b/ED_ParserFunctions.php @@ -248,10 +248,11 @@ } $table = ( array_key_exists( 'from', $args ) ) ? $args['from'] : null; $conds = ( array_key_exists( 'where', $args ) ) ? $args['where'] : null; + $findQuery = ( array_key_exists( 'find query', $args ) ) ? $args['find query'] : null; $limit = ( array_key_exists( 'limit', $args ) ) ? $args['limit'] : null; $orderBy = ( array_key_exists( 'order by', $args ) ) ? $args['order by'] : null; $groupBy = ( array_key_exists( 'group by', $args ) ) ? $args['group by'] : null; - $options = array( 'LIMIT' = $limit, 'ORDER BY' = $orderBy, 'GROUP BY' = $groupBy ); + $options = array( 'LIMIT' = $limit, 'ORDER BY' = $orderBy, 'GROUP BY' = $groupBy, 'FIND QUERY' = $findQuery ); $mappings = EDUtils::paramToArray( $data ); // parse the data arg into mappings $external_values = EDUtils::getDBData( $dbID, $table, array_values( $mappings ), $conds, $options ); diff --git a/ED_Utils.php b/ED_Utils.php index ae90bb1..33845f5 100644 --- a/ED_Utils.php +++ b/ED_Utils.php @@ -291,47 +291,43 @@ $collection = new MongoCollection( $db, $from ); - // Turn the SQL of the where= parameter into the appropriate - // array for MongoDB. - $whereArray = array(); - if ( $where != '' ) { - - // if the string 'PASSTHRU' is used, then just passthrough the - // JSON MongoDB find condition as a JSON string. This is necessary so we don't try + $findArray = array(); + // Was a direct MongoDB find query JSON string provided? + if ( $options['FIND QUERY'] != '' ) { + // if FIND QUERY is used, then just passthrough the + // JSON MongoDB FIND query as a JSON string. This is necessary so we don't try // to create a MongoDB find parser in ExternalData to accomodate all the possible // find scenarios since MongoDB is NotSQL :). Be sure to use spaces between curly - // brackets so as not to trip up the MW parser - if ( substr($where, 0, 10) == 'PASSTHRU' ) { - $whereArray = json_decode (substr($where, 10), true); - } else { - // Hopefully all-caps and all-lowercase are the only - // two variants that people will use - otherwise, - // preg_replace() should be used. - $where = str_replace( ' and ', ' AND ', $where ); - $where = str_replace( ' like ', ' LIKE ', $where ); - $whereElements = explode( ' AND ', $where ); - foreach ( $whereElements as $whereElement ) { - if ( strpos( $whereElement, '=' ) ) { - list( $fieldName, $value ) = explode( '=', $whereElement ); - $whereArray[trim( $fieldName )] = array( '$gte' = trim( $value ) ); - } elseif ( strpos( $whereElement, '' ) ) { - list( $fieldName, $value ) = explode( '', $whereElement ); - $whereArray[trim( $fieldName )] = array( '$gt' = trim( $value ) ); - } elseif ( strpos( $whereElement, '=' ) ) { - list( $fieldName, $value ) = explode( '=', $whereElement ); - $whereArray[trim( $fieldName )] = array( '$lte' = trim(
[MediaWiki-commits] [Gerrit] Corrected connectstring concatenation. Removed debugging mes... - change (mediawiki...ExternalData)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/62916 Change subject: Corrected connectstring concatenation. Removed debugging message. Tweaked typo in comments. .. Corrected connectstring concatenation. Removed debugging message. Tweaked typo in comments. Change-Id: I48e9afd0e6ad37618986b475b3d48f890cdbf6aa --- M ED_Utils.php 1 file changed, 3 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ExternalData refs/changes/16/62916/1 diff --git a/ED_Utils.php b/ED_Utils.php index 9782f45..a4df405 100644 --- a/ED_Utils.php +++ b/ED_Utils.php @@ -266,7 +266,7 @@ // construct connect string $connect_string = mongodb://; if ( $db_username != '' ) { - $connect_string .= $db_username . ':' . $db_password + '@'; + $connect_string .= $db_username . ':' . $db_password . '@'; } if ( $db_server != '') { $connect_string .= $db_server; @@ -295,8 +295,7 @@ // Was a direct MongoDB find query JSON string provided? // If so, use that. if ( array_key_exists( 'find query', $otherParams ) ) { -die('got here!'); - // Not to users: be sure to use spaces between curly + // Note to users: be sure to use spaces between curly // brackets in the 'find' JSON so as not to trip up the // MW parser. $findArray = json_decode ($otherParams['find query'], true); @@ -305,7 +304,7 @@ // a find array for MongoDB. Note that this approach // is only appropriate for simple find queries, that // use the operators OR, AND, =, , =, and LIKE - // - and NO NUMBER LITERALS. + // - and NO NUMERIC LITERALS. $where = str_ireplace( ' and ', ' AND ', $where ); $where = str_ireplace( ' like ', ' LIKE ', $where ); $whereElements = explode( ' AND ', $where ); -- To view, visit https://gerrit.wikimedia.org/r/62916 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I48e9afd0e6ad37618986b475b3d48f890cdbf6aa Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ExternalData Gerrit-Branch: master Gerrit-Owner: Jqnatividad joel.nativi...@ontodia.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Changed MongoDB connect to use connect string giving flexibi... - change (mediawiki...ExternalData)
Jqnatividad has uploaded a new change for review. https://gerrit.wikimedia.org/r/62774 Change subject: Changed MongoDB connect to use connect string giving flexibility to connect to remote host, specify port, etc. Also, MongoDB authenticate function has been deprecated. .. Changed MongoDB connect to use connect string giving flexibility to connect to remote host, specify port, etc. Also, MongoDB authenticate function has been deprecated. Also added PASSTHRU mode for specifying FIND condition. MongoDB is NotSQL, so trying to convert where clause to MongoDB Find JSON string, accounting for all of MongoDB's syntax will be too complex. Also PASSTHRU mode allowed user to specify number literals and use the exact same Find JSON string used in Mongo. Change-Id: I21a4ca2f85efce3799541f5427efc97ac719cb84 --- M ED_Utils.php 1 file changed, 50 insertions(+), 31 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ExternalData refs/changes/74/62774/1 diff --git a/ED_Utils.php b/ED_Utils.php index 52a2cbc..ae90bb1 100644 --- a/ED_Utils.php +++ b/ED_Utils.php @@ -159,7 +159,7 @@ $db_tableprefix = self::getArrayValue( $edgDBTablePrefix, $dbID ); // MongoDB has entirely different handling from the rest. - if ( $db_type == mongodb ) { + if ( $db_type == 'mongodb' ) { if ( $db_name == '' ) { return wfMessage( externaldata-db-incomplete-information )-text(); } @@ -262,11 +262,20 @@ * MongoDB. */ static function getMongoDBData( $db_server, $db_username, $db_password, $db_name, $from, $columns, $where, $options ) { - $m = new MongoClient(); - $db = $m-selectDB( $db_name ); + + // construct connect string + $connect_string = mongodb://; if ( $db_username != '' ) { - $db-authenticate( $db_username, $db_password ); + $connect_string .= $db_username . ':' . $db_password + '@'; } + if ( $db_server != '') { + $connect_string .= $db_server; + } else { + $connect_string .= 'localhost:27017'; + } + + $m = new MongoClient($connect_string); + $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 @@ -286,33 +295,43 @@ // array for MongoDB. $whereArray = array(); if ( $where != '' ) { - // Hopefully all-caps and all-lowercase are the only - // two variants that people will use - otherwise, - // preg_replace() should be used. - $where = str_replace( ' and ', ' AND ', $where ); - $where = str_replace( ' like ', ' LIKE ', $where ); - $whereElements = explode( ' AND ', $where ); - foreach ( $whereElements as $whereElement ) { - if ( strpos( $whereElement, '=' ) ) { - list( $fieldName, $value ) = explode( '=', $whereElement ); - $whereArray[trim( $fieldName )] = array( '$gte' = trim( $value ) ); - } elseif ( strpos( $whereElement, '' ) ) { - list( $fieldName, $value ) = explode( '', $whereElement ); - $whereArray[trim( $fieldName )] = array( '$gt' = trim( $value ) ); - } elseif ( strpos( $whereElement, '=' ) ) { - list( $fieldName, $value ) = explode( '=', $whereElement ); - $whereArray[trim( $fieldName )] = array( '$lte' = trim( $value ) ); - } elseif ( strpos( $whereElement, '' ) ) { - list( $fieldName, $value ) = explode( '', $whereElement ); - $whereArray[trim( $fieldName )] = array( '$lt' = trim( $value ) ); - } elseif ( strpos( $whereElement, ' LIKE ' ) ) { - list( $fieldName, $value ) = explode( ' LIKE ', $whereElement ); - $value = trim( $value ); - $regex = new MongoRegex( /$value/i ); - $whereArray[trim( $fieldName )] = $regex; - } else { - list( $fieldName, $value ) = explode( '=', $whereElement