Question Conflicting addons

Status
Not open for further replies.

madness85

Customer
Hi,

I have an issue with this addon and similar threads addon by AndyB.

Similar threads isn't working, if class extension "DBTech\Shop\XF\Entity\Thread" is disabled the Similar threads add-on works.

I asked AndyB to have a look at it and he was unable to find the issue. Would you be kind enough to have a look at this for me?
 
You should not be using any of their add-ons, as they are a security and performance nightmare.

That being said, they are likely not using XFCP to properly extend the Thread entity, they have changed the keyword for the _preSave / _postSave / _preDelete / _postDelete functions (they should be protected, not public), or they are not properly calling the parent of those functions in their extensions.
 
His reply:
The Similar threads add-on is properly extending the Thread entity. Here's the code:
Code:
<?php

namespace Andy\SimilarThreads\XF\Pub\Controller;

use XF\Mvc\ParameterBag;

class Thread extends XFCP_Thread
{
public function actionIndex(ParameterBag $params)
{
//########################################
// show similar threads in thread view
//########################################

// get parent
$parent = parent::actionIndex($params);

// return parent action if this is a redirect or other non View response
if (!$parent instanceof \XF\Mvc\Reply\View)
{
return $parent;
}

// get visitor
$visitor = \XF::visitor();

// check for user group permission
if (!$visitor->hasPermission('similarThreads', 'view'))
{
return $parent;
}

// get options
$options = \XF::options();

// get options from Admin CP -> Options -> Similar threads -> Enhanced search
$enhancedSearch = $options->similarThreadsEnhancedSearch;

// get thread
$thread = $this->assertViewableThread($params->thread_id);

// get currentNodeId
$currentNodeId = $thread->node_id;

// get currentThreadId
$currentThreadId = $thread->thread_id;

// get thread title
$threadTitle = $thread->title;

// use standard search
if (!$enhancedSearch)
{
$similarThreads = $this->getSimilarThreadsRepo()->getSimilarThreads($currentNodeId, $currentThreadId, $threadTitle);
}

// use enhanced search
if ($enhancedSearch)
{
$similarThreads = $this->getSimilarThreadsRepo()->getSimilarThreadsEnhanced($currentNodeId, $currentThreadId, $threadTitle);
}

// set parent
$parent->setParams([
'similarThreads' => $similarThreads
]);

// return parent
return $parent;
}

protected function getSimilarThreadsRepo()
{
return $this->repository('Andy\SimilarThreads:SimilarThreads');
}
}

I hate being the man in the middle in these situations :(
 
Then I will need more information about why you say the Similar Threads addon doesn't work. Can you please clarify?
 
Status
Not open for further replies.

DragonByte Shop

XenForo 1.5.3+ XenForo 2.0.x XenForo 2.1.x XenForo 2.2.x
Seller
DragonByte Technologies
Release date
Last update
Total downloads
3,228
Customer rating
5.00 star(s) 3 ratings
Top