[3.2][BETA] Best Answer

A place for Extension Authors to post and receive feedback on Extensions still in development. No Extensions within this forum should be used within a live environment!
Ideas Centre
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: Extensions Development rules

IMPORTANT FOR NEEDED EVENTS!!!
If you need an event for your extension please read this for the steps to follow to request the event(s)
User avatar
kinerity
Community Team Member
Community Team Member
Posts: 1895
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: [BETA] Best Answer

Post by kinerity » Tue Jul 26, 2016 6:44 pm

Using what release? I just pushed an update about 2 days ago that addressed this.
Kailey Truscott - Community Team

User avatar
SalazarAG
Registered User
Posts: 665
Joined: Mon Mar 30, 2015 10:48 am

Re: [BETA] Best Answer

Post by SalazarAG » Wed Jul 27, 2016 12:35 pm

There is a time I had a SQL error when activated the extension. How good it was fixed. great extension, my congratulations!
I'm sorry for my English. Google Translator does a bad job. :D

User avatar
SalazarAG
Registered User
Posts: 665
Joined: Mon Mar 30, 2015 10:48 am

Re: [BETA] Best Answer

Post by SalazarAG » Wed Jul 27, 2016 1:10 pm

ignore my previous comment ...

I installed, tested and after some time I have this error again

Code: Select all

	
Clique aqui para voltar ao índice	
Erro Geral
SQL ERROR [ mysqli ]

Not unique table/alias: 'p' [1066]

SQL

SELECT f.*, ft.mark_time, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, t.topic_id AS forum_last_post_topic_id, t.bestanswer_id, t.topic_id AS forum_last_post_topic_id FROM (phpbb_forums f) LEFT JOIN phpbb_forums_track ft ON (ft.user_id = 2 AND ft.forum_id = f.forum_id) LEFT JOIN phpbb_users u ON (u.user_id = f.forum_last_poster_id AND forum_type != 0) LEFT JOIN phpbb_posts p ON (f.forum_last_post_id = p.post_id) LEFT JOIN phpbb_topics t ON (t.topic_id = p.topic_id) LEFT JOIN phpbb_posts p ON (f.forum_last_post_id = p.post_id) LEFT JOIN phpbb_topics t ON (t.topic_id = p.topic_id) ORDER BY f.left_id

BACKTRACE

FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()

FILE: [ROOT]/phpbb/db/driver/driver.php
LINE: 855
CALL: trigger_error()

FILE: [ROOT]/phpbb/db/driver/mysqli.php
LINE: 193
CALL: phpbb\db\driver\driver->sql_error()

FILE: [ROOT]/phpbb/db/driver/factory.php
LINE: 329
CALL: phpbb\db\driver\mysqli->sql_query()

FILE: [ROOT]/includes/functions_display.php
LINE: 151
CALL: phpbb\db\driver\factory->sql_query()

FILE: [ROOT]/index.php
LINE: 75
CALL: display_forums()

Por favor, contate o administrador ou webmaster deste fórum: lucas_vinicius98@live.com
Powered by phpBB® Forum Software © phpBB Limited 
I'm sorry for my English. Google Translator does a bad job. :D

User avatar
kinerity
Community Team Member
Community Team Member
Posts: 1895
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: [BETA] Best Answer

Post by kinerity » Wed Jul 27, 2016 7:54 pm

That's cause by this function. Can you try replacing that entire function with the one below and let me know if it works? I'm not on my normal development computer.

Code: Select all

[removed]
If that one doesn't work, give this one a go.

Code: Select all

[removed]
Last edited by kinerity on Wed Jul 27, 2016 10:02 pm, edited 1 time in total.
Kailey Truscott - Community Team

User avatar
kasimi
Extension Customisations
Extension Customisations
Posts: 3223
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: [BETA] Best Answer

Post by kasimi » Wed Jul 27, 2016 8:29 pm

The code on GitHub looks fine to me.
  • $sql_ary['LEFT_JOIN'][] .= array(...); won't work as .= is only applicable to strings.
  • Code: Select all

    $sql_ary['FROM'][] = array(
        POSTS_TABLE     => 'p',
        TOPICS_TABLE    => 't',
    ); 
    This would result in the array below which doesn't look quite right. ;)

    Code: Select all

    array(
    	FORUMS_TABLE		=> 'f',
    	array(
    		POSTS_TABLE     => 'p',
    		TOPICS_TABLE    => 't',
    	)
    );
    This should work:

    Code: Select all

    $sql_ary['FROM'] = array_merge($sql_ary['FROM'], array(
        POSTS_TABLE     => 'p',
        TOPICS_TABLE    => 't',
    )); 
Apart from the above, in the SQL error there's a left join on the phpbb_users table which neither happens in phpBB's display_forums() function nor in this extension, so it's likely that there's a conflict with another extension that adds the duplicate left joins on the phpbb_posts and phpbb_topics table.

User avatar
SalazarAG
Registered User
Posts: 665
Joined: Mon Mar 30, 2015 10:48 am

Re: [BETA] Best Answer

Post by SalazarAG » Wed Jul 27, 2016 9:10 pm

I will try it.

But if it can be a conflict, I think it has to do with the Topic Count (which counts the topics of users). This extension has been a problem for me while I need a lot of it.
I'm sorry for my English. Google Translator does a bad job. :D

User avatar
kinerity
Community Team Member
Community Team Member
Posts: 1895
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: [BETA] Best Answer

Post by kinerity » Wed Jul 27, 2016 10:00 pm

kasimi wrote:
  • $sql_ary['LEFT_JOIN'][] .= array(...); won't work as .= is only applicable to strings.
Ah, you're right. I had a brain fart there. :P
kasimi wrote:the SQL error there's a left join on the phpbb_users table which neither happens in phpBB's display_forums() function nor in this extension, so it's likely that there's a conflict with another extension
I missed this. Thanks for pointing it out. I'll leave the code the way it is.
Kailey Truscott - Community Team

User avatar
SalazarAG
Registered User
Posts: 665
Joined: Mon Mar 30, 2015 10:48 am

Re: [BETA] Best Answer

Post by SalazarAG » Wed Jul 27, 2016 10:15 pm

I tried the codes and did not work! :(

I installed the extension in a new forum and the error did not occur. It seems to be a conflict with some other extension even. But they are many, it is difficult to find.
I'm sorry for my English. Google Translator does a bad job. :D

User avatar
kasimi
Extension Customisations
Extension Customisations
Posts: 3223
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: [BETA] Best Answer

Post by kasimi » Wed Jul 27, 2016 10:20 pm

SalazarAG wrote:But they are many, it is difficult to find.
Try to disable those that deal with avatars. :)

User avatar
SalazarAG
Registered User
Posts: 665
Joined: Mon Mar 30, 2015 10:48 am

Re: [BETA] Best Answer

Post by SalazarAG » Wed Jul 27, 2016 10:28 pm

kasimi wrote:
SalazarAG wrote:But they are many, it is difficult to find.
Try to disable those that deal with avatars. :)
I disabled "Last post avatar" and the erros appears changed

Code: Select all

Erro Geral
SQL ERROR [ mysqli ]

Not unique table/alias: 'p' [1066]

SQL

SELECT f.*, ft.mark_time, t.topic_id AS forum_last_post_topic_id, t.bestanswer_id, t.topic_id AS forum_last_post_topic_id FROM (phpbb_forums f) LEFT JOIN phpbb_forums_track ft ON (ft.user_id = 2 AND ft.forum_id = f.forum_id) LEFT JOIN phpbb_posts p ON (f.forum_last_post_id = p.post_id) LEFT JOIN phpbb_topics t ON (t.topic_id = p.topic_id) LEFT JOIN phpbb_posts p ON (f.forum_last_post_id = p.post_id) LEFT JOIN phpbb_topics t ON (t.topic_id = p.topic_id) ORDER BY f.left_id

BACKTRACE

FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()

FILE: [ROOT]/phpbb/db/driver/driver.php
LINE: 855
CALL: trigger_error()

FILE: [ROOT]/phpbb/db/driver/mysqli.php
LINE: 193
CALL: phpbb\db\driver\driver->sql_error()

FILE: [ROOT]/phpbb/db/driver/factory.php
LINE: 329
CALL: phpbb\db\driver\mysqli->sql_query()

FILE: [ROOT]/includes/functions_display.php
LINE: 151
CALL: phpbb\db\driver\factory->sql_query()

FILE: [ROOT]/index.php
LINE: 75
CALL: display_forums()
I'm sorry for my English. Google Translator does a bad job. :D

User avatar
kasimi
Extension Customisations
Extension Customisations
Posts: 3223
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: [BETA] Best Answer

Post by kasimi » Wed Jul 27, 2016 10:58 pm

Looks like there's another extension that adds t.topic_id AS forum_last_post_topic_id as well as those two duplicate left joins. Try to disable any extension that works with data from a forum's last post.
kinerity wrote:I'll leave the code the way it is.
You could try to only add the left joins if they aren't already present. I'm not sure if that's the most reliable way though.

Code: Select all

if (!$this->has_left_join($sql_ary['LEFT_JOIN'], POSTS_TABLE))
{
    $sql_ary['LEFT_JOIN'][] = array(
        'FROM'    => array(POSTS_TABLE => 'p'),
        'ON'    => 'f.forum_last_post_id = p.post_id',
    );
} 
... and the same for the TOPICS_TABLE. Here's the has_left_join() function:

Code: Select all

private function has_left_join($haystack, $needle)
{
    foreach ($haystack as $left_join)
    {
        if (isset($left_join['FROM'][$needle]))
        {
            return true;
        }
    }

    return false;
} 

User avatar
kinerity
Community Team Member
Community Team Member
Posts: 1895
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: [BETA] Best Answer

Post by kinerity » Thu Jul 28, 2016 1:26 am

kasimi wrote:Looks like there's another extension that adds t.topic_id AS forum_last_post_topic_id
That line is probably going to change. I don't think it's needed, but I need to test it out. As a matter of fact, that whole function will probably change.
Kailey Truscott - Community Team

User avatar
SalazarAG
Registered User
Posts: 665
Joined: Mon Mar 30, 2015 10:48 am

Re: [BETA] Best Answer

Post by SalazarAG » Fri Jul 29, 2016 1:35 am

Hello again!

The conflict is with the extension [pre]fixed.

I do not know how to solve, but the two extensions are useful.
I'm sorry for my English. Google Translator does a bad job. :D

User avatar
kinerity
Community Team Member
Community Team Member
Posts: 1895
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: [BETA] Best Answer

Post by kinerity » Fri Jul 29, 2016 2:14 am

I actually just pushed an update. See if it solves your problem. It's a variation of kasimi's code.
Kailey Truscott - Community Team

User avatar
SalazarAG
Registered User
Posts: 665
Joined: Mon Mar 30, 2015 10:48 am

Re: [BETA] Best Answer

Post by SalazarAG » Fri Jul 29, 2016 2:59 am

Updated and the problem is solved!

Thank kinerity!
I'm sorry for my English. Google Translator does a bad job. :D

Post Reply

Return to “Extensions in Development”

Who is online

Users browsing this forum: dio33, kustajuspin and 12 guests