fixed unpredictable working directory inside register_shutdown_function
This commit is contained in:
		
							parent
							
								
									a1da59804e
								
							
						
					
					
						commit
						9e2522f86f
					
				@ -1030,11 +1030,14 @@ function _start_coverage() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
function _end_coverage() {
 | 
					function _end_coverage() {
 | 
				
			||||||
	if(function_exists("xdebug_get_code_coverage")) {
 | 
						if(function_exists("xdebug_get_code_coverage")) {
 | 
				
			||||||
		if(!file_exists("data/coverage")) mkdir("data/coverage");
 | 
							// Absolute path is necessary because working directory 
 | 
				
			||||||
 | 
							// inside register_shutdown_function is unpredictable.
 | 
				
			||||||
 | 
							$absolute_path = dirname(dirname(__FILE__)) . "/data/coverage";
 | 
				
			||||||
 | 
							if(!file_exists($absolute_path)) mkdir($absolute_path);
 | 
				
			||||||
		$n = 0;
 | 
							$n = 0;
 | 
				
			||||||
		$t = time();
 | 
							$t = time();
 | 
				
			||||||
		while(file_exists("data/coverage/$t.$n.log")) $n++;
 | 
							while(file_exists("$absolute_path/$t.$n.log")) $n++;
 | 
				
			||||||
		file_put_contents("data/coverage/$t.$n.log", serialize(xdebug_get_code_coverage()));
 | 
							file_put_contents("$absolute_path/$t.$n.log", serialize(xdebug_get_code_coverage()));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
?>
 | 
					?>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user