From d01379dd18d800b833d254fa8107e6941d82d0cd Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Mon, 27 Jul 2009 19:26:31 +0000
Subject: [PATCH] - Patch #522184 by stBorchert: remove the 'minimum number of
 words' feature from Drupal.

---
 modules/node/content_types.inc              |  8 --------
 modules/node/node.api.php                   |  2 --
 modules/node/node.install                   | 16 +++++++++-------
 modules/node/node.module                    |  9 ---------
 modules/simpletest/drupal_web_test_case.php |  1 -
 5 files changed, 9 insertions(+), 27 deletions(-)

diff --git a/modules/node/content_types.inc b/modules/node/content_types.inc
index 88bda07541bf..d869153de709 100644
--- a/modules/node/content_types.inc
+++ b/modules/node/content_types.inc
@@ -129,13 +129,6 @@ function node_type_form(&$form_state, $type = NULL) {
     '#default_value' => isset($type->body_label) ? $type->body_label : '',
     '#description' => t('To omit the body field for this content type, remove any text and leave this field blank.'),
   );
-  $form['submission']['min_word_count'] = array(
-    '#type' => 'select',
-    '#title' => t('Minimum number of words'),
-    '#default_value' => $type->min_word_count,
-    '#options' => drupal_map_assoc(array(0, 1, 10, 25, 50, 75, 100, 125, 150, 175, 200)),
-    '#description' => t('The minimum number of words for the body field to be considered valid for this content type. This can be useful to rule out submissions that do not meet the site\'s standards, such as short test posts.')
-  );
   $form['submission']['node_preview'] = array(
     '#type' => 'radios',
     '#title' => t('Preview post'),
@@ -289,7 +282,6 @@ function node_type_form_submit($form, &$form_state) {
 
   $type->description = $form_state['values']['description'];
   $type->help = $form_state['values']['help'];
-  $type->min_word_count = $form_state['values']['min_word_count'];
   $type->title_label = $form_state['values']['title_label'];
   $type->body_label = $form_state['values']['body_label'];
 
diff --git a/modules/node/node.api.php b/modules/node/node.api.php
index 9938a6f9f58f..42ba87971a52 100644
--- a/modules/node/node.api.php
+++ b/modules/node/node.api.php
@@ -540,8 +540,6 @@ function hook_node_build_alter($node, $build_mode) {
  *      field. Optional (defaults to TRUE).
  *   - "body_label": the label for the body field of this content type. Optional
  *      (defaults to 'Body').
- *   - "min_word_count": the minimum number of words for the body field to be
- *      considered valid for this content type. Optional (defaults to 0).
  *   - "locked": boolean indicating whether the machine-readable name of this
  *      content type can (FALSE) or cannot (TRUE) be edited by a site
  *      administrator. Optional (defaults to TRUE).
diff --git a/modules/node/node.install b/modules/node/node.install
index d81626f52bd1..26f4f81a36d9 100644
--- a/modules/node/node.install
+++ b/modules/node/node.install
@@ -299,13 +299,6 @@ function node_schema() {
         'not null' => TRUE,
         'default' => '',
       ),
-      'min_word_count' => array(
-        'description' => 'The minimum number of words the body must contain.',
-        'type' => 'int',
-        'unsigned' => TRUE,
-        'not null' => TRUE,
-        'size' => 'small',
-      ),
       'custom' => array(
         'description' => 'A boolean indicating whether this type is defined by a module (FALSE) or by a user via a module like the Content Construction Kit (TRUE).',
         'type' => 'int',
@@ -523,6 +516,15 @@ function node_update_7005(&$context) {
   return $ret;
 }
 
+/**
+ * Remove column min_word_count.
+ */
+function node_update_7006() {
+  $ret = array();
+  db_drop_field($ret, 'node_type', 'min_word_count');
+  return $ret;
+}
+
 
 
 /**
diff --git a/modules/node/node.module b/modules/node/node.module
index 0453b3226ea5..a81815682c6d 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -416,7 +416,6 @@ function node_type_save($info) {
     'body_label' => (string) $type->body_label,
     'description' => (string) $type->description,
     'help' => (string) $type->help,
-    'min_word_count' => (int) $type->min_word_count,
     'custom' => (int) $type->custom,
     'modified' => (int) $type->modified,
     'locked' => (int) $type->locked,
@@ -611,7 +610,6 @@ function node_type_set_defaults($info = array()) {
     $type->base = '';
     $type->description = '';
     $type->help = '';
-    $type->min_word_count = 0;
     $type->has_title = 1;
     $type->has_body = 1;
     $type->title_label = t('Title');
@@ -860,13 +858,6 @@ function node_validate($node, $form = array()) {
   $node = (object)$node;
   $type = node_type_get_type($node);
 
-  // Make sure the body has the minimum number of words.
-  // TODO : use a better word counting algorithm that will work in other languages
-  if (!empty($type->min_word_count) && isset($node->body[0]['value']) && count(explode(' ', $node->body[0]['value'])) < $type->min_word_count) {
-    // TODO: Use Field API to set this error.
-    form_set_error('body', t('The body of your @type is too short. You need at least %words words.', array('%words' => $type->min_word_count, '@type' => $type->name)));
-  }
-
   if (isset($node->nid) && (node_last_changed($node->nid) > $node->changed)) {
     form_set_error('changed', t('The content on this page has either been modified by another user, or you have already submitted modifications using this form. As a result, your changes cannot be saved.'));
   }
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index f04c99ec0f62..591224b7cce3 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -750,7 +750,6 @@ protected function drupalCreateContentType($settings = array()) {
       'name' => $name,
       'description' => '',
       'help' => '',
-      'min_word_count' => 0,
       'title_label' => 'Title',
       'body_label' => 'Body',
       'has_title' => 1,
-- 
GitLab