Activate test mode for database
This commit is contained in:
		
					parent
					
						
							
								8ca0186409
							
						
					
				
			
			
				commit
				
					
						d71c3e0812
					
				
			
		
					 3 changed files with 14 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -21,8 +21,10 @@
 | 
			
		|||
 | 
			
		||||
namespace Friendica\Database;
 | 
			
		||||
 | 
			
		||||
use Exception;
 | 
			
		||||
use Friendica\Core\Config\Cache;
 | 
			
		||||
use Friendica\Core\System;
 | 
			
		||||
use Friendica\DI;
 | 
			
		||||
use Friendica\Network\HTTPException\InternalServerErrorException;
 | 
			
		||||
use Friendica\Util\DateTimeFormat;
 | 
			
		||||
use Friendica\Util\Profiler;
 | 
			
		||||
| 
						 | 
				
			
			@ -63,6 +65,7 @@ class Database
 | 
			
		|||
	private $affected_rows  = 0;
 | 
			
		||||
	protected $in_transaction = false;
 | 
			
		||||
	protected $in_retrial     = false;
 | 
			
		||||
	protected $testmode       = false;
 | 
			
		||||
	private $relation       = [];
 | 
			
		||||
 | 
			
		||||
	public function __construct(Cache $configCache, Profiler $profiler, LoggerInterface $logger, array $server = [])
 | 
			
		||||
| 
						 | 
				
			
			@ -181,6 +184,10 @@ class Database
 | 
			
		|||
		return $this->connected;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public function setTestmode(bool $test)
 | 
			
		||||
	{
 | 
			
		||||
		$this->testmode = $test;
 | 
			
		||||
	}
 | 
			
		||||
	/**
 | 
			
		||||
	 * Sets the logger for DBA
 | 
			
		||||
	 *
 | 
			
		||||
| 
						 | 
				
			
			@ -630,6 +637,10 @@ class Database
 | 
			
		|||
			$error   = $this->error;
 | 
			
		||||
			$errorno = $this->errorno;
 | 
			
		||||
 | 
			
		||||
			if ($this->testmode) {
 | 
			
		||||
				throw new Exception(DI::l10n()->t('Database error %d "%s" at "%s"', $errorno, $error, $this->replaceParameters($sql, $args)));
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			$this->logger->error('DB Error', [
 | 
			
		||||
				'code'      => $this->errorno,
 | 
			
		||||
				'error'     => $this->error,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue