注意:未定义的偏移量:在wysiwyg的ckeditor.inc中为2

时间:2013-10-28 19:46:33

标签: php drupal drupal-7 ckeditor wysiwyg

我正在尝试使用Drupal 7中的ckeditor和wysiwyg,但我一直收到此错误:

  

注意:未定义的偏移量:wysiwyg_ckeditor_version()中的2(第85行)   /var/www/sites/all/modules/wysiwyg/editors/ckeditor.inc)。

这是第85行:

return $version[1] . '.' . $version[2];

它是更大功能的一部分:

/**
* Detect editor version.
*
* @param $editor
*   An array containing editor properties as returned from hook_editor().
*
* @return
*   The installed editor version.
*/
function wysiwyg_ckeditor_version($editor) {
  $library = $editor['library path'] . '/ckeditor.js';
  if (!file_exists($library)) {
    return;
  }
  $library = fopen($library, 'r');
  $max_lines = 8;
  while ($max_lines && $line = fgets($library, 500)) {
    // version:'CKEditor 3.0 SVN',revision:'3665'
    // version:'3.0 RC',revision:'3753'
    // version:'3.0.1',revision:'4391'
    if (preg_match('@version:[\"|\'](?:CKEditor )?([\d\.]+)(?:.+revision:[\"|\']  ([\d]+))?@', $line, $version)) {
      fclose($library);
      // Version numbers need to have three parts since 3.0.1.
      $version[1] = preg_replace('/^(\d+)\.(\d+)$/', '${1}.${2}.0', $version[1]);
      return $version[1] . '.' . $version[2];
    }
    $max_lines--;
  }
  fclose($library);
}

对不起,我无法提供更多详细信息,但我在使用Drupal或使用php编写代码方面的经验很少。有谁知道我的问题是什么?

可能与

有关
if (preg_match('@version:[\"|\'](?:CKEditor )?([\d\.]+)(?:.+revision:[\"|\']  ([\d]+))?@', $line, $version)) {

我必须进入.inc文件并将某个字符更改为[\“| \''以使ckeditor兼容。这是我唯一能想到的可能影响文件的内容。

1 个答案:

答案 0 :(得分:4)

要解决警告问题,您应该使用以下代码更新第85行的return值:

return $version[1] . ((isset($version[2])) ? '.' . $version[2] : '');
相关问题