I am getting errors when I try to run the Top Pages and Top Referrers reports in the Statistics module. I completely uninstalled the Statistics module and re-enabled to make sure (I had trouble with some other modules because I enabled them at the same time as the Overlay module, which was causing hook_enable not to run, and I wanted to make sure that wasn't the reason for the problem, so that is why I disabled, uninstalled, and reinstalled Statistics). And for reference, I don't currently have any content on the site (I was just testing/verifying the help screens, so this is a new install).
The admin/reports/referrers page is just showing the following error messages and no page content (for reference, the site URL is http://bird/~eclipsework/drupal/ on my local box):
* Warning: Illegal offset type in isset or empty in SelectQuery->addJoin() (line 1190 of /opt/www/eclipsework/drupal/includes/database/select.inc).
* Warning: Illegal offset type in SelectQuery->addJoin() (line 1195 of /opt/www/eclipsework/drupal/includes/database/select.inc).
* PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 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 'WHERE (LOWER(url) NOT LIKE '%bird%') AND (url <> '')' at line 1: SELECT COUNT(DISTINCT url) AS expression FROM WHERE (LOWER(url) NOT LIKE :host) AND (url <> :db_condition_placeholder_0) ; Array ( [:host] => %bird% [:db_condition_placeholder_0] => ) in PagerDefault->execute() (line 86 of /opt/www/eclipsework/drupal/includes/pager.inc).
admin/reports/pages shows the following error messages (and no page content):
* Warning: Illegal offset type in isset or empty in SelectQuery->addJoin() (line 1190 of /opt/www/eclipsework/drupal/includes/database/select.inc).
* Warning: Illegal offset type in SelectQuery->addJoin() (line 1195 of /opt/www/eclipsework/drupal/includes/database/select.inc).
* Warning: Illegal offset type in isset or empty in SelectQuery->addJoin() (line 1190 of /opt/www/eclipsework/drupal/includes/database/select.inc).
* Warning: Illegal offset type in SelectQuery->addJoin() (line 1195 of /opt/www/eclipsework/drupal/includes/database/select.inc).
* PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 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 '' at line 1: SELECT COUNT(DISTINCT path) AS expression FROM ; Array ( ) in PagerDefault->execute() (line 86 of /opt/www/eclipsework/drupal/includes/pager.inc).
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | 659578.patch | 6.71 KB | jhodgdon |
| #17 | 659578_statistics_admin_select.patch | 6.9 KB | mcarbone |
| #11 | 659578_statistics_admin_select.patch | 6.94 KB | mcarbone |
| #6 | 659578_statistics_admin_select.patch | 5.76 KB | mcarbone |
| #3 | 659578_statistics_admin_select.patch | 1.85 KB | mcarbone |
Comments
Comment #1
jhodgdonComment #2
mcarbone commentedI can recreate, and will take a look. Can't ship with this, so this is critical.
Comment #3
mcarbone commentedA couple of arguments were missing.
Comment #4
jhodgdonShouldn't there also be a test to verify at least that the reports return an actual page, and better yet, that after requesting a page, that page shows up in Top Pages? I'm not sure how the Top Referrers report could be tested, as I don't think the framework supports referrers... and maybe the way the internal browser works there is no hit to stats either... but at a minimum the test could verify that the report comes up, so that next time someone makes a change in an API that breaks these pages, it would at least show up as a test failure?
I'll test the patch itself tomorrow...
Comment #5
mcarbone commentedMakes sense. We can always add rows to the accesslog table directly in order for the test to pull something up.
Comment #6
mcarbone commentedAdded a suite of tests for the various report pages.
Comment #7
jhodgdonThe patch applies fine and works for me. The tests look reasonable (at least there's a test to make sure the reports run and basic functionality, which is MUCH better than no tests).
However, there are a couple of problems with doc headers:
a) The new test classes you've added don't have doc headers at all. They need to.
b) At least one doc header for a class member function needs to be word-wrapped to 80 characters (there is one that you didn't create that you could fix in this patch too).
c) Function headers should start with a 3rd-person verb. E.g. "Verifies that..." rather than "Verify that...".
Other than that, I think it looks excellent.
Comment #8
jhodgdonAlso, is it possible for the stats module tests to test that pages are logged correctly? The approach being used here adds something directly to the database, which doesn't test that on a page hit, the module works to log the hit. That seems to be a testing hole. One that was not introduced by this patch, ...
Comment #9
aaron commentedThat normally happens in statistics_exit(). Not sure if we could just call that rather than updating the db manually, since the function calls drupal_bootstrap(), but maybe it's ok.
Comment #10
jhodgdonAh... well that question (whether stats module should be tested to verify stats are taken on page visits) should probably be filed as a separate issue, to be discussed in more detail whether it's feasible or not. Will do so later, but I have to run out now... if someone else files an issue, please comment here and link.
Anyway, this latest patch still needs minor doc header cleanup. Just as a note, each class, function, etc. should have an 80-character line ending in a period and followed by a blank line, explaining what it does.
See http://drupal.org/node/1354
I think that is the only thing wrong with the patch above.
Comment #11
mcarbone commentedFixed the doc headers. Also, testing access logging was fairly easy, since it works correctly when drupalGet() is called, so I added a test for that as well.
Comment #12
jhodgdonHmmm....
I don't see the new test for access logging in your patch... am I just being dense?
The doc headers are much better, but the one-sentence description that starts them is supposed to be just one 80-char line, not wrapped to the next line, according to the doc standards. We're trying to get the older function headers up to standards -- not all there yet -- but definitely anything new going in should follow the standards.
Comment #13
mcarbone commentedIt's in "function testAccessLogging()".
You're saying that they need to be 80 characters max? Interesting -- not sure why it's worth sacrificing length for clarity, but I'll post a new patch up tomorrow.
Comment #14
mcarbone commentedoic, it's a summary, followed by more details if needed.
Comment #15
mcarbone commentedComment #16
jhodgdonOK, I see the test now. Must have been blind there. :)
Comment #17
mcarbone commentedOne more time, with 80 chars max doc headers.
Comment #18
jhodgdonThat version was pretty close... I made some minor tweaks to the doc headers, and will take the liberty of marking it RTBC.
Comment #19
dries commentedCommitted to CVS HEAD. Great to see the patch came with tests. Thanks.