API: (bug 19004) Add support for tags. Patch by Matthew Britton
[lhc/web/wiklou.git] / includes / Status.php
index ed1455c..4bceb2e 100644 (file)
@@ -84,6 +84,13 @@ class Status {
                $this->ok = false;
        }
 
+       /**
+        * Sanitize the callback parameter on wakeup, to avoid arbitrary execution.
+        */
+       function __wakeup() {
+               $this->cleanCallback = false;
+       }
+
        protected function cleanParams( $params ) {
                if ( !$this->cleanCallback ) {
                        return $params;
@@ -152,7 +159,7 @@ class Status {
                        if ( $longContext ) {
                                $s = wfMsgNoTrans( $longContext, $s );
                        } elseif ( $shortContext ) {
-                               $s = wfMsgNoTrans( $shortContext, "\n$s\n" );
+                               $s = wfMsgNoTrans( $shortContext, "\n$s\n" );
                        }
                }
                return $s;
@@ -175,8 +182,23 @@ class Status {
                $result = array();
                foreach ( $this->errors as $error ) {
                        if ( $error['type'] == 'error' )
-                               $result[] = $error['message'];
+                               if( $error['params'] )
+                                       $result[] = array_merge( array( $error['message'] ), $error['params'] );
+                               else
+                                       $result[] = $error['message'];
                }
                return $result;
        }
+
+       /**
+        * Returns true if the specified message is present as a warning or error
+        */
+       function hasMessage( $msg ) {
+               foreach ( $this->errors as $error ) {
+                       if ( $error['message'] === $msg ) {
+                               return true;
+                       }
+               }
+               return false;
+       }
 }