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.
Problem/Motivation
When a non existing field key in Conditions is set and we try to access the sensor a fatal error occurs.
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not found: 1054 Unknown column '%' in 'where clause'
Steps to reproduce:
Go to admin/config/system/monitoring/sensors/add.
Set a label and select Database Aggregator.
Set table as watchdog, any string in Conditions and 'wid' in Verbose fields.
Save.
Go to the link of the created sensor.
Proposed resolution
We should verified that the field key exist in the table.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#6 | 2557977-6.patch | 1.92 KB | giancarlosotelo |
#6 | 2557977-TESTONLY.patch | 1.01 KB | giancarlosotelo |
#2 | 2557977-2.patch | 936 bytes | giancarlosotelo |
Comments
Comment #2
giancarlosotelo CreditAttribution: giancarlosotelo at MD Systems GmbH commentedAdding a try/catch would solve this problem.
Comment #4
miro_dietikerThe resultVerbose function should not throw an exception.
This situation needs to be caught internally inside the verbose processing. Also we can display a proper error message in such a case - not just verbose message markup.
Comment #5
BerdirI'm actually OK with fixing it like this. We do it exactly the same for the actual sensor check too.
Comment #6
giancarlosotelo CreditAttribution: giancarlosotelo at MD Systems GmbH commentedWell I added test for this error creating a Database Sensor with invalids conditions and asserting that the sensor has no problems otherwise should fail.
Comment #7
LKS90 CreditAttribution: LKS90 commentedWorks correctly, I'm just not sure about the test. It'd be nicer if it explicitly failed instead of just producing one exception. (You could do that with another try/catch() block where you call the runSensor() method)
Comment #8
miro_dietikerThe test is fine. It just needs to fail then.
Committed.
Comment #10
giancarlosotelo CreditAttribution: giancarlosotelo at MD Systems GmbH commentedCan this issue be related to #2528528: Test DatabaseAggregator sensor with invalid fields ?
We are testing DatabaseAggregator with wrong values. or it is more related to UI Test?
Comment #14
juanse254 CreditAttribution: juanse254 at MD Systems GmbH commentedComment #18
giancarlosotelo CreditAttribution: giancarlosotelo at MD Systems GmbH commented