mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-11-04 14:46:19 +08:00 
			
		
		
		
	connection wasn't properly returned in case of being created
This commit is contained in:
		@ -68,14 +68,14 @@ class DbTarget extends Target
 | 
				
			|||||||
	 */
 | 
						 */
 | 
				
			||||||
	public function getDbConnection()
 | 
						public function getDbConnection()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		if ($this->_db !== null) {
 | 
							if ($this->_db === null) {
 | 
				
			||||||
			return $this->_db;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
			$this->_db = \Yii::$application->getComponent($this->connectionID);
 | 
								$this->_db = \Yii::$application->getComponent($this->connectionID);
 | 
				
			||||||
			if (!$this->_db instanceof \yii\db\dao\Connection) {
 | 
								if (!$this->_db instanceof \yii\db\dao\Connection) {
 | 
				
			||||||
				throw new \yii\base\Exception('DbTarget.connectionID must refer to a valid application component ID');
 | 
									throw new \yii\base\Exception('DbTarget.connectionID must refer to a valid application component ID');
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							return $this->_db;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Stores log [[messages]] to DB.
 | 
						 * Stores log [[messages]] to DB.
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user