Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

array_keys() expects parameter 1 to be array, null given... #2088

Closed
LMS235 opened this issue Aug 23, 2017 · 4 comments
Closed

array_keys() expects parameter 1 to be array, null given... #2088

LMS235 opened this issue Aug 23, 2017 · 4 comments

Comments

@LMS235
Copy link

@LMS235 LMS235 commented Aug 23, 2017

After Upgrade form 2017-02-19c to 2017-02-19d following error occours with PHP 5.6.27 and 5.6.30 but not with 7.1.8 and 7.0.22 (see also https://forum.dokuwiki.org/post/57836):

Warning: array_keys() expects parameter 1 to be array, null given in .../wiki/vendor/easybook/geshi/geshi.php on line 2039

Warning: Invalid argument supplied for foreach() in .../wiki/vendor/easybook/geshi/geshi.php on line 2039

Warning: Invalid argument supplied for foreach() in .../wiki/vendor/easybook/geshi/geshi.php on line 2411

Warning: implode(): Argument must be an array in .../wiki/vendor/easybook/geshi/geshi.php on line 3365

Warning: array_keys() expects parameter 1 to be array, null given in .../wiki/vendor/easybook/geshi/geshi.php on line 3388

@phy25
Copy link
Collaborator

@phy25 phy25 commented Aug 23, 2017

Sorry about this. Are you using <code>? What language are you using in <code>?

@LMS235
Copy link
Author

@LMS235 LMS235 commented Aug 23, 2017

yes, error only on pages with <code> blocks. But with different languages. on my sites with
<code>, <code bash> and <code sql>

@phy25
Copy link
Collaborator

@phy25 phy25 commented Aug 23, 2017

I see... Actually I can reproduce this on PHP 7 (without render cache with this: <code>1</code>). Line 633 is making null to (string) "", causing line 654 fail to check.

function _highlight($type, $text, $language = null, $filename = null) {
global $ID;
global $lang;
$language = preg_replace(PREG_PATTERN_VALID_LANGUAGE, '', $language);
if($filename) {
// add icon
list($ext) = mimetype($filename, false);
$class = preg_replace('/[^_\-a-z0-9]+/i', '_', $ext);
$class = 'mediafile mf_'.$class;
$this->doc .= '<dl class="'.$type.'">'.DOKU_LF;
$this->doc .= '<dt><a href="'.exportlink($ID, 'code', array('codeblock' => $this->_codeblock)).'" title="'.$lang['download'].'" class="'.$class.'">';
$this->doc .= hsc($filename);
$this->doc .= '</a></dt>'.DOKU_LF.'<dd>';
}
if($text{0} == "\n") {
$text = substr($text, 1);
}
if(substr($text, -1) == "\n") {
$text = substr($text, 0, -1);
}
if(is_null($language)) {
$this->doc .= '<pre class="'.$type.'">'.$this->_xmlEntities($text).'</pre>'.DOKU_LF;
} else {
$class = 'code'; //we always need the code class to make the syntax highlighting apply
if($type != 'code') $class .= ' '.$type;
$this->doc .= "<pre class=\"$class $language\">".p_xhtml_cached_geshi($text, $language, '').'</pre>'.DOKU_LF;
}
if($filename) {
$this->doc .= '</dd></dl>'.DOKU_LF;
}
$this->_codeblock++;
}

My bad. You can fix this by changing line 654 to if(empty($language)) {. Will make a PR.

@LMS235
Copy link
Author

@LMS235 LMS235 commented Aug 23, 2017

after change 654 it works without errors, thanks!

splitbrain added a commit that referenced this issue Aug 23, 2017
Fix rendering null $language going to GeSHi (fixes #2088)
splitbrain added a commit that referenced this issue Aug 27, 2017
* master: (407 commits)
  do not export the appveyor config
  Added appveyor config for automated windows testing
  Update check supports HTTPS
  fixed some style errors found by scrutinizer
  removed unused, empty files
  some cleanup fpr set_metadata test
  added one more test for internal links
  parsertests: replaced var keywords and added type hints
  Fix p_set_metadata damaging contributors with numeric ID
  Add tests for array_replace part of set_metadata
  Fix rendering null $language going to GeSHi (fixes #2088)
  Fix RSS syntax XSS bug (#2081)
  Fix sanitation of $language for code highlighting (fixes #2080)
  translation update
  fix(config): empty string is valid for numericopt
  removed old tpl_content_core method
  updated composer dependencies
  Removed progressbar from searchform
  Release preparation
  translation update
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants