Not a bug Duplicate position in xf_post causes add-on to show error

AndyB

Well-known member
Affected version
Beta 7
If there's a duplicate position (see position 21) in the xf_post table like this:

1509289346809.webp

and in the thread_view there's a page number showing which doesn't actually exist, if that page number is clicked add-ons will show an error.

I was hoping the redirect portion of the PHP code would prevent the error but it does not.

PHP:
<?php

namespace Andy\Calendar\XF\Pub\Controller;

use XF\Mvc\ParameterBag;

class Thread extends XFCP_Thread
{
    public function actionIndex(ParameterBag $params)
    {      
        //########################################
        // show calendar dates in thread_view
        //########################################
      
        // get thread
        $thread = $this->assertViewableThread($params->thread_id, $this->getThreadViewExtraWith());

        // check if redirect
        if ($thread->discussion_type == 'redirect')
        {
            if (!$thread->Redirect)
            {
                return $this->noPermission();
            }

            return $this->redirectPermanently($this->request->convertToAbsoluteUri($thread->Redirect->target_url));
        }      
...

This is the error message:

1509289589519.webp

Line #139

1509289698688.webp
 
The error message suggests this is a problem with your extension of the code. Notably, you're trying to set view params on a Redirect reply rather than a View reply.

You should create a new thread in the development discussions forum.
 
Top Bottom