Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-18-2017, 08:40 PM
mainframe mainframe is offline
 
Join Date: Jul 2004
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default help needed with php7 issues on own mods

Dear vBulletin.org community,

I made a few custom mods for my site many years ago and I'm trying to get them to work with php 7. They all work fine with the latest version of php 5.6 but when I use php 7 all places where I use the <vb:each stuff it is no longer working.

### TEMPLATE CODE ###

<vb:each from="topstats_bits" value="topstats_bit">
everything here is just blank, not showing and no errors whatsoever.
</vb:each>

### PHP CODE ###

$templater = vB_Template::Create('topstats_threads');
$templater->register('pagenumber', $pagenumber);
$templater->register('topstats_bits', $topstats_bits);

print_output($templater->render());

###

It's happening in all my custom mods where I use vb:each to list stuff.
Hope you guys can put the finger on this, been searching all day and can't find anything wrong.

Regards,
mainframe
Reply With Quote
  #2  
Old 08-18-2017, 10:38 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Any errors in the PHP error log? We can't really do much with the code you've given us. We need more information on how $topstats_bits is populated.
Reply With Quote
  #3  
Old 08-18-2017, 11:58 PM
mainframe mainframe is offline
 
Join Date: Jul 2004
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dave View Post
Any errors in the PHP error log? We can't really do much with the code you've given us. We need more information on how $topstats_bits is populated.
No errors whatsoever, the page execution also continues as normal it just skips the <vb:each parts.

Attached blurred screenshots of how it looks in php 5.6.3 and 7.1.8

And here's the whole code
PHP Code:
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT''topstats');
define('CSRF_PROTECTION'true);

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array();

// pre-cache templates used by specific actions
$actiontemplates = array(
    
'none' => array(
        
'topstats_articles',
        
'topstats_forums',
        
'topstats_threads',
        
'topstats_users',
    ),
);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

if ($show['member'] AND !empty($_GET['show']))
{
    if (
in_array($_GET['show'], array(1,2,4,5,6,10,11)))
    {
        foreach(
$vbulletin->forumcache AS $forum)
        {
            if (!
$forum['displayorder'] OR !($forum['options'] & $vbulletin->bf_misc_forumoptions['active']))
            {
                
$excluded_forum_ids .= ',' $forum['forumid'];
            }

//            $forumpermissions = fetch_permissions($forum['forumid']);
            
$forumpermissions $vbulletin->userinfo['forumpermissions']["{$forum['forumid']}"];

            if (!(
$forumpermissions $vbulletin->bf_ugp_forumpermissions['canview']) AND ($vbulletin->forumcache["{$forum['forumid']}"]['showprivate'] == OR (!$vbulletin->forumcache["{$forum['forumid']}"]['showprivate'] AND !$vbulletin->options['showprivateforums'])))
            {
                
$excluded_forum_ids .= ',' $forum['forumid'];
            }

            if (
$_GET['cardsharing'] == 1)
            {
                if (
in_array($forum["forumid"], array(2947,3061,3065,1612,3082)))
                {
                    
$included_forum_ids .= ',' substr($forum['childlist'], 0, -3);
                }
            }
        }

        unset(
$forumpermissions$forum);

        
$excluded_forum_ids substr($excluded_forum_ids1);

        if (
$excluded_forum_ids != '')
        {
            
$excluded_ids "AND data.forumid NOT IN($excluded_forum_ids)";
        }

        
$included_forum_ids substr($included_forum_ids1);

        if (
$included_forum_ids != '')
        {
            
$included_ids "AND data.forumid IN ($included_forum_ids)";
        }
    }

    switch (
$_GET['show'])
    {
        case 
1// Latest Posts
            
$sqluserid 'lastposterid';
            
$sqlsortfield 'lastpost';
        break;
        case 
2// Latest Threads
            
$sqluserid 'postuserid';
            
$sqlsortfield 'dateline';
        break;
        case 
3// Latest Articles
            
$sqlsortfield 'publishdate';
        break;
        case 
4// Top Threads - Most Replies
            
$sqluserid 'postuserid';
            
$sqlsortfield 'replycount';
        break;
        case 
5// Top Threads - Most Views
            
$sqluserid 'postuserid';
            
$sqlsortfield 'views';
        break;
        case 
6// Top Threads - Highest Rating
            
$sqluserid 'postuserid';
            
$sqlsortfield 'voteavg DESC, votenum';
        break;
        case 
7// Top Articles - Most Comments
            
$sqlsortfield 'replycount';
        break;
        case 
8// Top Articles - Most Views
            
$sqlsortfield 'viewcount';
        break;
        case 
9// Top Articles - Highest Rating
            
$sqlsortfield 'ratingtotal';
        break;
        case 
10// Top Forums - Most Posts
            
$sqlsortfield 'replycount';
        break;
        case 
11// Top Forums - Most Threads
            
$sqlsortfield 'threadcount';
        break;
        case 
12// Top Members - Most Posts
            
$sqlsortfield 'posts';
        break;
        case 
13// Top Members - Most Threads
            
$sqlsortfield 'posts';
        break;
        case 
14// Top Members - Most Uploads
            
$sqlsortfield 'uploads';
        break;
        case 
15// Top Members - Most Shouts
            
$sqlsortfield 'dbtech_vbshout_shouts_lifetime';
        break;
        case 
16// Top Members - Highest Reputation
            
$sqlsortfield 'reputation';
        break;
        case 
17// Top Members - Most Profile Visits
            
$sqlsortfield 'profilevisits';
        break;
        case 
18// New Members
            
$sqlsortfield 'userid';
        break;
    }

    
$pagenumber $vbulletin->input->clean_gpc('r''pagenumber'TYPE_UINT);

    
$limitlower = ($pagenumber 1) * 20;
    
$limitupper = ($pagenumber) * 20;

    if (
$limitlower 0)
    {
        
$limitlower 0;
    }

    switch (
$_GET['show'])
    {
        case 
1:
        case 
2:
        case 
4:
        case 
5:
        case 
6:
            if (
$_GET['show'] == 6)
            {
                
$vbulletin->options['showvotes'] = intval($vbulletin->options['showvotes']);

                
$votequery "
                    IF(votenum >= " 
$vbulletin->options['showvotes'] . ", votenum, 0) AS votenum,
                    IF(votenum >= " 
$vbulletin->options['showvotes'] . " AND votenum > 0, votetotal / votenum, 0) AS voteavg, votetotal,
                "
;
            }

            
$result $vbulletin->db->query_read("
                SELECT subscribeforumid, user.userid, usergroupid, displaygroupid, username, data.threadid, title, data.lastpost, data.forumid, pollid, replycount, views, " 
iif($_GET['show'] == 6$votequery) . "attach, data.lastpostid, prefixid, taglist
                "
iif($vbulletin->options['threadmarking'] AND $vbulletin->userinfo['userid'], ", readtime") . "
                FROM " 
TABLE_PREFIX "thread AS data
                LEFT JOIN " 
TABLE_PREFIX "user AS user ON (user.userid = $sqluserid)
                LEFT JOIN " 
TABLE_PREFIX "subscribeforum AS subscribeforum ON (subscribeforum.forumid = data.forumid AND subscribeforum.userid = " $vbulletin->userinfo['userid'] . ")
                " 
iif($vbulletin->options['threadmarking'] AND $vbulletin->userinfo['userid'], "LEFT JOIN " TABLE_PREFIX "threadread AS threadread ON (threadread.threadid = data.threadid AND threadread.userid = " .  $vbulletin->userinfo['userid'] . ")") . "
                WHERE NOT ISNULL(data.threadid) AND visible = '1' AND open != '10' 
$excluded_ids $included_ids
                ORDER BY 
$sqlsortfield DESC
                LIMIT 
$limitlower, 20
            "
);
        break;
        case 
3:
        case 
7:
        case 
8:
        case 
9:
            
$result $vbulletin->db->query_read("
                SELECT replycount, GROUP_CONCAT(category.categoryid, '|', category) AS category, user.userid, usergroupid, displaygroupid, username, node.nodeid, nodeinfo.title, viewcount, publishdate
                FROM " 
TABLE_PREFIX "cms_node AS node
                INNER JOIN " 
TABLE_PREFIX "cms_nodeinfo AS nodeinfo ON (nodeinfo.nodeid = node.nodeid)
                LEFT JOIN " 
TABLE_PREFIX "user AS user ON (user.userid = node.userid)
                LEFT JOIN " 
TABLE_PREFIX "cms_nodecategory AS nodecategory ON (nodecategory.nodeid = node.nodeid)
                LEFT JOIN " 
TABLE_PREFIX "cms_category AS category ON (category.categoryid = nodecategory.categoryid)
                LEFT JOIN " 
TABLE_PREFIX "thread AS thread ON (thread.threadid = nodeinfo.associatedthreadid)
                WHERE contenttypeid = 18 and setpublish = 1
                GROUP BY node.nodeid
                ORDER BY 
$sqlsortfield DESC
                LIMIT 
$limitlower, 20
            "
);
        break;
        case 
10:
        case 
11:
            
$result $db->query_read("
                SELECT subscribeforumid, data.forumid, replycount, lastpost, threadcount
                "
iif($vbulletin->options['threadmarking'] AND $vbulletin->userinfo['userid'], ', readtime') . "
                FROM " 
TABLE_PREFIX "forum AS data
                LEFT JOIN " 
TABLE_PREFIX "subscribeforum AS subscribeforum ON (subscribeforum.forumid = data.forumid AND subscribeforum.userid = " $vbulletin->userinfo['userid'] . ")
                " 
iif($vbulletin->options['threadmarking'] AND $vbulletin->userinfo['userid'], "LEFT JOIN " TABLE_PREFIX "forumread AS forumread ON (forumread.forumid = data.forumid AND forumread.userid = " .  $vbulletin->userinfo['userid'] . ")") . "
                WHERE replycount > 0 
$excluded_ids $included_ids
                ORDER BY 
$sqlsortfield DESC
                LIMIT 
$limitlower, 20
            "
);
        break;
        case 
12:
        case 
13:
        case 
14:
        case 
15:
        case 
16:
        case 
17:
        case 
18:
            
$result $db->query_read("
                SELECT userid, usergroupid, displaygroupid, username, usertitle, joindate, lastactivity, posts, uploads, reputation, reputationlevelid, dbtech_vbshout_shouts_lifetime
                FROM " 
TABLE_PREFIX "user
                ORDER BY 
$sqlsortfield DESC
                LIMIT 
$limitlower, 20
            "
);
        break;
    }

    while (
$topstats_bit $db->fetch_array($resultMYSQL_ASSOC))
    {
        switch (
$_GET['show'])
        {
            case 
1:
            case 
2:
            case 
4:
            case 
5:
            case 
6:
                if (
$topstats_bit['lastpost'] > $vbulletin->userinfo['lastvisit'])
                {
                    if (
$vbulletin->options['threadmarking'] AND $topstats_bit['readtime'])
                    {
                        
$threadview $topstats_bit['readtime'];
                    }
                    else
                    {
                        
$threadview intval(fetch_bbarray_cookie('thread_lastview'$topstats_bit['threadid']));
                    }

                    if (
$topstats_bit['lastpost'] > $threadview)
                    {
                        
$topstats_bit['newpost'] = true;
                    }
                }

                if (!empty(
$topstats_bit['prefixid']))
                {
                    
$topstats_bit['prefix'] = $vbphrase["prefix_{$topstats_bit['prefixid']}_title_rich"].": ";
                }

                
$topstats_bit['fullthreadtitle']    = strip_tags($topstats_bit['title']);
                
$topstats_bit['titletrimmed']        = fetch_trimmed_title($topstats_bit['title'], 40);
                
$topstats_bit['pageinfo_lastpost']    = array('p' => $topstats_bit['lastpostid']);

                if (
$_GET['show'] == 1)
                {
                    
$topstats_bit['pageinfo_newpost'] = array('goto' => 'newpost');
                }

                
$topstats_bit['taglist']        = strip_tags($topstats_bit['taglist']);
                
$topstats_bit['fullforumtitle']        = strip_tags($vbulletin->forumcache["{$topstats_bit['forumid']}"]['title_clean']);
                
$topstats_bit['forumtitle']        = fetch_trimmed_title($topstats_bit['fullforumtitle'], 25);
                
$topstats_bit['musername']        = fetch_musername($topstats_bit);
                
$topstats_bit['memberaction_dropdown']    = construct_memberaction_dropdown($topstats_bit);
                
$topstats_bit['date']            = vbdate($vbulletin->options['dateformat'], $topstats_bit['lastpost'], 1);
                
$topstats_bit['time']            = vbdate($vbulletin->options['timeformat'], $topstats_bit['lastpost']);

                if (
$_GET['show'] == 6)
                {
                    if (
$topstats_bit['votetotal'] > 0)
                    {
                        
$topstats_bit['voteavg'] = vb_number_format($topstats_bit['votetotal'] / $topstats_bit['votenum'], 1);
                        
$topstats_bit['rating'] = intval(round($topstats_bit['votetotal'] / $topstats_bit['votenum']));
                    }

                    if (empty(
$topstats_bit['rating']))
                    {
                        
$topstats_bit['rating'] = 0;
                    }
                }
                else
                {
                    
$topstats_bit['replycount'] = vb_number_format($topstats_bit['replycount']);
                    
$topstats_bit['views'] = vb_number_format($topstats_bit['views']);
                }
            break;
            case 
3:
            case 
7:
            case 
8:
            case 
9:
                if (
$topstats_bit['publishdate'] > $vbulletin->userinfo['lastvisit'])
                {
                    
$topstats_bit['newpost'] = true;
                }

                
$topstats_bit['fullarticletitle']    = strip_tags($topstats_bit['title']);
                
$topstats_bit['articletitle']        = fetch_trimmed_title($topstats_bit['fullarticletitle'], 40);

                
$categories explode(','$topstats_bit['category']);

                foreach (
$categories AS $category)
                {
                    
$category explode('|'$category);

                    
$topstats_bit['cat']['categoryid'] = strip_tags($category[0]);
                    
$topstats_bit['cat']['fullcategorytitle'] = strip_tags($category[1]);
                    
$topstats_bit['cat']['categorytitle'] = fetch_trimmed_title($topstats_bit['cat']['fullcategorytitle'], 25);

                    
$topstats_bit['categories'][] = $topstats_bit['cat'];
                }

                unset(
$category);

                
$topstats_bit['musername']        = fetch_musername($topstats_bit);
                
$topstats_bit['memberaction_dropdown']    = construct_memberaction_dropdown($topstats_bit);
                
$topstats_bit['date']            = vbdate($vbulletin->options['dateformat'], $topstats_bit['publishdate'], 1);
                
$topstats_bit['time']            = vbdate($vbulletin->options['timeformat'], $topstats_bit['publishdate']);
                
$topstats_bit['views']            = vb_number_format($topstats_bit['viewcount']);
            break;
            case 
10:
            case 
11:
                if (!
$vbulletin->userinfo['lastvisit'])
                {
                    
$topstats_bit['newpost'] = true;
                }
                else
                {
                    if (
$vbulletin->options['threadmarking'] AND $vbulletin->userinfo['userid'])
                    {
                        
$userlastvisit = (!empty($topstats_bit['readtime']) ? $topstats_bit['readtime'] : (TIMENOW - ($vbulletin->options['markinglimit'] * 86400)));
                    }
                    else
                    {
                        
$forumview intval(fetch_bbarray_cookie('forum_view'$topstats_bit['forumid']));

                        
$userlastvisit = ($forumview $vbulletin->userinfo['lastvisit'] ? $forumview $vbulletin->userinfo['lastvisit']);
                    }

                    if (
$topstats_bit['lastpost'] AND $userlastvisit $topstats_bit['lastpost'] AND ($vbulletin->userinfo['forumpermissions'][$topstats_bit['forumid']] & $vbulletin->bf_ugp_forumpermissions['canviewothers']))
                    {
                        
$topstats_bit['newpost'] = true;
                    }
                }

                
$topstats_bit['fullforumtitle']        = strip_tags($vbulletin->forumcache["{$topstats_bit['forumid']}"]['title_clean']);
                
$topstats_bit['forumtitle']        = fetch_trimmed_title($topstats_bit['fullforumtitle'], 50);
                
$topstats_bit['fulldescription']    = strip_tags($vbulletin->forumcache["{$topstats_bit['forumid']}"]['description_clean']);
                
$topstats_bit['description']        = fetch_trimmed_title($topstats_bit['fulldescription'], 50);
                
$topstats_bit['threadcount']        = vb_number_format($topstats_bit['threadcount']);
                
$topstats_bit['replycount']        = vb_number_format($topstats_bit['replycount']);
            break;
            case 
12:
            case 
13:
            case 
14:
            case 
15:
            case 
16:
            case 
17:
            case 
18:
                
$topstats_bit['musername']        = fetch_musername($topstats_bit);
                
$topstats_bit['memberaction_dropdown']    = construct_memberaction_dropdown($topstats_bit);
                
$topstats_bit['usertitle']        = strip_tags($topstats_bit['usertitle']);
                
$topstats_bit['join_date']        = vbdate($vbulletin->options['dateformat'], $topstats_bit['joindate'], 1);
                
$topstats_bit['join_time']        = vbdate($vbulletin->options['timeformat'], $topstats_bit['joindate']);
                
$topstats_bit['activity_date']        = vbdate($vbulletin->options['dateformat'], $topstats_bit['lastactivity'], 1);
                
$topstats_bit['activity_time']        = vbdate($vbulletin->options['timeformat'], $topstats_bit['lastactivity']);
                
$topstats_bit['posts']            = vb_number_format($topstats_bit['posts']);
                
$topstats_bit['uploads']        = vb_number_format($topstats_bit['uploads']);
                
$topstats_bit['shouts']            = vb_number_format($topstats_bit['dbtech_vbshout_shouts_lifetime']);

                require_once(
DIR '/includes/functions_reputation.php');

                
$topstats_bit['showreputation'] = true;

                
cache_permissions($topstats_bit);
                
fetch_reputation_image($topstats_bit$topstats_bit['permissions']);
            break;
        }

        
$topstats_bits[] = $topstats_bit;
    }

    
$db->free_result($result);
    unset(
$topstats_bit);

    switch (
$_GET['show'])
    {
        case 
1:
        case 
2:
        case 
4:
        case 
5:
            
$templater vB_Template::Create('topstats_threads');
        break;
        case 
6:
            
$templater vB_Template::Create('topstats_threads_rating');
        break;
        case 
3:
        case 
7:
        case 
8:
        case 
9:
            
$templater vB_Template::Create('topstats_articles');
        break;
        case 
10:
        case 
11:
            
$templater vB_Template::Create('topstats_forums');
        break;
        case 
12:
        case 
13:
        case 
14:
        case 
15:
        case 
16:
        case 
17:
        case 
18:
            
$templater vB_Template::Create('topstats_users');
        break;
    }

    
$templater->register('pagenumber'$pagenumber);
    
$templater->register('topstats_bits'$topstats_bits);

    
print_output($templater->render());
}
?>
Attached Images
File Type: jpg 5.6.3.jpg (53.4 KB, 0 views)
File Type: jpg 7.1.8.jpg (25.9 KB, 0 views)
Reply With Quote
  #4  
Old 08-19-2017, 12:01 AM
Stingray27 Stingray27 is offline
 
Join Date: Jan 2006
Posts: 72
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You also havent shown what code is actually inside the foreach loop.
Reply With Quote
  #5  
Old 08-19-2017, 12:04 AM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you also upgrade to the latest version of vBulletin that supports PHP 7?
Reply With Quote
  #6  
Old 08-19-2017, 12:05 AM
Stingray27 Stingray27 is offline
 
Join Date: Jan 2006
Posts: 72
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by mainframe View Post
No errors whatsoever
That seems very unlikely, unless you have somehow disabled all error logging, are you sure you are checking the server logs ?
Reply With Quote
  #7  
Old 08-19-2017, 12:06 AM
mainframe mainframe is offline
 
Join Date: Jul 2004
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Stingray27 View Post
You also havent shown what code is actually inside the foreach loop.
That's just plain html code, even if I would put XXX there it should repeat the code inside for the number of results.

Quote:
Originally Posted by Dave View Post
Did you also upgrade to the latest version of vBulletin that supports PHP 7?
Yes, vBulletin works fine. it's just my own mods that act this way :-(

--------------- Added [DATE]1503109057[/DATE] at [TIME]1503109057[/TIME] ---------------

Quote:
Originally Posted by Stingray27 View Post
That seems very unlikely, unless you have somehow disabled all error logging, are you sure you are checking the server logs ?
That's what I find strange as well, if there was an error I probably wouldn't have to spend
hours tracking it down. I caused a few php errors on purpose and those showed up just fine.
Reply With Quote
  #8  
Old 08-19-2017, 12:26 AM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

When you add var_dump($topstats_bits); before you output the template, it shows all data properly that should be passed to the template?
Reply With Quote
  #9  
Old 08-19-2017, 12:27 AM
mainframe mainframe is offline
 
Join Date: Jul 2004
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

forgot this part.. sorry, it's been a few years since I made it.

It's a plugin on forumhome_start to initially display the mod.
The php file I posted earlier is used to retrieve data using AJAX

PHP Code:
if ($show['member'] AND (THIS_SCRIPT == 'index' OR THIS_SCRIPT == 'cardsharing'))
{
    foreach(
$vbulletin->forumcache AS $forum)
    {
        if (!
$forum['displayorder'] OR !($forum['options'] & $vbulletin->bf_misc_forumoptions['active']))
        {
            
$excluded_forum_ids .= ',' $forum['forumid'];
        }

        
$forumpermissions $vbulletin->userinfo['forumpermissions']["{$forum['forumid']}"];

        if (!(
$forumpermissions $vbulletin->bf_ugp_forumpermissions['canview']) AND ($vbulletin->forumcache["{$forum['forumid']}"]['showprivate'] == OR (!$vbulletin->forumcache["{$forum['forumid']}"]['showprivate'] AND !$vbulletin->options['showprivateforums'])))
        {
            
$excluded_forum_ids .= ',' $forum['forumid'];
        }

        if (
THIS_SCRIPT == 'cardsharing')
        {
            if (
in_array($forum['forumid'], array(2947,3061,3065,3150)))
            {
                
$included_forum_ids .= ',' substr($forum['childlist'], 0, -3);
            }
        }
    }

    unset(
$forumpermissions$forum);

    
$excluded_forum_ids substr($excluded_forum_ids1);

    if (
$excluded_forum_ids != '')
    {
        
$excluded_ids "AND data.forumid NOT IN($excluded_forum_ids)";
    }

    
$included_forum_ids substr($included_forum_ids1);

    if (
$included_forum_ids != '')
    {
        
$included_ids "AND data.forumid IN ($included_forum_ids)";
    }

    
$result $vbulletin->db->query_read("
        SELECT subscribeforumid, user.userid, usergroupid, displaygroupid, username, data.threadid, title, data.lastpost, data.forumid, pollid, replycount, views, attach, data.lastpostid, prefixid, taglist
        "
iif($vbulletin->options['threadmarking'] AND $vbulletin->userinfo['userid'], ', readtime') . "
        FROM " 
TABLE_PREFIX "thread AS data
        LEFT JOIN " 
TABLE_PREFIX "user AS user ON (user.userid = lastposterid)
        LEFT JOIN " 
TABLE_PREFIX "subscribeforum AS subscribeforum ON (subscribeforum.forumid = data.forumid AND subscribeforum.userid = " $vbulletin->userinfo['userid'] . ")
        " 
iif($vbulletin->options['threadmarking'] AND $vbulletin->userinfo['userid'], "LEFT JOIN " TABLE_PREFIX "threadread AS threadread ON (threadread.threadid = data.threadid AND threadread.userid = " .  $vbulletin->userinfo['userid'] . ")") . "
        WHERE NOT ISNULL(data.threadid) AND visible = '1' AND open != '10' 
$excluded_ids $included_ids
        ORDER BY lastpost DESC
        LIMIT 20
    "
);

    while (
$topstats_bit $db->fetch_array($resultMYSQL_ASSOC))
    {
        if (
$topstats_bit['lastpost'] > $vbulletin->userinfo['lastvisit'])
        {
            if (
$vbulletin->options['threadmarking'] AND $topstats_bit['readtime'])
            {
                
$threadview $topstats_bit['readtime'];
            }
            else
            {
                
$threadview intval(fetch_bbarray_cookie('thread_lastview'$topstats_bit['threadid']));
            }

            if (
$topstats_bit['lastpost'] > $threadview)
            {
                
$topstats_bit['newpost'] = true;
            }
        }

        if (!empty(
$topstats_bit['prefixid']))
        {
            
$topstats_bit['prefix'] = $vbphrase["prefix_{$topstats_bit['prefixid']}_title_rich"].": ";
        }

        
$topstats_bit['fullthreadtitle']    = strip_tags($topstats_bit['title']);
        
$topstats_bit['titletrimmed']        = fetch_trimmed_title($topstats_bit['title'], 40);
        
$topstats_bit['pageinfo_lastpost']    = array('p' => $topstats_bit['lastpostid']);
        
$topstats_bit['pageinfo_newpost']    = array('goto' => 'newpost');
        
$topstats_bit['taglist']        = strip_tags($topstats_bit['taglist']);
        
$topstats_bit['fullforumtitle']        = strip_tags($vbulletin->forumcache["{$topstats_bit['forumid']}"]['title_clean']);
        
$topstats_bit['forumtitle']        = fetch_trimmed_title($topstats_bit['fullforumtitle'], 25);
        
$topstats_bit['musername']        = fetch_musername($topstats_bit);
        
$topstats_bit['memberaction_dropdown']    = construct_memberaction_dropdown($topstats_bit);
        
$topstats_bit['date']            = vbdate($vbulletin->options['dateformat'], $topstats_bit['lastpost'], 1);
        
$topstats_bit['time']            = vbdate($vbulletin->options['timeformat'], $topstats_bit['lastpost']);
        
$topstats_bit['replycount']        = vb_number_format($topstats_bit['replycount']);
        
$topstats_bit['views']            = vb_number_format($topstats_bit['views']);

        
$topstats_bits[] = $topstats_bit;
        unset(
$topstats_bit);
    }

    
$db->free_result($result);

    
$templater vB_Template::Create('topstats');
    
$templater->register('topstats_bits'$topstats_bits);

    
$topstats['topstats'] = $templater->render();

    
vB_Template::preRegister('FORUMHOME'$topstats);

--------------- Added [DATE]1503110181[/DATE] at [TIME]1503110181[/TIME] ---------------

Quote:
Originally Posted by Dave View Post
When you add var_dump($topstats_bits); before you output the template, it shows all data properly that should be passed to the template?
You're on to something here, $topstats_bits = NULL on PHP 7.1.8
I'm new to php 7, maybe it doesn't like the way the array is initialized?
Reply With Quote
  #10  
Old 08-19-2017, 01:10 AM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What if you add $topstats_bits = []; on line 31, after requiring the global file?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:13 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05352 seconds
  • Memory Usage 2,564KB
  • Queries Executed 14 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (6)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (2)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete