diff --git a/mollom.drupal.inc b/mollom.drupal.inc index c70ebb3..9606bf2 100644 --- a/mollom.drupal.inc +++ b/mollom.drupal.inc @@ -320,6 +320,28 @@ class MollomDrupalTest extends MollomDrupal { } } + /** + * Overrides Mollom::createCaptcha(). + * + * Temporary fix to show proper image CAPTCHAs when testing mode is enabled. + * + * @todo Remove after REST Testing API has been fixed. + */ + public function createCaptcha(array $data = array()) { + $result = parent::createCaptcha($data); + if (isset($data['type']) && $data['type'] === 'image' && isset($result['url']) && strpos($result['url'], 'captcha') !== FALSE) { + if (!empty($data['ssl'])) { + $dhr = drupal_http_request($result['url']); + $dhr->code = (int) $dhr->code; + // If the code is 200 that means mollom fixed this problem for testing mode. + if ($dhr->code != 200) { + $result['url'] = str_replace( 'https://', 'http://', $result['url']); + } + } + } + return $result; + } + /** * Drupal Mollom client implementation using local dummy/fake REST server. */