跳转到主要内容
851244631@qq.com 提交于 2 March 2015

drupal7.34的views_slideshow模块有个bug,使用php5.5,报如下错误

preg_replace() /e modifier is deprecated, use preg_replace_callback()

解决的办法就是:

把views_slideshow.theme.inc这个文件的如下代码

    foreach ($addons as $addon_id => $addon_info) {
      foreach ($addon_info['accepts'] as $imp_key => $imp_value) {
        if (is_array($imp_value)) {
          $methods[$imp_key][] = preg_replace('/_(.?)/e',"strtoupper('$1')", $addon_id);
        }
        else {
          $methods[$imp_value][] = preg_replace('/_(.?)/e',"strtoupper('$1')", $addon_id);
        }
      }
    }

换成如下代码:

	foreach ($addons as $addon_id => $addon_info) {
		foreach ($addon_info['accepts'] as $imp_key => $imp_value) {
			if (is_array($imp_value)) {
				$methods[$imp_key][] = preg_replace_callback(  
					'/_(.?)/',
					function ($m) {
						return strtoupper($m[1]);
					},
					$addon_id
				);
			}
			else {
				$methods[$imp_value][] = preg_replace_callback(  // php5.x preg_replace_callback() method
					'/_(.?)/',
					function ($m) {
						return strtoupper($m[1]);
					},
					$addon_id
				);
			}
		}
	}
Drupal 版本