Fix runtime errors while running without a connected database (#11473)

This commit is contained in:
Wildkins
2021-03-19 22:08:00 +01:00
committed by GitHub
parent 5e40f9145c
commit a07700f8a6
16 changed files with 47 additions and 96 deletions
+3 -9
View File
@@ -6,9 +6,7 @@
if (!ckey || !address || !computer_id || !ban_id)
return
establish_db_connection(dbcon)
if (!dbcon.IsConnected())
if (!establish_db_connection(dbcon))
error("Ban database connection failure while attempting to mirror. Key passed for mirror handling: [ckey].")
log_misc("Ban database connection failure while attempting to mirror. Key passed for mirror handling: [ckey].")
return
@@ -59,9 +57,7 @@
if (!ckey || !address || !computer_id)
return null
establish_db_connection(dbcon)
if (!dbcon.IsConnected())
if (!establish_db_connection(dbcon))
error("Ban database connection failure while attempting to check mirrors. Key passed for mirror checking: [ckey].")
log_misc("Ban database connection failure while attempting to check mirrors. Key passed for mirror checking: [ckey].")
return null
@@ -111,9 +107,7 @@
if (!ban_id)
return null
establish_db_connection(dbcon)
if (!dbcon.IsConnected())
if (!establish_db_connection(dbcon))
return null
var/DBQuery/query = dbcon.NewQuery("SELECT id, ckey, ip, computerid, date(datetime) as datetime, source, extra_info, deleted_at FROM ss13_ban_mirrors WHERE ban_id = :ban_id:")
+4 -8
View File
@@ -12,8 +12,7 @@
if (!holder)
return
establish_db_connection(dbcon)
if(!dbcon.IsConnected())
if(!establish_db_connection(dbcon))
return
var/serverip = "[world.internet_address]:[world.port]"
@@ -139,8 +138,7 @@
if(job)
sql += " AND job = '[job]'"
establish_db_connection(dbcon)
if(!dbcon.IsConnected())
if(!establish_db_connection(dbcon))
return
var/ban_id
@@ -234,8 +232,7 @@
var/sql = "SELECT ckey, bantype, job FROM ss13_ban WHERE id = [id]"
establish_db_connection(dbcon)
if(!dbcon.IsConnected())
if(!establish_db_connection(dbcon))
return
var/reason = input("Please specify an unban reason.", "Unban Reason", "Unbanned as per appeal.")
@@ -306,8 +303,7 @@
if(!check_rights(R_BAN)) return
establish_db_connection(dbcon)
if(!dbcon.IsConnected())
if(!establish_db_connection(dbcon))
to_chat(usr, "<span class='warning'>Failed to establish database connection</span>")
return
+1 -3
View File
@@ -113,9 +113,7 @@ var/list/forum_groupids_to_ranks = list()
else
//The current admin system uses SQL
establish_db_connection(dbcon)
if(!dbcon.IsConnected())
if(!establish_db_connection(dbcon))
error("AdminRanks: Failed to connect to database in load_admins(). Reverting to legacy system.")
log_misc("AdminRanks: Failed to connect to database in load_admins(). Reverting to legacy system.")
config.admin_legacy_system = 1
+4 -9
View File
@@ -12,8 +12,7 @@
else
query_details["a_ckey"] = user.ckey
establish_db_connection(dbcon)
if (!dbcon.IsConnected())
if (!establish_db_connection(dbcon))
alert("SQL connection failed while trying to add a note!")
return
@@ -36,8 +35,7 @@
if (!note_id || !note_edit)
return
establish_db_connection(dbcon)
if (!dbcon.IsConnected())
if (!establish_db_connection(dbcon))
error("SQL connection failed while attempting to delete a note!")
return
@@ -93,8 +91,7 @@
player_ckey = ckey(player_ckey)
admin_ckey = ckey(admin_ckey)
establish_db_connection(dbcon)
if (!dbcon.IsConnected())
if (!establish_db_connection(dbcon))
error("SQL connection failed while attempting to view a player's notes!")
return
@@ -185,9 +182,7 @@
if (!ckey)
return "No ckey given!"
establish_db_connection(dbcon)
if (!dbcon.IsConnected())
if (!establish_db_connection(dbcon))
return "Unable to establish database connection! Aborting!"
var/DBQuery/info_query = dbcon.NewQuery("SELECT ip, computerid FROM ss13_player WHERE ckey = :ckey:")
+1 -2
View File
@@ -585,8 +585,7 @@ Traitors and the like can also be revived with the previous role mostly intact.
return
switch(reporttype)
if("Template")
establish_db_connection(dbcon)
if (!dbcon.IsConnected())
if (!establish_db_connection(dbcon))
to_chat(src, "<span class='notice'>Unable to connect to the database.</span>")
return
var/DBQuery/query = dbcon.NewQuery("SELECT title, message FROM ss13_ccia_general_notice_list WHERE deleted_at IS NULL")
+6 -12
View File
@@ -9,8 +9,7 @@
if (!warned_ckey || !istext(warned_ckey))
return
establish_db_connection(dbcon)
if (!dbcon.IsConnected())
if (!establish_db_connection(dbcon))
to_chat(usr, "<span class='warning'>Error: warn(): Database Connection failed, reverting to legacy systems.</span>")
usr.client.warn_legacy(warned_ckey)
return
@@ -110,8 +109,7 @@
var/dcolor = "#ffaaaa" //dark colour, severity = 1
var/ecolor = "#e3e3e3" //gray colour, expired = 1
establish_db_connection(dbcon)
if (!dbcon.IsConnected())
if (!establish_db_connection(dbcon))
alert("Connection to the SQL database lost. Aborting. Please alert an Administrator or a member of staff.")
return
@@ -213,8 +211,7 @@
if (!warning_id)
return
establish_db_connection(dbcon)
if (!dbcon.IsConnected())
if (!establish_db_connection(dbcon))
alert("Connection to SQL database failed while attempting to update your warning's status!")
return
@@ -249,8 +246,7 @@
var/count = 0
var/count_expire = 0
establish_db_connection(dbcon)
if (!dbcon.IsConnected())
if (!establish_db_connection(dbcon))
return
var/list/client_details = list("ckey" = ckey, "computer_id" = computer_id, "address" = address)
@@ -280,10 +276,9 @@
* A proc used to gather if someone has Unacknowledged Warnings
*/
/client/proc/fetch_unacked_warning_count()
establish_db_connection(dbcon)
if (!dbcon)
return
if (!dbcon.IsConnected())
if (!establish_db_connection(dbcon))
return
var/count = 0
@@ -468,8 +463,7 @@
if(!warning_id || !warning_edit)
return
establish_db_connection(dbcon)
if(!dbcon.IsConnected())
if(!establish_db_connection(dbcon))
alert("Connection to the SQL database lost. Aborting. Please alert the database admin!")
return