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

Incompatibility with Endless plugin #2

Closed
Eisteed opened this issue Jul 23, 2021 · 5 comments
Closed

Incompatibility with Endless plugin #2

Eisteed opened this issue Jul 23, 2021 · 5 comments

Comments

@Eisteed
Copy link

Eisteed commented Jul 23, 2021

Hey, really cool plugin works great but is there any way of making this compatible with endless plugin ?
https://community.mybb.com/mods.php?action=view&pid=1439

I'm using it for an infinite scroll in threadlist, this is the SQL error I get when endless try to load the other threads when scrolling (line 100 in threadpreview.php) :

SQL Error: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 5
Query: SELECT t.tid, t.firstpost, p.message
			FROM mybb_threads t
			LEFT JOIN mybb_posts p
			ON(t.firstpost=p.pid)
			WHERE t.tid IN()
Back Trace: #0  errorHandler-
Query: SELECT t.tid, t.firstpost, p.message
			FROM mybb_threads t
			LEFT JOIN mybb_posts p
			ON(t.firstpost=p.pid)
			WHERE t.tid IN(), , 0) called at [public_html/inc/class_error.php:203]
#1  errorHandler-
			FROM mybb_threads t
			LEFT JOIN mybb_posts p
			ON(t.firstpost=p.pid)
			WHERE t.tid IN())) called at [public_html/inc/db_mysqli.php:601]
#2  DB_MySQLi-
			FROM mybb_threads t
			LEFT JOIN mybb_posts p
			ON(t.firstpost=p.pid)
			WHERE t.tid IN()) called at [public_html/inc/db_mysqli.php:337]
#3  DB_MySQLi-
			FROM mybb_threads t
			LEFT JOIN mybb_posts p
			ON(t.firstpost=p.pid)
			WHERE t.tid IN()) called at [public_html/inc/plugins/threadpreview.php:100]
#4  threadpreview_preview() called at [public_html/inc/class_plugins.php:142]

Thanks

@MangaD
Copy link
Owner

MangaD commented Jul 23, 2021

Hello, I am not familiar with the endless plugin and have no intention to support it. But as this project is open source, anyone is welcome to contribute.

@Eisteed
Copy link
Author

Eisteed commented Jul 23, 2021

Alright ;( I don't know much about mybb plugins dev but I will try to find a fix.

@Eisteed
Copy link
Author

Eisteed commented Jul 24, 2021

Okay easier than I thought, but I don't know if this is a proper way to do it. I added another function to threadpreview

function threadpreview_getPreview($thread)
{
	global $mybb, $db, $tids, $threadcache, $thread, $firstpostcache;
	$query = $db->query("SELECT t.tid, t.firstpost, p.message
			FROM " . TABLE_PREFIX . "threads t
			LEFT JOIN " . TABLE_PREFIX . "posts p
			ON(t.firstpost=p.pid)
			WHERE t.tid IN(" . $thread['tid'] . ")");
	while($data = $db->fetch_array($query))
	{
		$firstpostcache[$data['tid']] = replaceMedia($data['message']);
		//$firstpostcache[$data['tid']] = substr($data['message'], 0, (int)$mybb->settings['threadpreview_maxlength']);
		//$threadcache[$data['tid']]['preview'] = $data['message'];
	}

	// MangaD - parse mycode, smilies...
	global $parser;
	if(!$parser)
	{
		require_once MYBB_ROOT."inc/class_parser.php";
		$parser = new postParser;
	}

	$parser_options = array(
		"allow_html" => (int)$mybb->settings['pmsallowhtml'],
		"allow_mycode" => (int)$mybb->settings['pmsallowmycode'],
		"allow_smilies" => (int)$mybb->settings['pmsallowsmilies'],
		"allow_imgcode" => (int)$mybb->settings['pmsallowimgcode'],
		"allow_videocode" => (int)$mybb->settings['pmsallowvideocode'],
		"nofollow_on" => 1,
		"filter_badwords" => 1
	);

	$thread['preview'] = $parser->parse_message($firstpostcache[$thread['tid']], $parser_options);
	$thread['preview'] = truncateHTML((int)$mybb->settings['threadpreview_maxlength'], $thread['preview']);
}

then inside endless I can call threadpreview_getPreview with the current $thread being created as argument.

@MangaD
Copy link
Owner

MangaD commented Jul 24, 2021

The only problem I see is that there's a reference to the $thread global variable inside the function, that possibly conflicts with the argument.

@Eisteed
Copy link
Author

Eisteed commented Jul 24, 2021

Yea I wasn't sure about how to use those but it's working like that ^^
Removing $thread returns an empty $thread['preview']

@Eisteed Eisteed closed this as completed Jul 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants