Commit 4a0c4a80 authored by Marco Aresu's avatar Marco Aresu Committed by Florent Torregrosa
Browse files

Issue #3306955: Skip site ID error.

parent 6e0802bb
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -449,10 +449,6 @@ function matomo_admin_settings_form_validate($form, &$form_state) {
  $form_state['values']['matomo_codesnippet_before'] = trim($form_state['values']['matomo_codesnippet_before']);
  $form_state['values']['matomo_codesnippet_after'] = trim($form_state['values']['matomo_codesnippet_after']);

  if (!preg_match('/^\d{1,}$/', $form_state['values']['matomo_site_id'])) {
    form_set_error('matomo_site_id', t('A valid Matomo site ID is an integer only.'));
  }

  $matomo_url = $form_state['values']['matomo_url_http'];
  if ('/' != drupal_substr($matomo_url, -1, 1)) {
    $matomo_url = $matomo_url . '/';
+1 −1
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ function matomo_requirements($phase) {
      }

      // Raise warning if Matomo user account has not been set yet.
      if (!preg_match('/^\d{1,}$/', variable_get('matomo_site_id', ''))) {
      if (empty(variable_get('matomo_site_id', ''))) {
        $requirements['matomo'] = array(
          'title' => $t('Matomo module'),
          'description' => $t('Matomo module has not been configured yet. Please configure its settings from the <a href="@url">Matomo settings page</a>.', array('@url' => url('admin/config/system/matomo'))),
+1 −1
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ function matomo_page_alter(&$page) {
  // 1. Check if the matomo account number has a value.
  // 2. Track page views based on visibility value.
  // 3. Check if we should track the currently active user's role.
  if (preg_match('/^\d{1,}$/', $id) && (_matomo_visibility_pages() || in_array($status, $trackable_status_codes)) && _matomo_visibility_user($user)) {
  if (!empty($id) && (_matomo_visibility_pages() || in_array($status, $trackable_status_codes)) && _matomo_visibility_user($user)) {

    $url_http = variable_get('matomo_url_http', '');
    $url_https = variable_get('matomo_url_https', '');
+0 −5
Original line number Diff line number Diff line
@@ -41,11 +41,6 @@ class MatomoBasicTest extends DrupalWebTestCase {
    $this->drupalGet('admin/config/system/matomo');
    $this->assertRaw(t('Matomo site ID'), '[testMatomoConfiguration]: Settings page displayed.');

    // Check for account code validation.
    $edit['matomo_site_id'] = $this->randomName(2);
    $this->drupalPost('admin/config/system/matomo', $edit, 'Save configuration');
    $this->assertRaw(t('A valid Matomo site ID is an integer only.'), '[testMatomoConfiguration]: Invalid Matomo site ID number validated.');

    // User should have access to code snippets.
    $this->assertFieldByName('matomo_codesnippet_before');
    $this->assertFieldByName('matomo_codesnippet_after');
+0 −14
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ function matomo_variable_info($options) {
    'group' => 'matomo',
    'localize' => TRUE,
    'multidomain' => TRUE,
    'validate callback' => 'matomo_validate_matomo_site_id',
  );

  return $variables;
@@ -37,16 +36,3 @@ function matomo_variable_group_info() {

  return $groups;
}

/**
 * Validate Matomo site ID variable.
 *
 * @param array $variable
 *
 * @return string
 */
function matomo_validate_matomo_site_id($variable) {
  if (!preg_match('/^\d{1,}$/', $variable['value'])) {
    return t('A valid Matomo site ID is an integer only.');
  }
}