Extension talk:UserPageViewTracker/Archive
Every view counts as 9 views
editI have the problem that every "single" view of a page counts as 9 views. 80.152.170.173 13:35, 1 April 2019 (UTC)
Receiving error: Table doesn't exist
editThis doesn't seem to be working with the instructions given...
I'm sure I'm making a simple mistake according to the .sql statements I'm supposed to run on my wiki database....
What I really don't understand is the statement:
CREATE VIEW ``user_page_hits` AS .....
...since that table doesn't exist, right?? Anything to steer me to the write course of installation would be great
PS It would be great to reference a screenshot of what the resultant page might be. Thanks --Dmccormick 06:30, 5 November 2007 (UTC)
- Did you create the table User_Page_Views? It's mentioned in the SQL UserPageViews.sql
- I'll work on the screenshot - it may be difficult as the one I've got is our internal corporate wiki which may have confidential data. --Kimon 13:35, 5 November 2007 (UTC)
- I just noticed that the SQL script had an extra quote (`). Try it again --Kimon 13:37, 5 November 2007 (UTC)
- I got the same error. I needed to make adjustments for the prefix. Now, the function
getQueryInfo()
around line 145 looks like this:
- I got the same error. I needed to make adjustments for the prefix. Now, the function
- I just noticed that the SQL script had an extra quote (`). Try it again --Kimon 13:37, 5 November 2007 (UTC)
function getQueryInfo() { global $wgDBprefix; list ($userpagehits) = wfGetDB(DB_SLAVE)->tableNamesN($wgDBprefix.'user_page_hits'); $conds = array();
- And again on about line 165, just before
return array(
- And again on about line 165, just before
$table .= "last from ".$wgDBprefix."user_page_hits) p) results";
- The insertion of
DB_SLAVE
inwfGetDB()
in the third line of my forst code block follows a fix needed for 1.14.0 given by Fungiblename for the Extension:UserSnoop on the Talk Page --skarred 4:35 PM, 7 March 2009 (UTC)
- The insertion of
Windows Install
editWill this work with a Windows install? I ran the scripts in phpMyAdmin and added the file but got an error. Can you help out
Detected bug in an extension! Hook wfUserPageViewTracker failed to return a value; should return true to continue hook processing or false to abort. Backtrace: #0 D:\xampplite\htdocs\mw\includes\Parser.php(386): wfRunHooks('ParserAfterTidy', Array) #1 D:\xampplite\htdocs\mw\includes\Article.php(3017): Parser->parse('<big>'''MediaWi...', Object(Title), Object(ParserOptions), true, true, 1) #2 D:\xampplite\htdocs\mw\includes\Article.php(831): Article->outputWikiText('<big>'''MediaWi...') #3 D:\xampplite\htdocs\mw\includes\Wiki.php(383): Article->view() #4 D:\xampplite\htdocs\mw\includes\Wiki.php(48): MediaWiki->performAction(Object(OutputPage), Object(Article), Object(Title), Object(User), Object(WebRequest)) #5 D:\xampplite\htdocs\mw\index.php(89): MediaWiki->initialize(Object(Title), Object(OutputPage), Object(User), Object(WebRequest)) #6 {main}
I also tried it in our CentOS box which is running MW 1.11 and am posting the backtrace from there... Might there be some step we are missing?
Internal error Detected bug in an extension! Hook wfUserPageViewTracker failed to return a value; should return true to continue hook processing or false to abort. Backtrace: #0 /var/www/html/tskb/includes/Parser.php(386): wfRunHooks('ParserAfterTidy', Array) #1 /var/www/html/tskb/includes/SkinTemplate.php(1196): Parser->parse('You must have c...', Object(Title), Object(ParserOptions), true) #2 /var/www/html/tskb/includes/templates/Userlogin.php(32): QuickTemplate->msgWiki('loginprompt') #3 /var/www/html/tskb/includes/OutputPage.php(457): UserloginTemplate->execute() #4 /var/www/html/tskb/includes/SpecialUserlogin.php(714): OutputPage->addTemplate(Object(UserloginTemplate)) #5 /var/www/html/tskb/includes/SpecialUserlogin.php(103): LoginForm->mainLoginForm('') #6 /var/www/html/tskb/includes/SpecialUserlogin.php(17): LoginForm->execute() #7 /var/www/html/tskb/includes/SpecialPage.php(653): wfSpecialUserlogin(NULL, Object(SpecialPage)) #8 /var/www/html/tskb/includes/SpecialPage.php(459): SpecialPage->execute(NULL) #9 /var/www/html/tskb/includes/Wiki.php(201): SpecialPage::executePath(Object(Title)) #10 /var/www/html/tskb/includes/Wiki.php(45): MediaWiki->initializeSpecialCases(Object(Title), Object(OutputPage), Object(WebRequest)) #11 /var/www/html/tskb/index.php(89): MediaWiki->initialize(Object(Title), Object(OutputPage), Object(User), Object(WebRequest)) #12 {main}
SellFone 14:52, 3 December 2007 (UTC)
- MW 1.11 requires the functions to return a value, 1.10 does not. Check this out. --Kimon 18:18, 3 December 2007 (UTC)
SQL Error on CREATE VIEW statement
editCREATE VIEW statement doesn't exist in MySQL 4, but exists in MySQL 5 and PostgreSQL. Can sqls in extension be fixed to work on MySQL 4.1? Maybe SUBSELECT can help?
Adding category pages also to the stats
editHi, this is working fine for me with MW 1.11. Only one problem-whenever I visit a page that has a category, the stats shows 2 entries-1 for the page and other for the category page. Actually i hvn't visited the category page. how to solve this?
SQL database error on wiki search
editI don't need a special page to get the date (I have a perl SQL cron job that generates the reports) but I'm using the first part listed of this extension to add the hits to a table in my mySQL database. This works fine, but when I use the search on my wiki I get this error (with $wgShowExceptionDetails = true;)
Error in numRows(): Duplicate entry '20080201211215-12-0' for key 1 (localhost) Backtrace: #0 /var/www/vhosts/mydomain.com/httpdocs/wiki/includes/Database.php(2326): Database->numRows(Resource id #92) #1 /var/www/vhosts/mydomain.com/httpdocs/wiki/includes/SearchMySQL.php(192): ResultWrapper->numRows() #2 /var/www/vhosts/mydomain.com/httpdocs/wiki/includes/SpecialSearch.php(192): MySQLSearchResultSet->numRows() #3 /var/www/vhosts/mydomain.com/httpdocs/wiki/includes/SpecialSearch.php(108): SpecialSearch->showResults('fgh') #4 /var/www/vhosts/mydomain.com/httpdocs/wiki/includes/SpecialSearch.php(40): SpecialSearch->goResult('fgh') #5 /var/www/vhosts/mydomain.com/httpdocs/wiki/includes/SpecialPage.php(653): wfSpecialSearch(NULL, Object(SpecialPage)) #6 /var/www/vhosts/mydomain.com/httpdocs/wiki/includes/SpecialPage.php(459): SpecialPage->execute(NULL) #7 /var/www/vhosts/mydomain.com/httpdocs/wiki/includes/Wiki.php(201): SpecialPage::executePath(Object(Title)) #8 /var/www/vhosts/mydomain.com/httpdocs/wiki/includes/Wiki.php(45): MediaWiki->initializeSpecialCases(Object(Title), Object(OutputPage), Object(WebRequest)) #9 /var/www/vhosts/mydomain.com/httpdocs/wiki/index.php(89): MediaWiki->initialize(Object(Title), Object(OutputPage), Object(User), Object(WebRequest)) #10 {main}
It looks to me like it's trying to record a hit to the search page while the search page accesses the database, making it angry. Any suggestions?
- Using $wgShowExceptionDetails, I got the same thing as you. I updated LocalSettings.php to display errors, and I got this (I removed the "undefined variable" lines):
Warning: Missing argument 1 for wfGetDB(), called in /var/www/html/wiki/extensions/UserPageViewTracker.php on line 145 and defined in /var/www/html/wiki/includes/GlobalFunctions.php on line 2691
- Seems wfGetDB() needs a value, so I changed the line to:
list ($userpagehits) = wfGetDB(DB_SLAVE)->tableNamesN('user_page_hits');
- That seems to have fixed it.
Added localisation to the timestamps
editThe times were showing in GMT, so I updated this to display the proper time. I've posted the updated formatRow function below -- it changes the following things:
- adds "global $wgLocalTZoffset", to bring in the offset amount
- puts the date formatting right after the beginning of the function, for ease of use
- adds date/time formatting
- replaces the "last" bit with the newly formatted date/time
function formatRow ( $row ) { global $wgLocalTZoffset; $dateForm = "Y-m-d H:i:s"; $userPage = Title::makeTitle( NS_USER, $row->user_name ); $name = $this->getSkin()->makeLinkObj( $userPage, htmlspecialchars( $userPage->getText() ) ); $pageTitle = Title::makeTitle( $row->page_namespace, $row->page_title ); if($row->page_namespace > 0) { $pageFullName = $pageTitle->getNsText().":".htmlspecialchars($pageTitle->getText() ); } else { $pageFullName = htmlspecialchars( $pageTitle->getText()); } $page = $this->getSkin()->makeLinkObj( $pageTitle, $pageFullName ); $this->rowCount += 1; $res = '<tr>'; $res .= "<td style=\"text-align:center\">$this->rowCount</td>"; $res .= '<td>'.$name.'</td><td>'; if ($row->user_real_name) { $res .= $row->user_real_name.'</td><td>'; } else { $res .= ' </td><td>'; } $date_yr = substr($row->last,0,4); $date_mn = substr($row->last,4,2); $date_dy = substr($row->last,6,2); $date_hr = substr($row->last,8,2); $date_mi = substr($row->last,10,2); $date_sc = substr($row->last,12,2); $tmp = date($dateForm, mktime($date_hr, $date_mi, $date_sc, $date_mn, $date_dy, $date_yr) + ($wgLocalTZoffset * 60)); $res .= "$page</td>"; $res .= "<td style=\"text-align:right\">$row->hits</td>"; $res .= "<td style=\"text-align:center\">$tmp</td>"; $res .= "</tr>\n"; return $res; }
There's likely a better way of doing this, but this worked for me, so I figured I'd share. CSchelin 17:47, 10 November 2010 (UTC)
- I got error after update above formatRow function:
Error from line 143 of /var/lib/mediawiki/extensions/UserPageViewTracker/SpecialUserPageViewTracker.php: Call to undefined method SkinVector::makeLinkObj()
--JHK (talk) 02:30, 8 December 2016 (UTC)
Anyway to sort the userpageviews page?
editI want to sort by most recent timestamp...
Uninstall
editThis extension requires database changes. My concern is if we decide to discontinue this extension are we stuck supporting it due to these changes. Is there a reasonable uninstall path? Thanks --Silversonic (talk) 16:54, 20 November 2013 (UTC)
- If you delete the extension files and remove the relevant lines from LocalSettings.php your wiki will function as if you never installed the extension. There will be one or two database tables that will simply be unused by anything. If you are familiar with working with databases you can drop those tables without hurting anything, but it is not required. Of course, always backup your database before making changes.
- Also take a look at Extension:Wiretap. I wrote it recently, and it is based off of this extension. I plan on upgrading Wiretap to have many more features such as visualizing how users move through your wiki and finding unused portions of the wiki.
Counting page visits from non-logged-in visitors
editThanks for the extension. Is there a way to count the visits of non-logged-in visitors?
Also, is there a way to display a line saying: "This article was viewed XXXX times." at the top or bottom of the articles?
This can be a very handy statistics tool for Mediawiki sites.
Thanks a lot.