WebsiteBaker Community Forum

WebsiteBaker Support (2.10.x) => General Help & Support => Topic started by: johnbroeckaert on January 10, 2018, 05:28:41 PM

Title: Lots of warnings in php_errorlog
Post by: johnbroeckaert on January 10, 2018, 05:28:41 PM
Hi,

I updatrs my site to 2.10 and I use a lot of droplets to show content on different pages.
My errorlog is full of theze warnings:
Code: [Select]
2018-01-10T15:37:16+00:00 [E_NOTICE] /modules/droplets/droplets.php(37) : eval()'d code:[19] from /modules/droplets/droplets.php:[86] do_eval "Undefined variable: section_id"
2018-01-10T15:37:16+00:00 [E_NOTICE] /modules/droplets/droplets.php(37) : eval()'d code:[19] from /modules/droplets/droplets.php:[86] do_eval "Undefined variable: section_id"
2018-01-10T15:37:16+00:00 [E_NOTICE] /modules/droplets/droplets.php(37) : eval()'d code:[19] from /modules/droplets/droplets.php:[86] do_eval "Undefined variable: section_id"
2018-01-10T15:37:16+00:00 [E_NOTICE] /modules/droplets/droplets.php(37) : eval()'d code:[19] from /modules/droplets/droplets.php:[86] do_eval "Undefined variable: section_id"
2018-01-10T15:37:16+00:00 [E_NOTICE] /modules/droplets/droplets.php(37) : eval()'d code:[19] from /modules/droplets/droplets.php:[86] do_eval "Undefined variable: section_id"
2018-01-10T15:37:16+00:00 [E_NOTICE] /modules/droplets/droplets.php(37) : eval()'d code:[19] from /modules/droplets/droplets.php:[86] do_eval "Undefined variable: section_id"
2018-01-10T15:37:16+00:00 [E_NOTICE] /modules/droplets/droplets.php(37) : eval()'d code:[19] from /modules/droplets/droplets.php:[86] do_eval "Undefined variable: section_id"

Everything is working but do I have to do something?
Thanks
Title: Re: Lots of warnings in php_errorlog
Post by: Luisehahne on January 10, 2018, 05:43:15 PM
Hallo,

that means, in one of your droplet you have an error in line 19. There is call of a none existing variable
"Undefined variable: section_id". Pls check your droplet code.

Dietmar
Title: Re: Lots of warnings in php_errorlog
Post by: johnbroeckaert on January 10, 2018, 07:37:17 PM
Hallo Dietmar,

These errors come with the droplets in the 2.10 package version 3.0.22 . Mostly SectionPicker.
This is the code of this droplet:

Code: [Select]
global $database, $wb, $TEXT, $DGTEXT;
$content = '';
$sid = isset($sid) ? intval($sid) : 0;
if( $sid ) {
$sql  = 'SELECT `module` FROM `'.TABLE_PREFIX.'sections` ';
$sql .= 'WHERE `section_id`='.$sid;
if (($module = $database->get_one($sql))) {
if (is_readable(WB_PATH.'/modules/'.$module.'/view.php')) {
$_sFrontendCss = '/modules/'.$module.'/frontend.css';
if(is_readable(WB_PATH.$_sFrontendCss)) {
$_sSearch = preg_quote(WB_URL.'/modules/'.$module.'/frontend.css', '/');
if(preg_match('/<link[^>]*?href\s*=\s*\"'.$_sSearch.'\".*?\/>/si', $wb_page_data)) {
$_sFrontendCss = '';
}else {
$_sFrontendCss = '<link href="'.WB_URL.$_sFrontendCss.'" rel="stylesheet" type="text/css" media="screen" />';
}
} else { $_sFrontendCss = ''; }
ob_start();
[b]$oldSid = $section_id; // save old sectionID[/b]
$section_id = $sid;
require(WB_PATH.'/modules/'.$module.'/view.php');
$content = $_sFrontendCss.ob_get_clean();
$section_id = $oldSid; // restore old sectionID
}
}
}
return $content;


The thick line is nr 19.
Thanks
Title: Re: Lots of warnings in php_errorlog
Post by: Gast on January 10, 2018, 07:56:40 PM
add $section_id to the line with the global, seperated by comma
like
Code: [Select]
global $database, $wb, $TEXT, $DGTEXT,$section_id,$page_id;

Here the new Code from the repaired Droplet Section Picker, included in WB 2.11

global $database, $wb, $TEXT, $DGTEXT,$section_id,$page_id;
    $sRetVal = '';
    $content = '';
    $_sFrontendCss = '';
    $sid = isset( $sid) ? intval( $sid) : 0;
    if ( intval( $sid) > 0) {
        $now = time();
        $sql = 'SELECT `s`.*'
              .     ', `p`.`viewing_groups`'
              .     ', `p`.`visibility`'
              .     ', `p`.`menu_title`'
              .     ', `p`.`link` '
              . 'FROM `'.TABLE_PREFIX.'sections` `s`'
              . 'INNER JOIN `'.TABLE_PREFIX.'pages` `p` '
              .    'ON `p`.`page_id`=`s`.`page_id` '
              . 'WHERE `s`.`section_id` = '.( int)$sid.' '
              .   'AND ('
              .         '('.$now.'>=`s`.`publ_start` OR `s`.`publ_start`=0) AND '
              .         '('.$now.'<=`s`.`publ_end` OR `s`.`publ_end`=0) '
              .       ')'
              .   'AND `p`.`visibility` NOT IN (\'deleted\') '
              .   '  ';
        if ( $oSection = $database->query( $sql)) {
            while ( $aSection = $oSection->fetchRow( MYSQLI_ASSOC)) {
                $section_id = $aSection['section_id'];
                $module = $aSection['module'];
                ob_start();
                require ( WB_PATH.'/modules/'.$module.'/view.php');
                $content = ob_get_clean();
                $_sFrontendCss = '/modules/'.$module.'/frontend.css';
                $_sFrontendCssrUrl = WB_URL.$_sFrontendCss;
                $_sSearch = preg_quote( WB_URL.'/modules/'.$module.'/frontend.css', '/');
                if ( preg_match( '/<link[^>]*?href\s*=\s*\"'.$_sSearch.'\".*?\/>/si', $content)) {
                    $_sFrontendCss = '';
                } else {
                    $sFrontend = '/modules/'.$module.'/frontend';
                    $sFrontendJsFile  = (is_readable(WB_PATH.$sFrontend.'.js')?WB_URL.$sFrontend.'.js':'"";');
                    $sFrontendCssFile = (is_readable(WB_PATH.$sFrontend.'.css')?WB_URL.$sFrontend.'.css':'"";');
                    $_sFrontendCss = '
                      <script>
                      <!--
                          try {
                              var ModuleCss = '.$sFrontendCssFile.'
                              var ModuleJs  = '.$sFrontendJsFile.'
                              if (ModuleCss!==""){
                                  if (typeof LoadOnFly === "undefined"){
                                      include_file(ModuleCss, "css");
                                  } else {
                                      LoadOnFly("head", ModuleCss);
                                  }
                              }
                              if (ModuleJs!==""){
                                  include_file(ModuleJs, "js");
                              }
                          } catch(e) {
                           /* alert("An error has occurred: "+e.message)*/
                          }
                      -->
                      </script>
                      ';
                }
            }
        }
    }
    return $_sFrontendCss.$content;
Title: Re: Lots of warnings in php_errorlog
Post by: dbs on January 10, 2018, 11:09:26 PM
You could also try to delete the droplet and then do a manually upgrade of the module droplets.
All missing WB droplets will installed (from the example folder).

An WB 2.10 upgrade will not replace old droplets with newer ones.
Title: Re: Lots of warnings in php_errorlog
Post by: johnbroeckaert on January 11, 2018, 08:04:38 AM
I tried the option of @Jacobi22 first. I works fine!
Thank YOU UWE.

Code: [Select]
global $database, $wb, $TEXT, $DGTEXT,$section_id,$page_id;