[CDB] Top Poster Of The Month (reloaded)

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
takufner
Registered User
Posts: 215
Joined: Mon Oct 23, 2006 10:39 am
Location: Rio de Janeiro - Brasil
Name: Prof. Caju
Contact:

Re: [3.1][3.2][RC] Top Poster Of The Month (reloaded)

Post by takufner »

Hello 3Di,

I am a little without free time this week, but I gave a try in this new version and could see that the load average is still going up, but now to a lesser degree (before it was going to 25 or 30, and now is going to 5).

And could spot two errors:

First. Every page load I get the debug notice:

Code: Select all

[phpBB Debug] PHP Warning: in file [ROOT]/ext/threedi/tpotm/core/tpotm.php on line 555: Division by zero
Second. When trying to change the extension settings in ACP, I get the following SQL Error.

Code: Select all

 Erro Geral
SQL ERROR [ mysqli ]

Duplicate entry 'threedi_tpotm_index' for key 'PRIMARY' [1062]

SQL

INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('threedi_tpotm_index', 0, 0)

BACKTRACE

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

FILE: [ROOT]/phpbb/db/driver/driver.php
LINE: 999
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]/phpbb/config/db.php
LINE: 161
CALL: phpbb\db\driver\factory->sql_query()

FILE: [ROOT]/phpbb/config/db.php
LINE: 122
CALL: phpbb\config\db->set_atomic()

FILE: [ROOT]/ext/threedi/tpotm/acp/tpotm_module.php
LINE: 80
CALL: phpbb\config\db->set()

FILE: [ROOT]/includes/functions_module.php
LINE: 676
CALL: threedi\tpotm\acp\tpotm_module->main()

FILE: [ROOT]/adm/index.php
LINE: 82
CALL: p_master->load_active()
Just to mention, after enabling the extension, the load average kept around 5, and the navigation on the forum was really slow.

Thanks for your help,
User avatar
3Di
Former Team Member
Posts: 16032
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: [3.1][3.2][RC] Top Poster Of The Month (reloaded)

Post by 3Di »

I am unable to reproduce those errors in my environment, (PHP 5.6.xx or 7.04 and MySql(i) 5.7.11 or more)

I guess I need a test account?¿
Or at least a screenshot of your ACP settings.

Could you try to change the line 555 from
$percent = min(100, ((int) $tpotm_tot_posts) / (int) $total_month) * 100;
to
$percent = min(100, ((int) $tpotm_tot_posts / (int) $total_month) * 100);
and see if the division by zero is gone? Thx.
Last edited by 3Di on Fri Sep 29, 2017 1:35 pm, edited 1 time in total.
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
Looking for a specific feature or alternative option? We will rock you! 🚀
User avatar
Elsensee
Former Team Member
Posts: 122
Joined: Sat May 07, 2011 11:04 am
Location: Hamburg, Germany
Name: Oliver Schramm
Contact:

Re: [3.1][3.2][RC] Top Poster Of The Month (reloaded)

Post by Elsensee »

takufner wrote:
Fri Sep 29, 2017 1:10 pm
Hello 3Di,

I am a little without free time this week, but I gave a try in this new version and could see that the load average is still going up, but now to a lesser degree (before it was going to 25 or 30, and now is going to 5).

And could spot two errors:

First. Every page load I get the debug notice:

Code: Select all

[phpBB Debug] PHP Warning: in file [ROOT]/ext/threedi/tpotm/core/tpotm.php on line 555: Division by zero
Second. When trying to change the extension settings in ACP, I get the following SQL Error.

Code: Select all

 Erro Geral
SQL ERROR [ mysqli ]

Duplicate entry 'threedi_tpotm_index' for key 'PRIMARY' [1062]

SQL

INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('threedi_tpotm_index', 0, 0)

BACKTRACE

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

FILE: [ROOT]/phpbb/db/driver/driver.php
LINE: 999
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]/phpbb/config/db.php
LINE: 161
CALL: phpbb\db\driver\factory->sql_query()

FILE: [ROOT]/phpbb/config/db.php
LINE: 122
CALL: phpbb\config\db->set_atomic()

FILE: [ROOT]/ext/threedi/tpotm/acp/tpotm_module.php
LINE: 80
CALL: phpbb\config\db->set()

FILE: [ROOT]/includes/functions_module.php
LINE: 676
CALL: threedi\tpotm\acp\tpotm_module->main()

FILE: [ROOT]/adm/index.php
LINE: 82
CALL: p_master->load_active()
Just to mention, after enabling the extension, the load average kept around 5, and the navigation on the forum was really slow.

Thanks for your help,
Let me take a guess, you're using a version of PHP lower than or equal to 3.3.5? Or an old version of MySQL?
Development Team Member
I don't make bugs - I make features
User avatar
3Di
Former Team Member
Posts: 16032
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: [3.1][3.2][RC] Top Poster Of The Month (reloaded)

Post by 3Di »

Elsensee wrote:
Fri Sep 29, 2017 1:35 pm
Let me take a guess, you're using a version of PHP lower than or equal to 3.3.5? Or an old version of MySQL?
Thanks for chiming in, the OP stated:
takufner wrote:
Wed Sep 27, 2017 3:59 am
Hello 3Di, thanks for your answer.

My forum:
  • messages: 145184
  • topics: 54237
  • users: 13247
My server:
  • 8 GB RAM
  • 4 CPU Cores
  • Ubuntu 16.04
  • Apache 2.4
  • PHP Version 7.0.22-0ubuntu0.16.04.1
  • MySQL(i) 5.7.19-0ubuntu0.16.04.1-log
My env is:
3Di wrote:
Fri Sep 29, 2017 1:22 pm
I am unable to reproduce those errors in my environment, (PHP 5.6.xx or 7.04 and MySql(i) 5.7.11 or more)
The division by zero could be solved I guess by:
3Di wrote:
Fri Sep 29, 2017 1:22 pm
Could you try to change the line 555 from
$percent = min(100, ((int) $tpotm_tot_posts) / (int) $total_month) * 100;
to
$percent = min(100, ((int) $tpotm_tot_posts / (int) $total_month) * 100);
and see if the division by zero is gone? Thx.
This situation is puzzling me a bit. :|
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
Looking for a specific feature or alternative option? We will rock you! 🚀
User avatar
takufner
Registered User
Posts: 215
Joined: Mon Oct 23, 2006 10:39 am
Location: Rio de Janeiro - Brasil
Name: Prof. Caju
Contact:

Re: [3.1][3.2][RC] Top Poster Of The Month (reloaded)

Post by takufner »

Hello Elsensee,

My server configuration:

Code: Select all

Database server:	MySQL(i) 5.7.19-0ubuntu0.16.04.1
PHP Version:		7.0.22-0ubuntu0.16.04.1
Board version:		3.2.1
Kind regards,
User avatar
takufner
Registered User
Posts: 215
Joined: Mon Oct 23, 2006 10:39 am
Location: Rio de Janeiro - Brasil
Name: Prof. Caju
Contact:

Re: [3.1][3.2][RC] Top Poster Of The Month (reloaded)

Post by takufner »

Could you try to change the line 555 from

$percent = min(100, ((int) $tpotm_tot_posts) / (int) $total_month) * 100;

to

$percent = min(100, ((int) $tpotm_tot_posts / (int) $total_month) * 100);

and see if the division by zero is gone? Thx.
Did the code change, and the debug notice still persists...
User avatar
3Di
Former Team Member
Posts: 16032
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: [3.1][3.2][RC] Top Poster Of The Month (reloaded)

Post by 3Di »

takufner wrote:
Fri Sep 29, 2017 2:19 pm
Could you try to change the line 555 from

$percent = min(100, ((int) $tpotm_tot_posts) / (int) $total_month) * 100;

to

$percent = min(100, ((int) $tpotm_tot_posts / (int) $total_month) * 100);

and see if the division by zero is gone? Thx.
Did the code change, and the debug notice still persists...
Is not easy not having a valid reproduction, try pls..
$percent = min(100, ((int) $tpotm_tot_posts / (int) $total_month)) * 100;
instead

Did you perform a "delete DATA" as well before to install the new files?
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
Looking for a specific feature or alternative option? We will rock you! 🚀
User avatar
RMcGirr83
Former Team Member
Posts: 21486
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: [3.1][3.2][RC] Top Poster Of The Month (reloaded)

Post by RMcGirr83 »

It is division by zero because the config entry is set to zero in the migration file

Code: Select all

array('config.add', array('threedi_tpotm_month_total_posts', 0)),
and a number hasn't been set within the ACP for that.
Appreciate the extensions/mods/support then buy me a beerImage
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
User avatar
3Di
Former Team Member
Posts: 16032
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: [3.1][3.2][RC] Top Poster Of The Month (reloaded)

Post by 3Di »

RMcGirr83 wrote:
Fri Sep 29, 2017 2:34 pm
It is division by zero because the config entry is set to zero in the migration file

Code: Select all

array('config.add', array('threedi_tpotm_month_total_posts', 0)),
and a number hasn't been set within the ACP for that.
The number is being set not in ACP but a runtime with a query (function)
https://github.com/3D-I/tpotm/blob/v1.1 ... #L363-L397

The migrations sets a default of 0 just to begin with?
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
Looking for a specific feature or alternative option? We will rock you! 🚀
User avatar
RMcGirr83
Former Team Member
Posts: 21486
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: [3.1][3.2][RC] Top Poster Of The Month (reloaded)

Post by RMcGirr83 »

Be that as it may it is still tossing a zero which is the division by zero error. What if a board doesn't have any posts for a month?

Why not just use the cache entry instead of having a config setting?
Appreciate the extensions/mods/support then buy me a beerImage
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
User avatar
3Di
Former Team Member
Posts: 16032
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: [3.1][3.2][RC] Top Poster Of The Month (reloaded)

Post by 3Di »

RMcGirr83 wrote:
Fri Sep 29, 2017 2:56 pm
Be that as it may it is still tossing a zero which is the division by zero error. What if a board doesn't have any posts for a month?

Why not just use the cache entry instead of having a config setting?
1 - Correct, I am installing a fresh 3.2.1 NOT populated atm.

2 - To avoid to call such a function (query) multiple times instead to simply read a config in the following code there.
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
Looking for a specific feature or alternative option? We will rock you! 🚀
User avatar
RMcGirr83
Former Team Member
Posts: 21486
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: [3.1][3.2][RC] Top Poster Of The Month (reloaded)

Post by RMcGirr83 »

3Di wrote:
Fri Sep 29, 2017 3:02 pm
2 - To avoid to call such a function (query) multiple times instead to simply read a config in the following code there.
Haven't really delved into the code that much but then what is the purpose of the cache entry if you are relying on the config entry.
Appreciate the extensions/mods/support then buy me a beerImage
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
User avatar
3Di
Former Team Member
Posts: 16032
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: [3.1][3.2][RC] Top Poster Of The Month (reloaded)

Post by 3Di »

RMcGirr83 wrote:
Fri Sep 29, 2017 3:18 pm
3Di wrote:
Fri Sep 29, 2017 3:02 pm
2 - To avoid to call such a function (query) multiple times instead to simply read a config in the following code there.
Haven't really delved into the code that much but then what is the purpose of the cache entry if you are relying on the config entry.
Seems like (multiple tests using the SQL explain) that's the preferred method to save queries, at least 2/3. Calling that function so many times later on in the code results in an redundancy/overkill.
All right I will check if the cache still have to exist there, indeed. Having it cached though allows the query/config->set to run (in synchro) only if the cache is disabled or the TTL has passed on?

And yes, I was finally able to reproduce the division by zero error .. thank you Rich, good catch! :)

https://github.com/3D-I/tpotm/commit/81 ... 8f0994bf60
line 42 of ext/threedi/tpotm/migrations/m3_install_configs.php
FIND
array('config.add', array('threedi_tpotm_month_total_posts', 0)),
REPLACE WITH
array('config.add', array('threedi_tpotm_month_total_posts', 1)),
(which is correct being the only one post the one posted on installation by the FOUNDER, btw) ..that's all.
https://user-images.githubusercontent.c ... bef47f.png


About the "error" on config->set INDEX.. I wasn't able to reproduce it.
takufner wrote:
Fri Sep 29, 2017 1:10 pm
Second. When trying to change the extension settings in ACP, I get the following SQL Error.

Duplicate entry 'threedi_tpotm_index' for key 'PRIMARY' [1062]
Configs are cached, try and delete the production folder in your cache.
takufner wrote:
Fri Sep 29, 2017 2:19 pm
Could you try to change the line 555 from
$percent = min(100, ((int) $tpotm_tot_posts) / (int) $total_month) * 100;
to
$percent = min(100, ((int) $tpotm_tot_posts / (int) $total_month) * 100);
and see if the division by zero is gone? Thx.
Did the code change, and the debug notice still persists...
edit: disable/DELETE DATA/re-enable

Please roll back those changes, and apply the fix above mentioned.
Thanks for feedback.
Last edited by 3Di on Fri Sep 29, 2017 8:13 pm, edited 1 time in total.
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
Looking for a specific feature or alternative option? We will rock you! 🚀
User avatar
3Di
Former Team Member
Posts: 16032
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: [3.1][3.2][RC] Top Poster Of The Month (reloaded)

Post by 3Di »

v1.1.0-rc4 (PL1) released. See first posts.
Changes Log v1.1.0-rc4 (PL1)

ª FIX - division by zero error
ª FIX - Duplicate entry 'threedi_tpotm_index' for key 'PRIMARY' [1062]
Updating:
ª disable / delete data & files / upload new files / re-enable
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
Looking for a specific feature or alternative option? We will rock you! 🚀
bug-i
Registered User
Posts: 131
Joined: Fri Feb 17, 2017 12:45 pm

Re: [3.1][3.2][RC] Top Poster Of The Month (reloaded)

Post by bug-i »

awesome work! Thanks!
Seems to be working almost perfect, but I am missing admins in the list. Even with activated option in the acp. Can you check that, is there anything that helps finding the bug?
Activating the option works for moderators, but not yet for admins or maybe founders (if that matters).


Another thing: Clearing cache and clearing session data seems in the acp to reset the tpotm-statistic. Is there a way of initiation recalculation? This currently leads to "At the present time is "not yet available" out of 67 ( 0%)"

Showing the Avatar of the current TPOTM works only after refresh (F5) (Firefox)
Locked

Return to “Extensions in Development”