Geeklog-Core / geeklog

Geeklog - The Secure CMS.
https://www.geeklog.net
24 stars 19 forks source link

Staticpages plugin error when edit data. #1053

Closed ivywe closed 4 years ago

ivywe commented 4 years ago
ERROR: PHP Version:7.2.24

E_WARNING(2) - Invalid argument supplied for foreach() @ /var/www/html/lib-common.php line 1809

Call Stack
# Function File Line
1 COM_optionListFromLangVariables /public_html/admin/plugins/staticpages/index.php 227
2 staticpageeditor_form /public_html/admin/plugins/staticpages/index.php 853
3 staticpageeditor /public_html/admin/plugins/staticpages/index.php 976
array(5) {
["langVariableName"]=>
string(23) "LANG_staticpages_search"
["selected"]=>
string(1) "1"
["charset"]=>
&string(5) "utf-8"
["retval"]=>
string(0) ""
["LANG_staticpages_search"]=>
&NULL
}

Now it works correctry. This is hiroron's report.

lib-common.php add empty check in COM_optionListFromLangVariables()

from:

        foreach ($$langVariableName as $value => $text) {
            $isSelected = ($value == $selected) ? ' selected="selected"' : '';
            $retval .= sprintf(
                    '<option value="%s"%s>%s</option>',
                    htmlspecialchars($value, ENT_QUOTES, $charset),
                    $isSelected,
                    htmlspecialchars($text, ENT_QUOTES, $charset)
                ) . PHP_EOL;
        }

to:

    if (!empty($$langVariableName)) {
        foreach ($$langVariableName as $value => $text) {
            $isSelected = ($value == $selected) ? ' selected="selected"' : '';
            $retval .= sprintf(
                    '<option value="%s"%s>%s</option>',
                    htmlspecialchars($value, ENT_QUOTES, $charset),
                    $isSelected,
                    htmlspecialchars($text, ENT_QUOTES, $charset)
                ) . PHP_EOL;
        }
    }
eSilverStrike commented 4 years ago

Actually that is not correct fix. That variable is required for the function COM_optionListFromLangVariables.

It looks like your staticpage language files are missing the variable $LANG_staticpages_search.

It was an issue with the Geeklog Language Synch which I have now fixed. You can update your staticpage language files now from the repository and it should work

ivywe commented 4 years ago

Tom, thanks!

Ivy