handle the case of the SQL log failing to open
This commit is contained in:
		
							parent
							
								
									3bc10bf64f
								
							
						
					
					
						commit
						535bcc2a00
					
				@ -245,7 +245,8 @@ function check_cli() {
 | 
				
			|||||||
function _count_execs($db, $sql, $inputarray) {
 | 
					function _count_execs($db, $sql, $inputarray) {
 | 
				
			||||||
	global $_execs;
 | 
						global $_execs;
 | 
				
			||||||
	if(DEBUG) {
 | 
						if(DEBUG) {
 | 
				
			||||||
		$fp = fopen("sql.log", "a");
 | 
							$fp = @fopen("sql.log", "a");
 | 
				
			||||||
 | 
							if($fp) {
 | 
				
			||||||
			if(is_array($inputarray)) {
 | 
								if(is_array($inputarray)) {
 | 
				
			||||||
				fwrite($fp, preg_replace('/\s+/msi', ' ', $sql)." -- ".join(", ", $inputarray)."\n");
 | 
									fwrite($fp, preg_replace('/\s+/msi', ' ', $sql)." -- ".join(", ", $inputarray)."\n");
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@ -254,6 +255,10 @@ function _count_execs($db, $sql, $inputarray) {
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
			fclose($fp);
 | 
								fclose($fp);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							else {
 | 
				
			||||||
 | 
								log_error("core", "failed to open sql.log for appending");
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if (!is_array($inputarray)) $_execs++;
 | 
						if (!is_array($inputarray)) $_execs++;
 | 
				
			||||||
	# handle 2-dimensional input arrays
 | 
						# handle 2-dimensional input arrays
 | 
				
			||||||
	else if (is_array(reset($inputarray))) $_execs += sizeof($inputarray);
 | 
						else if (is_array(reset($inputarray))) $_execs += sizeof($inputarray);
 | 
				
			||||||
@ -422,6 +427,13 @@ function log_info($section, $message) {
 | 
				
			|||||||
	log_msg($section, LOG_INFO, $message);
 | 
						log_msg($section, LOG_INFO, $message);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * A shorthand way to send a LogEvent
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					function log_error($section, $message) {
 | 
				
			||||||
 | 
						log_msg($section, LOG_ERROR, $message);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
 | 
					/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
 | 
				
			||||||
* Things which should be in the core API                                    *
 | 
					* Things which should be in the core API                                    *
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user