Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Checking DB size may fail, for example if the DB has Views or Functions the user Drupal uses is not allowed to access (such as when the definer in the View is another or non-existing user).
In this case, the query will fail, yet the dashboard will report that the database size is 0 bytes instead of reporting that the check failed.
I spent a few days wondering why the DB size was not reported before realizing there was an error in the DB.
Comment | File | Size | Author |
---|---|---|---|
#6 | db_size_check_catch_failure-2394635-6.patch | 1.7 KB | mdupont |
Comments
Comment #1
FluxSauce CreditAttribution: FluxSauce commentedInteresting, hadn't run into that one, but I can see how this would be a problem.
I'll try to replicate this locally and check for a database error condition and return info if there's a security problem.
Thanks for reporting this!
Comment #2
mdupontTo help you replicate the issue, you can try creating a MySQL View this way:
Comment #3
FluxSauce CreditAttribution: FluxSauce commentedHey, sorry for the delay in response. I can't replicate this as described. As root, I created the view, then ensured that the Drupal MySQL user couldn't access it.
So far, so good. However, I ran the specific check you specified:
drush ad --detail --skip=DatabaseCollation,DatabaseEngine,DatabaseRowCount --verbose --debug
Here's the result:
No error. This is the raw SQL:
I believe you're having a problem, but it's not with a view. Are you certain it's with the size check, and are you certain it's within Site Audit? What's the result of that specific check for you?
Comment #4
mdupontIndeed, with the view I gave as an example, I still can run the raw SQL query for DB size.
Here is another View that triggers the bug in my DB (note this is a site hosted at Pantheon):
The error that occurs is this one: http://stackoverflow.com/questions/6527599/mysql-forgets-who-is-logged-i...
Now here's the tricky thing. To reproduce the bug in my context:
Color me puzzled.
Comment #5
mdupontI made some further research and to sum up I don't think it's possible to calculate the DB size with a buggy View.
The right thing to do is to enclose the query in calculateScore() inside a try...catch block, so we can catch the PDOException and warn the user there's something wrong.
It appears that the cause is that the value for the *_length columns in information_schema.TABLES are calculated, and the bug occurs when trying to calculate a *_length for the buggy view. Adding WHERE clauses to the query doesn't help. The only fix is for the site owner to go and fix the DEFINER in the View.
Comment #6
mdupontPatch attached to catch an error executing the query and aborting cleanly if it's the case.
Comment #7
FluxSauce CreditAttribution: FluxSauce commentedGreat, replicated the bug locally with
nodeView
!Thanks for the patch, much appreciated! The patch supplied included a syntax error (always test!); I fixed it and clarified the error message (empty isn't always accurate now).
Committed. I'm going to do some cleanup and roll 1.13 this afternoon.
Comment #9
FluxSauce CreditAttribution: FluxSauce commented