Page MenuHomePhabricator

Bug with the UserPageViewTracker extension.
Closed, ResolvedPublicBUG REPORT

Assigned To
None
Authored By
Andrewmvk
Jan 29 2022, 1:44 AM
Referenced Files
F34941636: image.png
Feb 3 2022, 6:27 PM
F34941566: image.png
Feb 3 2022, 5:57 PM
F34941557: image.png
Feb 3 2022, 5:57 PM
F34934941: image.png
Jan 29 2022, 1:44 AM
F34934944: image.png
Jan 29 2022, 1:44 AM
F34934946: image.png
Jan 29 2022, 1:44 AM

Description

Whats trully happening is the extension table (on the special page) shows "??????????" in "last" column instead of the actual date.
Searching in the table of the extension on the database i noticed that the "last" column shows the same thing.

image.png (300×1 px, 46 KB)

DO NOT CONSIDER the first value in column "last" i modified it directly in the database's table:

image.png (327×664 px, 64 KB)

The date is working as intended in the rest of the wiki.
The extension code where i found the "last" value:

image.png (349×1 px, 60 KB)

I haven't found the solution yet, if someone could help me, i would be grateful.

Event Timeline

Aklapper changed the task status from Open to Stalled.Jan 29 2022, 9:24 AM

@Andrewmvk: Thanks for reporting this. Please always use the bug report form (linked from the top of the task creation page) to create a bug report:

List of steps to reproduce (step by step, including full links if applicable):

What happens?:

What should have happened instead?:

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc.:

Change 758953 had a related patch set uploaded (by Sophivorus; author: Sophivorus):

[mediawiki/extensions/UserPageViewTracker@master] Fix timestamp issue and improve performance

https://gerrit.wikimedia.org/r/758953

Change 758953 merged by Sophivorus:

[mediawiki/extensions/UserPageViewTracker@master] Fix timestamp issue and improve performance

https://gerrit.wikimedia.org/r/758953

@Andrewmvk Hi! I think I was able to spot and fix the error, please download the latest version of the extension (0.6) and let me know how it goes!

Aklapper changed the task status from Stalled to Open.Feb 1 2022, 10:03 PM

@Sophivorus Hi! Sorry for the delay to answer you, i downloaded the latesd version of UserPageViewTracker, but i got a error in my main page:

MediaWiki internal error.

Original exception: [b7703c5f1903f43a36e173c5] /wiki/index.php/P%C3%A1gina_principal Wikimedia\Rdbms\DBUnexpectedError: The unique key array should contain a single unique index
Backtrace:
from C:\xampp\htdocs\wiki\includes\libs\rdbms\database\Database.php(2315)
#0 C:\xampp\htdocs\wiki\includes\libs\rdbms\database\Database.php(2286): Wikimedia\Rdbms\Database->normalizeUpsertKeys(array)
#1 C:\xampp\htdocs\wiki\includes\libs\rdbms\database\Database.php(3540): Wikimedia\Rdbms\Database->normalizeUpsertParams(array, array)
#2 C:\xampp\htdocs\wiki\includes\libs\rdbms\database\DBConnRef.php(68): Wikimedia\Rdbms\Database->upsert(string, array, array, array)
#3 C:\xampp\htdocs\wiki\includes\libs\rdbms\database\DBConnRef.php(521): Wikimedia\Rdbms\DBConnRef->__call(string, array)
#4 C:\xampp\htdocs\wiki\extensions\UserPageViewTracker\includes\specials\SpecialUserPageViewTracker.php(30): Wikimedia\Rdbms\DBConnRef->upsert(string, array, array, array)
#5 C:\xampp\htdocs\wiki\includes\HookContainer\HookContainer.php(338): SpecialUserPageViewTracker::onBeforePageDisplay(OutputPage, SkinTimeless)
#6 C:\xampp\htdocs\wiki\includes\HookContainer\HookContainer.php(137): MediaWiki\HookContainer\HookContainer->callLegacyHook(string, array, array, array)
#7 C:\xampp\htdocs\wiki\includes\HookContainer\HookRunner.php(947): MediaWiki\HookContainer\HookContainer->run(string, array, array)
#8 C:\xampp\htdocs\wiki\includes\OutputPage.php(2639): MediaWiki\HookContainer\HookRunner->onBeforePageDisplay(OutputPage, SkinTimeless)
#9 C:\xampp\htdocs\wiki\includes\MediaWiki.php(944): OutputPage->output(boolean)
#10 C:\xampp\htdocs\wiki\includes\MediaWiki.php(957): MediaWiki::{closure}()
#11 C:\xampp\htdocs\wiki\includes\MediaWiki.php(564): MediaWiki->main()
#12 C:\xampp\htdocs\wiki\index.php(53): MediaWiki->run()
#13 C:\xampp\htdocs\wiki\index.php(46): wfIndexMain()
#14 {main}

Exception caught inside exception handler: [b7703c5f1903f43a36e173c5] /wiki/index.php/P%C3%A1gina_principal Wikimedia\Rdbms\DBUnexpectedError: The unique key array should contain a single unique index
Backtrace:
from C:\xampp\htdocs\wiki\includes\libs\rdbms\database\Database.php(2315)
#0 C:\xampp\htdocs\wiki\includes\libs\rdbms\database\Database.php(2286): Wikimedia\Rdbms\Database->normalizeUpsertKeys(array)
#1 C:\xampp\htdocs\wiki\includes\libs\rdbms\database\Database.php(3540): Wikimedia\Rdbms\Database->normalizeUpsertParams(array, array)
#2 C:\xampp\htdocs\wiki\includes\libs\rdbms\database\DBConnRef.php(68): Wikimedia\Rdbms\Database->upsert(string, array, array, array)
#3 C:\xampp\htdocs\wiki\includes\libs\rdbms\database\DBConnRef.php(521): Wikimedia\Rdbms\DBConnRef->__call(string, array)
#4 C:\xampp\htdocs\wiki\extensions\UserPageViewTracker\includes\specials\SpecialUserPageViewTracker.php(30): Wikimedia\Rdbms\DBConnRef->upsert(string, array, array, array)
#5 C:\xampp\htdocs\wiki\includes\HookContainer\HookContainer.php(338): SpecialUserPageViewTracker::onBeforePageDisplay(OutputPage, SkinTimeless)
#6 C:\xampp\htdocs\wiki\includes\HookContainer\HookContainer.php(137): MediaWiki\HookContainer\HookContainer->callLegacyHook(string, array, array, array)
#7 C:\xampp\htdocs\wiki\includes\HookContainer\HookRunner.php(947): MediaWiki\HookContainer\HookContainer->run(string, array, array)
#8 C:\xampp\htdocs\wiki\includes\OutputPage.php(2639): MediaWiki\HookContainer\HookRunner->onBeforePageDisplay(OutputPage, SkinTimeless)
#9 C:\xampp\htdocs\wiki\includes\exception\MWExceptionRenderer.php(158): OutputPage->output()
#10 C:\xampp\htdocs\wiki\includes\exception\MWExceptionRenderer.php(77): MWExceptionRenderer::reportHTML(Wikimedia\Rdbms\DBUnexpectedError)
#11 C:\xampp\htdocs\wiki\includes\exception\MWExceptionHandler.php(107): MWExceptionRenderer::output(Wikimedia\Rdbms\DBUnexpectedError, integer)
#12 C:\xampp\htdocs\wiki\includes\exception\MWExceptionHandler.php(202): MWExceptionHandler::report(Wikimedia\Rdbms\DBUnexpectedError)
#13 C:\xampp\htdocs\wiki\includes\MediaWiki.php(583): MWExceptionHandler::handleException(Wikimedia\Rdbms\DBUnexpectedError, string)
#14 C:\xampp\htdocs\wiki\index.php(53): MediaWiki->run()
#15 C:\xampp\htdocs\wiki\index.php(46): wfIndexMain()
#16 {main}

It happens when i loggin the user and i go to main page. I'm Brazilian, and my main page is in pt-br, I dont know if this is the problem.

Ok, I solved the error above, this error is caused by the SpecialUserPageViewTracker.php(29) where you miss 2 square brackets around the 29 line.
When I changed it the error is gone, but the timestamp continue borked with the question marks (like in the screenshot).

So, for now, I changed the UserPageViewTracker.sql to generate the user_page_view(1) table with the "last" column in TIMESTAMP, it will update the time everytime something get updated in the same line.

image.png (200×832 px, 36 KB)

I delete the "concat" from the UserPageViewTracker.php(51) too.

image.png (298×872 px, 29 KB)

I need a fixed update to use the extension correctly, this generated timestamp is three hours foward from me, i tried to solve it, but the database doesn't follow the SET time-zone command.

Another update, I solved it, it was not a problem with MySQL, but the code started to work and was overwritten the "last" column on MySQL.
SO, I think I've found the source problem: the table need to have at least a value in the "last" column to start generating a correct value, so, if you have another account, it you bug again.
For this I continue with the temporary solution, changing the SpecialUserPageViewTracker.php(28-30) to not have the $last overwritten.

image.png (138×826 px, 18 KB)

@Andrewmvk Hi! Thanks for all the debugging, but I honestly cannot reproduce your issue or understand what was your final fix. If you could just write one more time to clarify, I'll be happy to incorporate your changes to the extension. Cheers!

Aklapper changed the task status from Open to Stalled.Mar 22 2022, 3:32 PM

@Andrewmvk: Could you please answer the last comment? Thanks in advance!

Ok, sorry for the delay in answer.
Ignore the last update I did, the first problem was fixed (icrement bug), the second (last showing "?????????" rather than the actual date) was a problem with MediaWiki's database generation.
Like I said before, i'm brazilian, my wiki is in Pt-BR, we have accent in the words, so we use UTF-8 unicode-ci, but MySQL was configured to generate databases with UTF-8mb4 and this caused the second error.