Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special:PageStatistics Wikimedia\Rdbms\DBQueryError #120

Open
djflux opened this issue May 29, 2022 · 1 comment
Open

Special:PageStatistics Wikimedia\Rdbms\DBQueryError #120

djflux opened this issue May 29, 2022 · 1 comment

Comments

@djflux
Copy link

djflux commented May 29, 2022

System Details

  • WatchAnalytics 3.2.0 (adf3421) 16:52, 26 April 2022
  • MW 1.35.6 (bbd9421)
  • SMW 4.0.1
  • Rocky Linux 8.6
  • Apache 2.4.37-47.module+el8.6.0+823+f143cee1.1
  • PHP 7.4.19 (php-fpm)
  • MariaDB 10.3.32-MariaDB-log

Clean MW/SMW Demo Wiki installed via meza from:

https://github.com/djflux/meza/tree/336c3c985631e229cd9d51ccdde54535c953c0eb

Received the follow error when trying to look at Special:PageStatistics for Main_Page:

Error 1054: Unknown column 'rev.rev_user' in 'field list' (localhost)
Function: SpecialPageStatistics::renderPageStats
Query: SELECT rev.rev_user,rev.rev_user_text,COUNT( * ) AS num_revisions FROM `revision` `rev` LEFT JOIN `page` `p` ON ((p.page_id = rev.rev_page)) WHERE p.page_title = 'Main_Page' AND p.page_namespace = 0 GROUP BY rev.rev_user ORDER BY num_revisions DESC 

Backtrace:

#0 /opt/htdocs/mediawiki/includes/libs/rdbms/database/Database.php(1684): Wikimedia\Rdbms\Database->getQueryException(string, integer, string, string)
#1 /opt/htdocs/mediawiki/includes/libs/rdbms/database/Database.php(1659): Wikimedia\Rdbms\Database->getQueryExceptionAndLog(string, integer, string, string)
#2 /opt/htdocs/mediawiki/includes/libs/rdbms/database/Database.php(1228): Wikimedia\Rdbms\Database->reportQueryError(string, integer, string, string, boolean)
#3 /opt/htdocs/mediawiki/includes/libs/rdbms/database/Database.php(1908): Wikimedia\Rdbms\Database->query(string, string, integer)
#4 /opt/htdocs/mediawiki/includes/libs/rdbms/database/DBConnRef.php(68): Wikimedia\Rdbms\Database->select(array, array, array, string, array, array)
#5 /opt/htdocs/mediawiki/includes/libs/rdbms/database/DBConnRef.php(313): Wikimedia\Rdbms\DBConnRef->__call(string, array)
#6 /opt/htdocs/mediawiki/extensions/WatchAnalytics/specials/SpecialPageStatistics.php(145): Wikimedia\Rdbms\DBConnRef->select(array, array, array, string, array, array)
#7 /opt/htdocs/mediawiki/extensions/WatchAnalytics/specials/SpecialPageStatistics.php(49): SpecialPageStatistics->renderPageStats()
#8 /opt/htdocs/mediawiki/includes/specialpage/SpecialPage.php(600): SpecialPageStatistics->execute(NULL)
#9 /opt/htdocs/mediawiki/includes/specialpage/SpecialPageFactory.php(635): SpecialPage->run(NULL)
#10 /opt/htdocs/mediawiki/includes/MediaWiki.php(307): MediaWiki\SpecialPage\SpecialPageFactory->executePath(Title, RequestContext)
#11 /opt/htdocs/mediawiki/includes/MediaWiki.php(945): MediaWiki->performRequest()
#12 /opt/htdocs/mediawiki/includes/MediaWiki.php(548): MediaWiki->main()
#13 /opt/htdocs/mediawiki/index.php(53): MediaWiki->run()
#14 /opt/htdocs/mediawiki/index.php(46): wfIndexMain()
#15 {main}

I added the query parameter &requestDebug=1 to get the error details and backtrace.

There appears to no longer be a rev_user column in the revision table. Maybe the revision table schema changed in newer MW/SMW?

MariaDB [wiki_demo]> describe revision;
+----------------+---------------------+------+-----+----------------+----------------+
| Field          | Type                | Null | Key | Default        | Extra          |
+----------------+---------------------+------+-----+----------------+----------------+
| rev_id         | int(10) unsigned    | NO   | PRI | NULL           | auto_increment |
| rev_page       | int(10) unsigned    | NO   | MUL | NULL           |                |
| rev_comment_id | bigint(20) unsigned | NO   |     | 0              |                |
| rev_actor      | bigint(20) unsigned | NO   | MUL | 0              |                |
| rev_timestamp  | binary(14)          | NO   | MUL |                |                |
| rev_minor_edit | tinyint(3) unsigned | NO   |     | 0              |                |
| rev_deleted    | tinyint(3) unsigned | NO   |     | 0              |                |
| rev_len        | int(10) unsigned    | YES  |     | NULL           |                |
| rev_parent_id  | int(10) unsigned    | YES  |     | NULL           |                |
| rev_sha1       | varbinary(32)       | NO   |     |                |                |
+----------------+---------------------+------+-----+----------------+----------------+
10 rows in set (0.001 sec)

I can attempt a fix if someone gives me an idea of what the query is supposed to be doing. 😄

@djflux
Copy link
Author

djflux commented Jul 8, 2022

I have a fix for this and will be creating a pull request soon. For those who can't wait for the pull request, here is a patch against WatchAnalytics master branch (as of the datestamp of this post) for Special:PageStatistics:

WatchAnalytics-SpecialPageStatistics-MW1.35.patch

diff --git a/specials/SpecialPageStatistics.php b/specials/SpecialPageStatistics.php
index a7a6186..c1838e8 100644
--- a/specials/SpecialPageStatistics.php
+++ b/specials/SpecialPageStatistics.php
@@ -108,14 +108,19 @@ class SpecialPageStatistics extends SpecialPage {
                // Load the styles for the D3.js force directed graph
                // $wgOut->addModuleStyles( 'ext.watchanalytics.forcegraph.styles' );
 
+
+               // Per https://www.mediawiki.org/wiki/Manual:Revision_table#rev_actor the
+               // table schema and which tables contain this data may change after MW1.35
+               //
                // SELECT
-               // rev.rev_user,
-               // rev.rev_user_text,
+               // rev.revactor_actor,
+               // act.actor_name,
                // COUNT( * ) AS num_revisions
-               // FROM revision AS rev
-               // LEFT JOIN page AS p ON p.page_id = rev.rev_page
-               // WHERE p.page_title = "US_EVA_29_(US_EVA_IDA1_Cables)" AND p.page_namespace = 0
-               // GROUP BY rev.rev_user
+               // FROM revision_actor_temp AS rev
+               // LEFT JOIN page AS p ON p.page_id = rev.revactor_page
+               // LEFT JOIN actor AS act on act.actor_id = rev.revactor_actor
+               // WHERE p.page_title = "Main_Page" AND p.page_namespace = 0
+               // GROUP BY rev.revactor_actor
                // ORDER BY num_revisions DESC
 
                #
@@ -123,12 +128,13 @@ class SpecialPageStatistics extends SpecialPage {
                #
                $res = $dbr->select(
                        [
-                               'rev' => 'revision',
+                               'rev' => 'revision_actor_temp',
                                'p' => 'page',
+                               'act' => 'actor',
                        ],
                        [
-                               'rev.rev_user',
-                               'rev.rev_user_text',
+                               'rev.revactor_actor',
+                               'act.actor_name',
                                'COUNT( * ) AS num_revisions',
                        ],
                        [
@@ -137,12 +143,15 @@ class SpecialPageStatistics extends SpecialPage {
                        ],
                        __METHOD__,
                        [
-                               'GROUP BY' => 'rev.rev_user',
+                               'GROUP BY' => 'rev.revactor_actor',
                                'ORDER BY' => 'num_revisions DESC',
                        ],
                        [
                                'p' => [
-                                       'LEFT JOIN', 'p.page_id = rev.rev_page'
+                                       'LEFT JOIN', 'p.page_id = rev.revactor_page'
+                               ],
+                               'act' => [
+                                       'LEFT JOIN', 'act.actor_id = rev.revactor_actor'
                                ],
                        ]
                );
@@ -160,7 +169,7 @@ class SpecialPageStatistics extends SpecialPage {
                                Xml::openElement( 'li' )
                                . wfMessage(
                                        'watchanalytics-pagestats-editors-list-item',
-                                       Linker::userLink( $row->rev_user, $row->rev_user_text ),
+                                       Linker::userLink( $row->revactor_actor, $row->actor_name ),
                                        $row->num_revisions
                                )->text()
                                . Xml::closeElement( 'li' );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant