Commit d338e848 authored by soxofaan's avatar soxofaan

#245720: added requirement check for uid=0 in users table

parent 2689968c
......@@ -113,6 +113,16 @@ function captcha_requirements($phase) {
'value' => $t('Already @counter blocked form submissions', array('@counter' => variable_get('captcha_wrong_response_counter', 0))),
'severity' => REQUIREMENT_INFO,
// Check if there is an entry for uid=0 in the users table, this is required
// to have working a $_SESSION variable for anonymous users.
if (!db_result(db_query('SELECT COUNT(*) FROM {users} WHERE uid=%d', 0))) {
$requirements['captcha_no_sessions_for_anonymous'] = array(
'title' => $t('CAPTCHA'),
'value' => $t('No sessions for anonymous users.'),
'description' => $t('There is no entry for uid 0 in the %users table of the database. This disables persistent session data for anonymous users. Because the CAPTCHA module depends on this session data, CAPTCHAs will not work for anonymous users. Add a row for uid 0 to the %users table to resolve this.', array('%users' => 'users')),
'severity' => REQUIREMENT_ERROR,
return $requirements;
......@@ -323,7 +333,7 @@ function captcha_validate($form, &$form_state) {
// not that we use $form_state['clicked_button']['#post']['captcha_token']
// here instead of $form_state['values']['captcha_token'], because the latter
// contains the captcha_token of the new form, while the former contains
// not the captcha token of the posted form.
// the captcha token of the posted form.
$captcha_token = $form_state['clicked_button']['#post']['captcha_token'];
// Check if captcha_token exists
if (!isset($_SESSION['captcha'][$form_id][$captcha_token])) {
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment