The explode function looks for spaces, and so misses line and paragraph breaks. Improving this algorithm was listed as a TODO in the code, but it specifically referred to doing a better job for foreign languages and I'm not sure what the approach would be there.

I also haven't looked to see if this has changed in six, nor if there might be a CCK way that is superior. Just raising the issue and offering to try and make a patch if there's any thoughts/consensus on the approach for the word-count algorithm.

More notes here:

http://agaricdesign.com/note/allow-textfields-be-required-but-fewer-10-w...

(Below notes mostly about a related issue-- 10 is pretty high as the minimum number of words for merely requiring a node body. If there's interest in a patch for that, or knowledge of a contributed module that form_alters this or would be a good home for a tweak allowing a lower minimum word count, please let Agaric know.)

Comments

Guillaume Beaulieu’s picture

Assigned: Unassigned » Guillaume Beaulieu

I'll fix that

Guillaume Beaulieu’s picture

StatusFileSize
new1.14 KB

I've included a patch to change explode(' ', $str) into pregsplit('[\s]+', $str).

It might be slower, but will definitely interpret two words separated by comma and no space as two words.

To change the minimal number of words required, you can go to admin/content/types/(whatever type of content), at least in the current cvs version.

mlncn’s picture

Quick work! That looks like it would do it, however I can't get the patch to apply to 5.3 or 5.2. I'm following the documentation as I've interpreted it; could someone point out where I'm wrong or do I need to apply this to dev?

I tried several things, including this command from root, modules, and node:
patch < numwordfix.patch

Guillaume Beaulieu’s picture

StatusFileSize
new724 bytes

Sorry, I fixed it for the CVS HEAD, here's the 5.3 version of the patch

Guillaume Beaulieu’s picture

Status: Active » Needs review
mlncn’s picture

Status: Needs review » Reviewed & tested by the community

This works!

(Really, I should have tried this on Drupal 5 dev or even 6 head, and we should have changed the version). Marking ready-to-be-committed anyway to get the attention of keepers of the core.

drumm’s picture

Version: 5.3 » 6.x-dev
Status: Reviewed & tested by the community » Needs work

- We do not use $camelCase, we use $underscored_names.
- [] does not need to surround \s
- I would like to see this committed to Drupal 6 first, then backported to 5.x.

pancho’s picture

Assigned: Guillaume Beaulieu » Unassigned
Priority: Minor » Normal
Status: Needs work » Needs review
StatusFileSize
new938 bytes

Created a patch against HEAD with renamed variable and simplified regexp.

Guillaume Beaulieu’s picture

Status: Needs review » Fixed

It has been fixed without the use of a regexp as of 6.2.

Guillaume Beaulieu’s picture

Priority: Normal » Minor
Status: Fixed » Needs review
StatusFileSize
new755 bytes

In fact, this would fix it. Sorry for closing something that shouldn't have been close in the first place

dpearcefl’s picture

Status: Needs review » Postponed (maintainer needs more info)

Does this issue exist in current D6?

dpearcefl’s picture

Status: Postponed (maintainer needs more info) » Needs work

We want your patch if it is still needed. Please resubmit it with a proper filename.

http://drupal.org/node/1054616
[description]-[issue-number]-[comment-number].patch

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.