Index: captcha.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/captcha/captcha.admin.inc,v
retrieving revision 1.32.2.1
diff -u -b -u -p -r1.32.2.1 captcha.admin.inc
--- captcha.admin.inc	12 Jun 2010 14:35:55 -0000	1.32.2.1
+++ captcha.admin.inc	2 Jul 2010 20:20:36 -0000
@@ -32,7 +32,7 @@ function _captcha_available_challenge_ty
 /**
  * Form builder function for the general CAPTCHA configuration
  */
-function captcha_admin_settings() {
+function captcha_admin_settings(&$form_state) {
   module_load_include('inc', 'captcha');
 
   // Use javascript for some added usability on admin form.
@@ -119,6 +119,26 @@ function captcha_admin_settings() {
     '#description' => t('This option makes it possible to add CAPTCHAs to forms on administrative pages. CAPTCHAs are disabled by default on administrative pages (which shouldn\'t be accessible to untrusted users normally) to avoid the related overhead. In some situations, e.g. in the case of demo sites, it can be usefull to allow CAPTCHAs on administrative pages.'),
   );
 
+  // Button for flushing the CAPTCHA placement cache.
+  $form['captcha_form_protection']['captcha_placement_caching'] = array(
+    '#type' => 'item',
+    '#title' => t('CAPTCHA placement caching'),
+    '#description' => t('For efficiency, the positions of the CAPTCHA elements in each of the configured forms are cached. Most of the time, the structure of a form does not change and it would be a waste to recalculate the positions every time. Occasionally however, the form structure can change (e.g. during site building) and flushing the CAPTCHA placement cache can be required to fix the CAPTCHA placement.'),
+  );
+  $form['captcha_form_protection']['captcha_placement_caching']['captcha_placement_cache_flush'] = array(
+    '#type' => 'button',
+    '#value' => t('Flush the CAPTCHA placement cache'),
+    '#submit' => array('captcha_placement_cache_flush'),
+  );
+  // Handle the button for flushing the CAPTCHA placement cache.
+  // This is done here instead of in a submit handler because the button is
+  // not a submitting button.
+  if (isset($form_state['post']['op']) && $form_state['post']['op'] ==  t('Flush the CAPTCHA placement cache')) {
+    variable_del('captcha_placement_map_cache');
+    drupal_set_message(t('Flushed the CAPTCHA placement cache.'));
+  }
+
+
   // Configuration option for adding a CAPTCHA description.
   $form['captcha_add_captcha_description'] = array(
     '#type' => 'checkbox',
Index: captcha.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/captcha/captcha.inc,v
retrieving revision 1.11.2.3
diff -u -b -u -p -r1.11.2.3 captcha.inc
--- captcha.inc	12 Jun 2010 14:35:55 -0000	1.11.2.3
+++ captcha.inc	2 Jul 2010 20:20:36 -0000
@@ -203,7 +203,6 @@ function _captcha_get_captcha_placement(
   if ($placement_map === NULL) {
     // If first level cache missed: try second level cache.
     $placement_map = variable_get('captcha_placement_map_cache', NULL);
-    // TODO: add UI in admin UI for flushing this cache.
 
     if ($placement_map === NULL) {
       // If second level cache missed: start from a fresh placement map.
Index: captcha.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/captcha/captcha.test,v
retrieving revision 1.14.2.4
diff -u -b -u -p -r1.14.2.4 captcha.test
--- captcha.test	2 Jul 2010 19:07:37 -0000	1.14.2.4
+++ captcha.test	2 Jul 2010 20:20:37 -0000
@@ -536,6 +536,25 @@ class CaptchaAdminTestCase extends Captc
 
   }
 
+  /**
+   * Test the CAPTCHA placement flushing.
+   */
+  function testCaptchaPlacementCacheFlushing() {
+    // Set CAPTCHA on user register form.
+    captcha_set_form_id_setting('user_register', 'captcha/Math');
+    // Visit user register form to fill the CAPTCHA placement cache.
+    $this->drupalGet('user/register');
+    // Check if there is CAPTCHA placement cache.
+    $placement_map = variable_get('captcha_placement_map_cache', NULL);
+    $this->assertNotNull($placement_map, 'CAPTCHA placement cache should be set.');
+    // Flush the cache
+    $this->drupalLogin($this->admin_user);
+    $this->drupalPost('admin/user/captcha', array(), t('Flush the CAPTCHA placement cache'));
+    // Check that the placement cache is unset
+    $placement_map = variable_get('captcha_placement_map_cache', NULL);
+    $this->assertNull($placement_map, 'CAPTCHA placement cache should be unset after flush.');
+  }
+
 }
 
 
