Supporting each other

Community forums

Welcome, Guest
Username: Password: Remember me
Report any technical problems you discover and discuss solutions.
  • Page:
  • 1

TOPIC:

v3: bug changing error log entry count 8 years 8 months ago #2986

  • jayaich
  • jayaich's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
  • Posts: 92
  • Thank you received: 5
Hello,

This is a bit of a complicated one, and seems to be two bugs tied together. They seem to be quite old (checking the Xerte github code). Since neither seem to have been reported before, I can only assume that not many people (anyone?) are changing the error log values via the management page.

During setup certain fields relating to the error logs are initialized in the local database. This is done correctly, and can be seen by the following SQL statement:
MariaDB> select error_log_path,email_error_list,error_log_message,max_error_size,error_email_message from sitedetails;
+----------------+------------------+-------------------+----------------+---------------------+
| error_log_path | email_error_list | error_log_message | max_error_size | error_email_message |
+----------------+------------------+-------------------+----------------+---------------------+
| error_logs/    |                  | true              | 10             | false               |
+----------------+------------------+-------------------+----------------+---------------------+
1 row in set (0.00 sec)

In this instance, we have stated that we do want error log messages, so 'error_log_message' is true. The default is false. As can also be seen the 'max_error_size' entry (i.e. how many log entries are to be kept) and the 'error_email_message' entry (i.e. are emails to be sent when an error occurs) are set to their default values.

The bug is that if you enter the management page, then select the 'Error handling settings' and then change the 'maximum error size' entry, and finally click 'Save', this will have no effect. If you run the above SQL again, you will see that the 'max_error_size' value is still 10, and that the 'error_email_message' value is now set to whatever number you entered for 'maximum error size':
MariaDB> select error_log_path,email_error_list,error_log_message,max_error_size,error_email_message from sitedetails;
+----------------+------------------+-------------------+----------------+---------------------+
| error_log_path | email_error_list | error_log_message | max_error_size | error_email_message |
+----------------+------------------+-------------------+----------------+---------------------+
| error_logs/    |                  | true              | 10             | 100                 |
+----------------+------------------+-------------------+----------------+---------------------+
1 row in set (0.00 sec)

Thus the bug has bitten both field entries. I suspect - but haven't tried - that if you change the 'email error list' in the management page, then this too won't work because the 'error_email_message' value is not changed in the database to 'true'. (The email address list is updated, but the value of 'error_email_message' in the DB is not.)

For email messages to be sent, the value of 'error_email_message' is compared against the string "true" (not the boolean; file error_library.php line 57). So when it gets overwritten by the number you entered, the test fails and no email msgs are sent.

The bug stems from the fact that the 'max_error_size' field is not handled at all in some parts of the code, and so any entered value overwrites the wrong field. In addition is that the email address check is not quite right.

The fix (for us) is to change the code to handle the 'max_error_size' entry so that the correct field is updated. I have also removed the need for the 'error_email_message' field (although it is left in the DB), and email messages are now sent if the address field is not null. The 'error_email_message' field is still set up by the 'setup' program, and exists in the DB, it is just never updated or shown. Most of these patches are minor changes, but there are a few of them:

Note here we use '!= false' rather than '!==' since this will then allow for the null string:
--- error_library.php.orig      2015-07-29 23:17:24.000000000 +0100
+++ error_library.php   2015-08-05 13:51:04.748919070 +0100
@@ -54,7 +54,7 @@
      * If error email message turned on, send an error email message 
      */
 
-    if(isset($xerte_toolkits_site->error_email_message) && $xerte_toolkits_site->error_email_message=="true"){
+    if(isset($xerte_toolkits_site->email_error_list) && trim($xerte_toolkits_site->email_error_list) != false){
 
         email_message($user_name, $type, $level, $subject, $content);

--- management.js.orig  2015-07-29 23:17:24.000000000 +0100
+++ management.js       2015-08-05 13:53:22.979545594 +0100
@@ -426,7 +426,7 @@
                                         '&play_edit_preview_query=' + document.getElementById("play_edit_preview_query").value + 
                                         '&email_error_list=' + document.getElementById("error_email_list").value + 
                                         '&error_log_message=' + document.getElementById("error_log_message").value + 
-                                        '&error_email_message=' + document.getElementById("error_email_message").value + 
+                                        '&max_error_size=' + document.getElementById("max_error_size").value + 
                                         '&ldap_host=' + document.getElementById("ldap_host").value     + 
                                         '&ldap_port=' + document.getElementById("ldap_port").value + 
                                         '&bind_pwd=' + document.getElementById("bind_pwd").value + 
@@ -973,4 +973,4 @@
         }
     }
 
-}
\ No newline at end of file
+}

--- site.php.orig       2015-07-29 23:17:24.000000000 +0100
+++ site.php    2015-08-05 13:55:42.883155092 +0100
@@ -147,7 +147,7 @@
 
     echo "<p>" . MANAGEMENT_SITE_ERROR_EMAIL . "<form><textarea id=\"error_email_list\">" . $row['email_error_list'] . "</textarea></form></p>";
 
-    echo "<p>" . MANAGEMENT_SITE_ERROR_MAX . "<form><textarea id=\"error_email_message\">" . $row['max_error_size'] . "</textarea></form></p>";
+    echo "<p>" . MANAGEMENT_SITE_ERROR_MAX . "<form><textarea id=\"max_error_size\">" . $row['max_error_size'] . "</textarea></form></p>";
 
     echo "</div>";


--- site_details_management.php.orig    2015-07-29 23:17:24.000000000 +0100
+++ site_details_management.php 2015-08-05 13:57:02.224928356 +0100
@@ -34,14 +34,14 @@
     $query = "update " . $xerte_toolkits_site->database_table_prefix . "sitedetails set site_url = ?, site_title = ?, site_name=?, site_logo=?, organisational_logo=?, welcome_message=?,
         site_text=? ,news_text=? ,pod_one=? , pod_two= ? ,copyright=? ,demonstration_page=? ,form_string= ? ,peer_form_string=?,feedback_list=?,
         rss_title=?, module_path=?, website_code_path=?, users_file_area_short=?, php_library_path=?, root_file_path=?, play_edit_preview_query=?, email_error_list=?, 
-        error_log_message=?, error_email_message=?, ldap_host=?, ldap_port=?, bind_pwd=?, basedn=?, bind_dn=?, flash_save_path=?, flash_upload_path=?, flash_preview_check_path=?, flash_flv_skin=? , site_email_account=?,
+        error_log_message=?, max_error_size=?, ldap_host=?, ldap_port=?, bind_pwd=?, basedn=?, bind_dn=?, flash_save_path=?, flash_upload_path=?, flash_preview_check_path=?, flash_flv_skin=? , site_email_account=?,
         headers=?, email_to_add_to_username=?, proxy1=?, port1=?, site_session_name=?, synd_publisher=?, synd_rights=?, synd_license=?,import_path=? ,
         apache=?, mimetypes=?, LDAP_preference=? ,LDAP_filter=? , integration_config_path=?, admin_username=? ,admin_password=? ";
 
     $data = array($_POST['site_url'], $_POST['site_title'], $_POST['site_name'], $_POST['site_logo'], $_POST['organisational_logo'], $_POST['welcome_message'], $site_texts, base64_encode(stripcslashes($_POST['news_text'])), base64_encode(stripcslashes($_POST['pod_one'])), base64_encode(stripcslashes($_POST['pod_two'])), $copyright, $_POST['demonstration_page'], base64_encode(stripcslashes($_POST['form_string'])),
         base64_encode(stripcslashes($_POST['peer_form_string'])), $_POST['feedback_list'], $_POST['rss_title'], $_POST['module_path'], $_POST['website_code_path'], $_POST['users_file_area_short'],
         $_POST['php_library_path'], str_replace("\\", "/", $_POST['root_file_path']), base64_encode(stripcslashes($_POST['play_edit_preview_query'])), $_POST['email_error_list'], $_POST['error_log_message'],
-        $_POST['error_email_message'], $_POST['ldap_host'], $_POST['ldap_port'], $_POST['bind_pwd'], $_POST['base_dn'], $_POST['bind_dn'], $_POST['flash_save_path'], $_POST['flash_upload_path'],
+        $_POST['max_error_size'], $_POST['ldap_host'], $_POST['ldap_port'], $_POST['bind_pwd'], $_POST['base_dn'], $_POST['bind_dn'], $_POST['flash_save_path'], $_POST['flash_upload_path'],
         $_POST['flash_preview_check_path'], $_POST['flash_flv_skin'], $_POST['site_email_account'], $_POST['headers'], $_POST['email_to_add_to_username'], $_POST['proxy1'], $_POST['port1'],
         $_POST['site_session_name'], $_POST['synd_publisher'], $_POST['synd_rights'], $_POST['synd_license'], str_replace("\\", "/", $_POST['import_path']), $_POST['apache'],
         $_POST['mimetypes'], $_POST['LDAP_preference'], $_POST['LDAP_filter'], $_POST['integration_config_path'], $_POST['admin_username'], $_POST['admin_password']);


John.

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Moderators: ronmjultenJohnSmith
Time to create page: 0.057 seconds
Copyright © 2024 The Xerte Project.
Xerte logo Apereo logo OSI Logo

Search