Перейти к основному содержанию

Drupal 7 — правка багов с кириллицей

Drupal 7

В седьмом друпале есть несколько багов с кириллицей, которые никак не поправят. После каждой переустановки или обновлении drupal 7 я руками вношу следующие изменения, перезаписывая функции:

В файле bootstrap.inc

function check_plain($text) {
  if (drupal_validate_utf8($text))
	return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
return htmlspecialchars($text, ENT_QUOTES);
}
function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL) {
  global $user, $base_root;

  static $in_error_state = FALSE;

  // It is possible that the error handling will itself trigger an error. In that case, we could
  // end up in an infinite loop. To avoid that, we implement a simple static semaphore.
  if (!$in_error_state && function_exists('module_implements')) {
    $in_error_state = TRUE;

    // The user object may not exist in all conditions, so 0 is substituted if needed.
    $user_uid = isset($user->uid) ? $user->uid : 0;

    // Prepare the fields to be logged
    $log_entry = array(
      'type'        => $type,
      'message'     => $message,
      'variables'   => $variables,
      'severity'    => $severity,
      'link'        => $link,
      'user'        => $user,
      'uid'         => $user_uid,
	  'request_uri' => urlencode($base_root . request_uri()),
      'referer'     => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',
      'ip'          => ip_address(),
      // Request time isn't accurate for long processes, use time() instead.
      'timestamp'   => time(),
    );

    // Call the logging hooks to log/process the message
    foreach (module_implements('watchdog') as $module) {
      module_invoke($module, 'watchdog', $log_entry);
    }

    // It is critical that the semaphore is only cleared here, in the parent
    // watchdog() call (not outside the loop), to prevent recursive execution.
    $in_error_state = FALSE;
  }
}

В файле dblog.module

function dblog_watchdog(array $log_entry) {
  Database::getConnection('default', 'default')->insert('watchdog')
    ->fields(array(
      'uid' => $log_entry['uid'],
	  'type' => truncate_utf8($log_entry['type'], 64),
      'message' => $log_entry['message'],
      'variables' => serialize($log_entry['variables']),
      'severity' => $log_entry['severity'],
	  'link' => truncate_utf8($log_entry['link'], 255),
      'location' => $log_entry['request_uri'],
      'referer' => $log_entry['referer'],
	  'hostname' => truncate_utf8($log_entry['ip'], 128),
      'timestamp' => $log_entry['timestamp'],
    ))
    ->execute();
}

 

Теги

 

Похожие материалы

Windows 10 — Intel Rapid Storage Management

Если на вашей материнской плате стоит чип Intel, поддерживающий технологию Intel RST (Intel Rapid Storage Technology), то вы можете собрать RAID массив из жёстких дисков SATA или PCIe и обеспечить отказоустойчивость данных. Если из строй выйдет один диск, то вы продолжаете работать.

Теги

Как покупать в Интернете и не потерять деньги?

Сейчас смотрел по телевизору очередной невысокоинтеллектуальный репортаж о том как покупать в Интернете. Это финиш, ребята. Немного погуглил — та же картина.

Теги

Применение мультипроцессорных серверов

Зачем нужны мультипроцессорные серверы? Для чего производят двухпроцессорные серверы? Где используют четырёхпроцессорные и восьмипроцессорные серверы?

Теги