Drupal 6.13 を PHP 5.3.0 で動かす

先の記事で Drupal 6.13 を PHP 5.3.0 で動かすと、「Function ereg() is deprecated******\includes\file.inc895 行目」というメッセージが表示されてしまうと書いた。

このメッセージは、PHP 5.3.0 で非推奨になった関数を使っていることが原因であり、Drupal の動作自体には影響がないはずだ。
しかし、Drupal で何かをしようとする度にこのメッセージが表示されるのは、どうしても気になるので、簡単にではあるが対処法を調べてみた。

その結果、Drupal 6.13では以下のファイルを修正すれば、このメッセージが表示されなくなりそうだということが分かったので、単なる備忘録としてここに残しておく。

includes\file.inc
オリジナル
 :          :
625:  if ($user->uid != 1) {
626:    $regex = '/\.('. ereg_replace(' +', '|', preg_quote($extensions)) .')$/i';
627:    if (!preg_match($regex, $file->filename)) {
 :          :
894:        }
895:        elseif ($depth >= $min_depth && ereg($mask, $file)) {
896:          // Always use this match over anything already set in $files with the same $$key.
 :          :

修正後

 :          :
625:  if ($user->uid != 1) {
626:    $regex = '/\.('. preg_replace(' +', '|', preg_quote($extensions)) .')$/i';
627:    if (!preg_match($regex, $file->filename)) {
 :          :
894:        }
895:        elseif ($depth >= $min_depth && preg_match($mask, $file)) {
896:          // Always use this match over anything already set in $files with the same $$key.
 :          :

includes\unicode.inc
オリジナル

 :          :
137:  // Check for an encoding declaration in the XML prolog if no BOM was found.
138:  if (!$bom && ereg('^<\?xml[^>]+encoding="([^"]+)"', $data, $match)) {
139:    $encoding = $match[1];
 :          :
147:      $encoding = 'utf-8';
148:      $data = ereg_replace('^(<\?xml[^>]+encoding)="([^"]+)"', '\\1="utf-8"', $out);
149:    }
 :          :

修正後

 :          :
137:  // Check for an encoding declaration in the XML prolog if no BOM was found.
138:  if (!$bom && preg_match('^<\?xml[^>]+encoding="([^"]+)"', $data, $match)) {
139:    $encoding = $match[1];
 :          :
147:      $encoding = 'utf-8';
148:      $data = preg_replace('^(<\?xml[^>]+encoding)="([^"]+)"', '\\1="utf-8"', $out);
149:    }
 :          :

modules\blogapi\blogapi.module
オリジナル

 :          :
691:function blogapi_blogger_title(&$contents) {
692:  if (eregi('<title>([^<]*)</title>', $contents, $title)) {
693:    $title = strip_tags($title[0]);
 :          :
693:    $title = strip_tags($title[0]);
694:    $contents = ereg_replace('<title>[^<]*</title>', '', $contents);
695:  }
 :          :

修正後

 :          :
691:function blogapi_blogger_title(&$contents) {
692:  if (preg_match('@<title>([^<]*)</title>@i', $contents, $title)) {
693:    $title = strip_tags($title[0]);
 :          :
693:    $title = strip_tags($title[0]);
694:    $contents = preg_replace('<title>[^<]*</title>', '', $contents);
695:  }
 :          :

modules\user\user.module
オリジナル

 :          :
384:  if (strpos($name, '  ') !== FALSE) return t('The username cannot contain multiple spaces in a row.');
385:  if (ereg("[^\x80-\xF7 [:alnum:]@_.-]", $name)) return t('The username contains an illegal character.');
386:  if (preg_match('/[\x{80}-\x{A0}'.          // Non-printable ISO-8859-1 + NBSP
 :          :
397:  }
398:  if (strpos($name, '@') !== FALSE && !eregi('@([0-9a-z](-?[0-9a-z])*.)+[a-z]{2}([zmuvtg]|fo|me)?$', $name)) return t('The username is not a valid authentication ID.');
399:  if (strlen($name) > USERNAME_MAX_LENGTH) return t('The username %name is too long: it must be %max characters or less.', array('%name' => $name, '%max' => USERNAME_MAX_LENGTH));
 :          :

修正後

 :          :
384:  if (strpos($name, '  ') !== FALSE) return t('The username cannot contain multiple spaces in a row.');
385:  if (preg_match("[^\x80-\xF7 [:alnum:]@_.-]", $name)) return t('The username contains an illegal character.');
386:  if (preg_match('/[\x{80}-\x{A0}'.          // Non-printable ISO-8859-1 + NBSP
 :          :
397:  }
398:  if (strpos($name, '@') !== FALSE && !preg_match('/@([0-9a-z](-?[0-9a-z])*.)+[a-z]{2}([zmuvtg]|fo|me)?$/i', $name)) return t('The username is not a valid authentication ID.');
399:  if (strlen($name) > USERNAME_MAX_LENGTH) return t('The username %name is too long: it must be %max characters or less.', array('%name' => $name, '%max' => USERNAME_MAX_LENGTH));
 :          :

なお、この対処法は正式なものではないため、何ら保証の無いことに注意されたい。

関連する記事 (Related posts):

  1. Drupal [Install Maniax 3]
  2. Drupal を弄ってみた [準備編]
  3. Drupal [Install Maniax 2009]
  4. ubuntu 10.04 をメールサーバーに (PostfixAdmin 設定編)
  5. IIS の ARR を使って Plone を呼び出す

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <img localsrc="" alt="">