DMaggot has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/84011


Change subject: Implement additionalProperties => true according to
......................................................................

Implement additionalProperties => true according to

http://json-schema.org/latest/json-schema-validation.html#anchor64

Change-Id: I68c9de57e98c013f586591a766560f403209f637
---
M includes/JsonSchema.php
1 file changed, 9 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/EventLogging 
refs/changes/11/84011/1

diff --git a/includes/JsonSchema.php b/includes/JsonSchema.php
index 1b2a1f3..2fe6430 100644
--- a/includes/JsonSchema.php
+++ b/includes/JsonSchema.php
@@ -344,29 +344,27 @@
         */
        public function getMappingChildRef( $key ) {
                $snode = $this->schemaref->node;
-               $nodename = null;
+               $schemadata = array();
+               $nodename = $key;
                if( array_key_exists( 'properties', $snode ) &&
                        array_key_exists( $key, $snode['properties'] ) ) {
                        $schemadata = $snode['properties'][$key];
                        $nodename = isset( $schemadata['title'] ) ? 
$schemadata['title'] : $key;
                }
                elseif ( array_key_exists( 'additionalProperties', $snode ) ) {
-                       // additionalProperties can *either* be false (a 
boolean) or can be
+                       // additionalProperties can *either* be a boolean or 
can be
                        // defined as a schema (an object)
-                       if ( $snode['additionalProperties'] == false ) {
-                               $msg = JsonUtil::uiMessage( 
'jsonschema-invalidkey',
-                                                                               
        $key, $this->getDataPathTitles() );
-                               throw new JsonSchemaException( $msg );
+                       if ( gettype( $snode['additionalProperties'] ) == 
"boolean" ) {
+                           if ( !$snode['additionalProperties'] ) {
+                               $msg = JsonUtil::uiMessage( 
'jsonschema-invalidkey',
+                                                           $key, 
$this->getDataPathTitles() );
+                               throw new JsonSchemaException( $msg );
+                           }
                        }
                        else {
                                $schemadata = $snode['additionalProperties'];
                                $nodename = $key;
                        }
-               }
-               else {
-                       // return the default schema
-                       $schemadata = array();
-                       $nodename = $key;
                }
                $value = $this->node[$key];
                $schemai = $this->schemaindex->newRef( $schemadata, 
$this->schemaref, $key, $key );

-- 
To view, visit https://gerrit.wikimedia.org/r/84011
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I68c9de57e98c013f586591a766560f403209f637
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/EventLogging
Gerrit-Branch: master
Gerrit-Owner: DMaggot <[email protected]>

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

Reply via email to