Quick question: as in subject. But that’s just to be quick... I’d prefer a better solution: if you think you can give it, please read on.
We use a snippet called "php" to execute scripts stored into filesystem: we use it in almost every node of our site, so that the content is not in database but on filesystem.
In one of our pages, we have a problem with the "System Events" log feature of MODx: in fact, in this page we use fpdf and fpdi to generate pdf; but those projects make use of returning value of new by reference, which seems to be deprecated in PHP5. So MODx logs this into the System Events log:
’php - Snippet’,’Assigning the return value of new by reference is deprecated [...]’
But, I’ve replaced with "[...]" the whole content of the page, which is huge and which is loaded many times a day, resulting in a quick grow of the database size just for logging it.
Given that we do not want to modify fpdf’s and fpdi’s files, I’m here asking if you can suggest a way to avoid logging of the content, or at least to turn off the System Events log.
-
☆ A M B ☆
- 24,524 Posts
Not really recommended, preferable to fix the PHP code, but in manager/includes/document.parser.class.inc.php, around line 1287, you’ll find the function that inserts the events into the database. You could comment out the whole function definition body, or just the query and the query results check conditional at the end of the function.
If I were going to do something like that, I would be more inclined to add some code to truncate the table if it gets beyond 50 or so entries; at least that way you would still have a way of seeing error conditions.
-
☆ A M B ☆
- 24,524 Posts
Like any SELECT query, it returns an array; you still need to get the first value out of the array before you get the count. I would use the MODx dbAPI call:
$tablename = $modx->getFullTableName('event_log');
$count = $modx->db->getValue($modx->db->select('COUNT(*)', $tablename));
if($count > 50) { $modx->db->query('TRUNCATE TABLE' . $tablename); }
Damn, sure! Thank you very much, nice suggestion to use the db api.