×
Kunena 5.1.18 Released (30 Jun 2020)

The Kunena team has announce the arrival of Kunena 5.1.18 [K 5.1.18] which is now available for download as a native Joomla extension for J! 3.9.x. This version addresses most of the issues that were discovered in K 5.1 and issues discovered during the development stages of K 5.1.

× Topics that are moved into this category are generally considered to be closed. Users may want to add additional information but these topics should not be resurrected in order to discuss new problems or unrelated matters.

Solved KunenaDiscuss messing up article id (from JInput) | Fix included

More
3 years 4 months ago - 3 years 4 months ago #1 by ruud
Hi, I have a module that will display the latest articles from the same category as the displayed article.

All fine except when there is a post avaialble on Kunena that is displayed via KunenaDiscuss.

here is what happens:
when I var_dump JFactory::getApplication(); I get the followinf JInput information:
              object(JInput)#11 (4) {
                ["options":protected]=>
                array(0) {
                }
                ["filter":protected]=>
                object(JFilterInput)#12 (8) {
                  ["stripUSC"]=>
                  int(0)
                  ["tagsArray"]=>
                  array(0) {
                  }
                  ["attrArray"]=>
                  array(0) {
                  }
                  ["tagsMethod"]=>
                  int(0)
                  ["attrMethod"]=>
                  int(0)
                  ["xssAuto"]=>
                  int(1)
...
                ["data":protected]=>
                &array(5) {
                  ["Itemid"]=>
                  string(4) "1811"
                  ["option"]=>
                  string(11) "com_content"
                  ["view"]=>
                  string(7) "article"
                  ["catid"]=>
                  int(87)
                  ["id"]=>
                  int(1020)
                }
...

As you can see the article id is 1020... but that real article id is 522???
1020 is the Kunena thread_id!!!

This means that all plugins / modules that need to handle the article id will go in error...

when I turn of KunenaDiscuss the values are correct:
...
                ["data":protected]=>
                &array(5) {
                  ["Itemid"]=>
                  string(4) "1811"
                  ["option"]=>
                  string(11) "com_content"
                  ["view"]=>
                  string(7) "article"
                  ["catid"]=>
                  int(87)
                  ["id"]=>
                  int(522)
                }
...

sharing = caring
Last edit: 3 years 4 months ago by ruud.

Please Log in or Create an account to join the conversation.

More
3 years 4 months ago - 3 years 4 months ago #2 by ruud
this method is where it goes wrong:
        protected function showTopic(KunenaForumCategory $category, KunenaForumTopic $topic, $link_topic)
        {
                if (!$topic->exists())
                {
                        $this->debug("showTopic: No messages to render");
 
                        return '';
                }
 
                $this->debug("showTopic: Rendering discussion");
 
                $ordering = $this->params->get('ordering', 1); // 0=ASC, 1=DESC
                $params   = array(
                        'catid'            => $category->id,
                        'id'               => $topic->id,
                        'limitstart'       => (int) !$ordering,
                        'limit'            => $this->params->get('limit', 25),
                        'filter_order_Dir' => $ordering ? 'desc' : 'asc',
                        'templatepath'     => __DIR__ . '/tmpl'
                );
                ob_start();
                KunenaForum::display('topic', 'default', null, $params);
                $str = ob_get_contents();
                ob_end_clean();
 
                return $link_topic . $str;
        }
before call KunenaForum::display('topic', 'default', null, $params);
the id = 522 after the id = 1020

so in KunenaForum::display the following code sets the article id to topic id
                // Render the view.
                $view->displayLayout($layout, $template);

This is far as I get :(

sharing = caring
Last edit: 3 years 4 months ago by ruud.

Please Log in or Create an account to join the conversation.

More
3 years 4 months ago #3 by ruud
This would be a 'work-around' or if reworked a fix. Can somebody have a look?
	protected function showTopic(KunenaForumCategory $category, KunenaForumTopic $topic, $link_topic)
	{
		if (!$topic->exists())
		{
			$this->debug("showTopic: No messages to render");
 
			return '';
		}
 
		$this->debug("showTopic: Rendering discussion");
 
		// FIX: Store article's ID
		$article_id = $this->app->input->get('id');
 
		$ordering = $this->params->get('ordering', 1); // 0=ASC, 1=DESC
		$params   = array(
			'catid'            => $category->id,
			'id'               => $topic->id,
			'limitstart'       => (int) !$ordering,
			'limit'            => $this->params->get('limit', 25),
			'filter_order_Dir' => $ordering ? 'desc' : 'asc',
			'templatepath'     => __DIR__ . '/tmpl'
		);
		ob_start();
		KunenaForum::display('topic', 'default', null, $params);
		$str = ob_get_contents();
		ob_end_clean();
 
		// FIX: Set article's ID back
		$this->app->input->set('id', $article_id);
 
		return $link_topic . $str;
	}

sharing = caring

Please Log in or Create an account to join the conversation.

More
3 years 1 month ago #4 by ruud
fix implemented in Kunena 5.0.8 :)
topic can be set to solved

sharing = caring

Please Log in or Create an account to join the conversation.

  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to edit your message.
Time to create page: 0.100 seconds