content validation, global consistency check
authordaniel <daniel.kinzler@wikimedia.de>
Wed, 23 May 2012 07:30:26 +0000 (09:30 +0200)
committerdaniel <daniel.kinzler@wikimedia.de>
Wed, 23 May 2012 07:37:54 +0000 (09:37 +0200)
includes/Content.php
includes/ContentHandler.php

index c270540..8f505e6 100644 (file)
@@ -201,15 +201,16 @@ abstract class Content {
        }
 
        /**
-        * Returns if the content is valid.
+        * Returns if the content is valid. This is intended for local validity checks, not considering global consistency.
         * It needs to be valid before it can be saved.
         *
+        * This default implementation always returns true.
+        *
         * @since WD.1
         *
         * @return boolean
         */
        public function isValid() {
-               // TODO
                return true;
        }
 
index 80f729b..b2d28d7 100644 (file)
@@ -461,6 +461,22 @@ abstract class ContentHandler {
                }
        }
 
+       /**
+        * Returns if the content is consistent with the database, that is if saving it to the database would not violate any
+        * global constraints.
+        *
+        * Content needs to be valid using this method before it can be saved.
+        *
+        * This default implementation always returns true.
+        *
+        * @since WD.1
+        *
+        * @return boolean
+        */
+       public function isConsistentWithDatabase( Content $content ) {
+               return true;
+       }
+
        /**
         * Returns overrides for action handlers.
         * Classes listed here will be used instead of the default one when