Index: htmlpurifier.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/htmlpurifier/htmlpurifier.install,v
retrieving revision 1.13
diff -u -p -r1.13 htmlpurifier.install
--- htmlpurifier.install 9 Jun 2010 17:07:14 -0000 1.13
+++ htmlpurifier.install 30 Jul 2010 09:20:24 -0000
@@ -96,8 +96,7 @@ function htmlpurifier_requirements($phas
if ($phase=='runtime') {
$current = variable_get('htmlpurifier_version_current', FALSE);
if (!$current) {
- htmlpurifier_cron();
- $current = variable_get('htmlpurifier_version_current', FALSE);
+ $current = htmlpurifier_check_version();
}
$ours = variable_get('htmlpurifier_version_ours', FALSE);
if (!$ours || version_compare($ours, $req_version, '<')) {
@@ -130,7 +129,18 @@ function htmlpurifier_requirements($phas
}
}
- if (!$ours || version_compare($current, $ours, '>')) {
+ if (!$current) {
+ $requirements['htmlpurifier_check'] = array(
+ 'title' => $t('HTML Purifier Library'),
+ 'value' => $ours,
+ 'description' => $t('Unable to check for the latest version of the
+ HTML Purifier library. You will need to check manually at
+ htmlpurifier.org to find out if
+ the version you are using is out of date.'),
+ 'severity' => REQUIREMENT_WARNING,
+ );
+ }
+ elseif (!$ours || version_compare($current, $ours, '>')) {
// Update our version number if it can't be found, or there's a
// mismatch. This won't do anything if _htmlpurifier_load() has
// already been called. An equivalent formulation would be
Index: htmlpurifier.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/htmlpurifier/htmlpurifier.module,v
retrieving revision 1.17
diff -u -p -r1.17 htmlpurifier.module
--- htmlpurifier.module 9 Jun 2010 17:07:14 -0000 1.17
+++ htmlpurifier.module 30 Jul 2010 09:20:24 -0000
@@ -32,16 +32,34 @@ function htmlpurifier_help($path, $arg)
/**
* Implementation of hook_cron().
- * @note
- * Checks for updates to the HTML Purifier library.
*/
function htmlpurifier_cron() {
- // Maybe this should be changed in the future:
- $result = drupal_http_request('http://htmlpurifier.org/live/VERSION');
- $version = trim($result->data);
- variable_set('htmlpurifier_version_current', $version);
+ // Force an attempt at checking for a new version; this is safe to do in
+ // hook_cron because a slow timeout will not degrade the user experience.
+ htmlpurifier_check_version(TRUE);
}
+/**
+ * Checks for updates to the HTML Purifier library.
+ */
+function htmlpurifier_check_version($force = FALSE) {
+ if ($force || !variable_get('htmlpurifier_version_check_failed', FALSE)) {
+ // Maybe this should be changed in the future:
+ $result = drupal_http_request('http://htmlpurifier.org/live/VERSION');
+ if ($result->code == 200) {
+ $version = trim($result->data);
+ variable_set('htmlpurifier_version_check_failed', FALSE);
+ variable_set('htmlpurifier_version_current', $version);
+ return $version;
+ }
+ else {
+ variable_set('htmlpurifier_version_check_failed', TRUE);
+ // Delete any previously known "latest" version so that people can be
+ // alerted if a problem appears on a previously working site.
+ variable_del('htmlpurifier_version_current');
+ }
+ }
+}
/**
* Implementation of hook_filter().