e107inc / e107

e107 Bootstrap CMS (Content Management System) v2 with PHP, MySQL, HTML5, jQuery and Twitter Bootstrap. Issue Discussion Room: https://gitter.im/e107inc/e107
https://e107.org
GNU General Public License v3.0
323 stars 214 forks source link

Fatal error: Uncaught Error: Call to a member function query() on null in /var/www/domain.com/e107_handlers/e_db_pdo_class.php:224 #3907

Open mostym opened 5 years ago

mostym commented 5 years ago
2019/07/28 19:55:08 [error] 20844#20844: *12918731 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to a member function query() on null in /var/www/domain.com/e107_handlers/e_db_pdo_class.php:224
Stack trace:
#0 /var/www/domain.com/e107_handlers/e_db_pdo_class.php(2799): e_db_pdo->database(NULL)
#1 /var/www/domain.com/e107_handlers/e_db_pdo_class.php(1945): e_db_pdo->_getMySQLaccess()
#2 /var/www/domain.com/e107_handlers/userclass_class.php(160): e_db_pdo->field('userclass_class...', 'userclass_paren...')
#3 /var/www/domain.com/e107_handlers/userclass_class.php(94): user_class->readTree(true)
#4 /var/www/domain.com/e107_handlers/e107_class.php(945): user_class->__construct(NULL)
#5 /var/www/domain.com/e107_handlers/e107_class.php(1721): e107::getSingleton('user_class', '../handlers/use...')
#6 /var/www/domain.com/e107_handlers/e107_class.php(5100): e107::getUserClass()
#7 /var/www/domain.com/class2.php(1711): e107->__get('user_class')
#8 /var/www/domain.com/add/index.php(13): check_class('Uploader')
#9" while reading upstream, client: 104.174.206.178, server: www.domain.com, request: "GET /add/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.2-fpm.sock:", host: "www.domain.com", referrer: "https://www.domain.com/add/"
Moc commented 5 years ago

When exactly does this happen? I can see it is related to the userclass page, but do you click something specifically?

mostym commented 5 years ago

I created a custom page called /add and in the index.php file is the following code:

<?php
//define('e_DEBUG', true);
//to disable https redirection:
//define('e_SSL_DISABLE', true);
require_once("../class2.php");
require_once(HEADERF);
require_once(FOOTERF);
require_once('db_config.php');
include_once("categories.php");
include_once("header.inc.php");
if (!check_class('Uploader')) {
    header('location: https://www.domain.com/');
    exit;
}
if($pref['user_tracking'] != "session"){
    session_start();
}
function getCatList($parentId) {
    global $categories;
    $res = '';
    foreach ($categories as $catId=>$cat) {
        if($cat['parent'] != $parentId) continue;
        $sunCats = getCatList($catId);
        $action = '<input type="text" placeholder="ftp path" /><span class="action add-ftp-path" data-id="'.$catId.'">[add]</span>';
        if($cat['dir']) $action = '('.$cat['dir'].') <span class="action start" data-id="'.$catId.'">[go]</span>';
        $res .= '<li class="li_cat_'.$catId.'">' . ($sunCats ? '<span class="opener closed">[+]</span> ' : '') . $cat['name'].' <span class="acts">'.$action.'</span>';
        $res .= $sunCats.'</li>';
    }
    return $res ? '<ul class="cat_list'.$parentId.'">'.$res.'</ul>' : '';
}
?>
<?= getCatList(0) ?>
<form id="process" action="process.php" method="POST"><input type="hidden" name="category_id" value="0" /></form>
mostym commented 5 years ago

Removing the following makes the page load. However, this is not the desired result. I need this logic to only allow a specific user class access to this page. Any help would be appreciated. Thanks!

if (!check_class('Uploader')) {
    header('location: https://www.domain.com/');
    exit;
}