[3.2][BETA] User Topic Count

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!
Anti-Spam Guide
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
kasimi
Extension Customisations
Extension Customisations
Posts: 3216
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: [3.2][BETA] User Topic Count

Post by kasimi » Sun Jun 17, 2018 8:41 am

martti wrote:
Sat Jun 16, 2018 8:42 am
Because the "Topic Count" for all users is calculated and stored in the column when enabling the extension.
Schema changes should be done in migrations only. Run your resync code via a custom method from within your migration on install: https://area51.phpbb.com/docs/dev/3.2.x ... -processes

To cover the disable/enable cases, you can run the resync code in your ext.php only if the column exists.

User avatar
martti
Registered User
Posts: 653
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [3.2][BETA] User Topic Count

Post by martti » Sun Jun 17, 2018 9:27 pm

kasimi wrote:
Sun Jun 17, 2018 8:41 am
Thanks! I've updated the code accordingly. Version 0.3.0

Voice4Vision
Registered User
Posts: 6
Joined: Sat Feb 14, 2009 8:58 pm

Re: [3.2][BETA] User Topic Count

Post by Voice4Vision » Mon Jun 18, 2018 2:19 am

I get the following error when attempting to enable version 0.3.0

Code: Select all

SQL ERROR [ mysqli ]

Unknown column 'u.user_topic_count' in 'having clause' [1054]

SQL

select count(t.topic_id) as topic_count, u.user_id from bbv4v_topics t, bbv4v_users u where t.topic_visibility = 1 and t.topic_poster = u.user_id and u.user_id >= 1 and u.user_id <= 1001 and u.user_id <> 1 group by t.topic_poster having count(t.topic_id) <> u.user_topic_count

BACKTRACE

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

FILE: [ROOT]/phpbb/db/driver/driver.php
LINE: 997
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]/ext/marttiphpbb/usertopiccount/service/update.php
LINE: 86
CALL: phpbb\db\driver\factory->sql_query()

FILE: [ROOT]/ext/marttiphpbb/usertopiccount/service/update.php
LINE: 109
CALL: marttiphpbb\usertopiccount\service\update->for_sql_where()

FILE: [ROOT]/ext/marttiphpbb/usertopiccount/ext.php
LINE: 57
CALL: marttiphpbb\usertopiccount\service\update->for_user_range()

FILE: [ROOT]/phpbb/extension/manager.php
LINE: 190
CALL: marttiphpbb\usertopiccount\ext->enable_step()

FILE: [ROOT]/includes/acp/acp_extensions.php
LINE: 209
CALL: phpbb\extension\manager->enable_step()

FILE: [ROOT]/includes/functions_module.php
LINE: 676
CALL: acp_extensions->main()

FILE: [ROOT]/adm/index.php
LINE: 82
CALL: p_master->load_active()

User avatar
martti
Registered User
Posts: 653
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [3.2][BETA] User Topic Count

Post by martti » Mon Jun 18, 2018 8:54 am

Voice4Vision wrote:
Mon Jun 18, 2018 2:19 am
I get the following error when attempting to enable version 0.3.0
...
It's because MySQL expects the column be present in the SELECT also
https://stackoverflow.com/questions/361 ... ing-clause
According to the post on Stackoverflow it's not standard SQL so maybe it will be better to find something else then the HAVING clause (a nested SELECT).

I've add the user_topic_count column for now in the SELECT in version 0.4.0

ko13o
Registered User
Posts: 6
Joined: Tue May 08, 2018 8:10 am

Re: [3.2][BETA] User Topic Count

Post by ko13o » Thu Jun 21, 2018 4:35 pm

martti wrote:
Mon Jun 18, 2018 8:54 am
Voice4Vision wrote:
Mon Jun 18, 2018 2:19 am
I get the following error when attempting to enable version 0.3.0
...
It's because MySQL expects the column be present in the SELECT also
https://stackoverflow.com/questions/361 ... ing-clause
According to the post on Stackoverflow it's not standard SQL so maybe it will be better to find something else then the HAVING clause (a nested SELECT).

I've add the user_topic_count column for now in the SELECT in version 0.4.0
is there a version for php 5.6.32

User avatar
martti
Registered User
Posts: 653
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [3.2][BETA] User Topic Count

Post by martti » Thu Jun 21, 2018 4:49 pm

ko13o wrote:
Thu Jun 21, 2018 4:35 pm
is there a version for php 5.6.32
No, PHP 7+ only

ko13o
Registered User
Posts: 6
Joined: Tue May 08, 2018 8:10 am

Re: [3.2][BETA] User Topic Count

Post by ko13o » Fri Jun 22, 2018 12:50 pm

martti wrote:
Thu Jun 21, 2018 4:49 pm
ko13o wrote:
Thu Jun 21, 2018 4:35 pm
is there a version for php 5.6.32
No, PHP 7+ only
is there any way it can be used in version 5. ???
in addition to Update server

User avatar
martti
Registered User
Posts: 653
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [3.2][BETA] User Topic Count

Post by martti » Fri Jun 22, 2018 12:54 pm

ko13o wrote:
Fri Jun 22, 2018 12:50 pm
is there any way it can be used in version 5. ???
in addition to Update server
The most logical is to update your PHP. Why keep hanging in 5 when 7 is there already for a long time (and is much faster)?

Otherwise: fork and change the code to make it work in version 5.

User avatar
Restless Rancor
Registered User
Posts: 105
Joined: Tue Sep 18, 2018 1:51 pm

Re: [3.2][BETA] User Topic Count

Post by Restless Rancor » Sat Oct 13, 2018 12:06 pm

Hi, is this extension still under development?

I've installed version 0.4.0 onto a clean phpBB 3.2.3 installation and have observed the following behavior:

The Topic Count shows the total number of topics the member has regardless of if they are in a "private" forum (a staff forum for example). When clicking on the topic count it only shows topics visible to the member who clicked it: I know this is intentional, but would it be possible to disable the topic count increment in specific forums just as you can for posts, or, have the topic count only show the number of visible topics so the user?

More importantly, if I delete a topic in the topic view I get an SQL error:

Code: Select all

General Error
SQL ERROR [ mysqli ]

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*) as topic_count, ps.poster_id from (select min(p.post_id), p.poster_id, p.t' at line 1 [1064]

SQL

select count(ps.*) as topic_count, ps.poster_id from (select min(p.post_id), p.poster_id, p.topic_id from phpbb_posts p where p.post_visibility = 1 group by p.topic_id) ps where p.poster_id = 2 group by ps.poster_id

BACKTRACE

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

FILE: [ROOT]/phpbb/db/driver/driver.php
LINE: 997
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]/ext/marttiphpbb/usertopiccount/service/update.php
LINE: 57
CALL: phpbb\db\driver\factory->sql_query()

FILE: [ROOT]/ext/marttiphpbb/usertopiccount/event/update_listener.php
LINE: 190
CALL: marttiphpbb\usertopiccount\service\update->for_unsynced_user_ary()

FILE: [ROOT]/vendor/symfony/event-dispatcher/EventDispatcher.php
LINE: 184
CALL: marttiphpbb\usertopiccount\event\update_listener->core_delete_posts_after()

FILE: [ROOT]/vendor/symfony/event-dispatcher/EventDispatcher.php
LINE: 46
CALL: Symfony\Component\EventDispatcher\EventDispatcher->doDispatch()

FILE: [ROOT]/phpbb/event/dispatcher.php
LINE: 62
CALL: Symfony\Component\EventDispatcher\EventDispatcher->dispatch()

FILE: [ROOT]/phpbb/event/dispatcher.php
LINE: 46
CALL: phpbb\event\dispatcher->dispatch()

FILE: [ROOT]/includes/functions_admin.php
LINE: 1129
CALL: phpbb\event\dispatcher->trigger_event()

FILE: [ROOT]/includes/functions_posting.php
LINE: 1240
CALL: delete_posts()

FILE: [ROOT]/includes/functions_posting.php
LINE: 2661
CALL: delete_post()

FILE: [ROOT]/posting.php
LINE: 483
CALL: phpbb_handle_post_delete()
The topic is deleted but a shadow remains and it must be deleted "again" via the MCP.

Thanks
These aren't the droids you're looking for...
My snippets | I'm currently (slowly) learning php as a hobby, aiming to be able to write somewhat useful extensions. :roll:

User avatar
pikachuturkey
Registered User
Posts: 241
Joined: Wed Dec 20, 2006 10:34 pm
Name: Rıza
Contact:

Re: [3.2][BETA] User Topic Count

Post by pikachuturkey » Sat Oct 13, 2018 12:26 pm

Turkish (tr) language for "[3.2][BETA] User Topic Count" (from github, date:13.10.2018)

Code: Select all

<?php
/**
* phpBB Extension - marttiphpbb usertopiccount
* @copyright (c) 2015 - 2018 marttiphpbb <info@martti.be>
* @license GNU General Public License, version 2 (GPL-2.0)
*/
if (!defined('IN_PHPBB'))
{
	exit;
}
if (empty($lang) || !is_array($lang))
{
	$lang = [];
}
$lang = array_merge($lang, [
	'MARTTIPHPBB_USERTOPICCOUNT_TOTAL'				=> 'Toplam konu',
	'MARTTIPHPBB_USERTOPICCOUNT_SEARCH'				=> 'Kullanıcı konularını ara',
	'MARTTIPHPBB_USERTOPICCOUNT_SEARCH_YOUR_TOPICS'	=> 'Konularını göster',
]);
Health For Everyone ==> www.saglikforum.org

User avatar
martti
Registered User
Posts: 653
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [3.2][BETA] User Topic Count

Post by martti » Sat Oct 13, 2018 6:51 pm

Restless Rancor wrote:
Sat Oct 13, 2018 12:06 pm
More importantly, if I delete a topic in the topic view I get an SQL error:

Code: Select all

General Error
SQL ERROR [ mysqli ]

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*) as topic_count, ps.poster_id from (select min(p.post_id), p.poster_id, p.t' at line 1 [1064]

SQL

select count(ps.*) as topic_count, ps.poster_id from (select min(p.post_id), p.poster_id, p.topic_id from phpbb_posts p where p.post_visibility = 1 group by p.topic_id) ps where p.poster_id = 2 group by ps.poster_id

BACKTRACE

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

FILE: [ROOT]/phpbb/db/driver/driver.php
LINE: 997
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]/ext/marttiphpbb/usertopiccount/service/update.php
LINE: 57
CALL: phpbb\db\driver\factory->sql_query()

FILE: [ROOT]/ext/marttiphpbb/usertopiccount/event/update_listener.php
LINE: 190
CALL: marttiphpbb\usertopiccount\service\update->for_unsynced_user_ary()

FILE: [ROOT]/vendor/symfony/event-dispatcher/EventDispatcher.php
LINE: 184
CALL: marttiphpbb\usertopiccount\event\update_listener->core_delete_posts_after()

FILE: [ROOT]/vendor/symfony/event-dispatcher/EventDispatcher.php
LINE: 46
CALL: Symfony\Component\EventDispatcher\EventDispatcher->doDispatch()

FILE: [ROOT]/phpbb/event/dispatcher.php
LINE: 62
CALL: Symfony\Component\EventDispatcher\EventDispatcher->dispatch()

FILE: [ROOT]/phpbb/event/dispatcher.php
LINE: 46
CALL: phpbb\event\dispatcher->dispatch()

FILE: [ROOT]/includes/functions_admin.php
LINE: 1129
CALL: phpbb\event\dispatcher->trigger_event()

FILE: [ROOT]/includes/functions_posting.php
LINE: 1240
CALL: delete_posts()

FILE: [ROOT]/includes/functions_posting.php
LINE: 2661
CALL: delete_post()

FILE: [ROOT]/posting.php
LINE: 483
CALL: phpbb_handle_post_delete()
The topic is deleted but a shadow remains and it must be deleted "again" via the MCP.

Thanks
Maybe the AS keyword is required for the alias of the subquery. What is your database and version?

User avatar
Restless Rancor
Registered User
Posts: 105
Joined: Tue Sep 18, 2018 1:51 pm

Re: [3.2][BETA] User Topic Count

Post by Restless Rancor » Sat Oct 13, 2018 6:53 pm

martti wrote:
Sat Oct 13, 2018 6:51 pm
Maybe the AS keyword is required for the alias of the subquery. What is your database and version?
Hi, it's MySQL 5.5
These aren't the droids you're looking for...
My snippets | I'm currently (slowly) learning php as a hobby, aiming to be able to write somewhat useful extensions. :roll:

User avatar
martti
Registered User
Posts: 653
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [3.2][BETA] User Topic Count

Post by martti » Sat Oct 13, 2018 10:11 pm

Restless Rancor wrote:
Sat Oct 13, 2018 12:06 pm
More importantly, if I delete a topic in the topic view I get an SQL error:
I launched version 0.5.0 now that takes another approach in handling the deletion of topics.

User avatar
martti
Registered User
Posts: 653
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [3.2][BETA] User Topic Count

Post by martti » Sun Oct 14, 2018 8:21 am

Restless Rancor wrote:
Sat Oct 13, 2018 12:06 pm
I've installed version 0.4.0 onto a clean phpBB 3.2.3 installation and have observed the following behavior:

The Topic Count shows the total number of topics the member has regardless of if they are in a "private" forum (a staff forum for example). When clicking on the topic count it only shows topics visible to the member who clicked it: I know this is intentional, but would it be possible to disable the topic count increment in specific forums just as you can for posts, or, have the topic count only show the number of visible topics so the user?
  • Showing a different topic counts to according to permissions is going to be overcomplicated (for my taste) or create overhead when the topic count has to be calculated every time on page load.
  • I don't like the standard setup of the phpBB post count with forum permissions (also too overcomplicated for my taste) where only posts in certain forums are counted.
    Furthermore, this extension works differently; it doesn't add or remove topics to/from the counting, but it recalculates the entire user topic count each time a change takes place. (in order to avoid sync problems).
Therefore, I decided to show only the total count of topics of each user regardless if you can reach them or not.
So,in general I would say this extension will work best in boards where everyone has viewing access to all forums.
To avoid confusion on boards with "private" forums, I think a solution might be to add an explanation in the search page, something like
This user has 4 more topics that are in forums for which you don't have viewing permission.
That's something I could add.

User avatar
Restless Rancor
Registered User
Posts: 105
Joined: Tue Sep 18, 2018 1:51 pm

Re: [3.2][BETA] User Topic Count

Post by Restless Rancor » Sun Oct 14, 2018 10:46 am

martti wrote:
Sun Oct 14, 2018 8:21 am
  • Showing a different topic counts to according to permissions is going to be overcomplicated (for my taste) or create overhead when the topic count has to be calculated every time on page load.
  • I don't like the standard setup of the phpBB post count with forum permissions (also too overcomplicated for my taste) where only posts in certain forums are counted.
    Furthermore, this extension works differently; it doesn't add or remove topics to/from the counting, but it recalculates the entire user topic count each time a change takes place. (in order to avoid sync problems).
Therefore, I decided to show only the total count of topics of each user regardless if you can reach them or not.
So,in general I would say this extension will work best in boards where everyone has viewing access to all forums.
To avoid confusion on boards with "private" forums, I think a solution might be to add an explanation in the search page, something like
This user has 4 more topics that are in forums for which you don't have viewing permission.
That's something I could add.
Hi martti, thank you for the detailed explanation. I'm honestly not 100% sure if I'd use the extension, even with the This user has 4 more...., but am happy to install it to test should you add it. :)
These aren't the droids you're looking for...
My snippets | I'm currently (slowly) learning php as a hobby, aiming to be able to write somewhat useful extensions. :roll:

Post Reply

Return to “Extensions in Development”

Who is online

Users browsing this forum: Guldstrand, nextgen and 36 guests