Merge "Add logic for "tags" in ApiBase"
[lhc/web/wiklou.git] / includes / api / ApiBase.php
index 02720c0..a6da823 100644 (file)
@@ -74,6 +74,8 @@ abstract class ApiBase extends ContextSource {
         * - string: Any non-empty string, not expected to be very long or contain newlines.
         *   <input type="text"> would be an appropriate HTML form field.
         * - submodule: The name of a submodule of this module, see PARAM_SUBMODULE_MAP.
+        * - tags: A string naming an existing, explicitly-defined tag. Should usually be
+        *   used with PARAM_ISMULTI.
         * - text: Any non-empty string, expected to be very long or contain newlines.
         *   <textarea> would be an appropriate HTML form field.
         * - timestamp: A timestamp in any format recognized by MWTimestamp, or the
@@ -1063,6 +1065,16 @@ abstract class ApiBase extends ContextSource {
                                                break;
                                        case 'upload': // nothing to do
                                                break;
+                                       case 'tags':
+                                               // If change tagging was requested, check that the tags are valid.
+                                               if ( !is_array( $value ) && !$multi ) {
+                                                       $value = array( $value );
+                                               }
+                                               $tagsStatus = ChangeTags::canAddTagsAccompanyingChange( $value );
+                                               if ( !$tagsStatus->isGood() ) {
+                                                       $this->dieStatus( $tagsStatus );
+                                               }
+                                               break;
                                        default:
                                                ApiBase::dieDebug( __METHOD__, "Param $encParamName's type is unknown - $type" );
                                }