File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed 
app/code/core/Mage/Core/Model/Resource/Db Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -324,18 +324,30 @@ protected function _getConnection($connectionName)
324324        return  $ this  ->_connections [$ connectionName ];
325325    }
326326
327+     /** 
328+      * @param string $connectionName 
329+      * @return bool 
330+      */ 
331+     public  function  hasConnection ($ connectionName )
332+     {
333+         return  isset ($ this  ->_connections [$ connectionName ]);
334+     }
335+ 
327336    /** 
328337     * Retrieve connection for read data 
329338     * 
330339     * @return Magento_Db_Adapter_Pdo_Mysql 
331340     */ 
332341    protected  function  _getReadAdapter ()
333342    {
334-         $ writeAdapter  = $ this  ->_getWriteAdapter ();
335-         if  ($ writeAdapter  && $ writeAdapter ->getTransactionLevel () > 0 ) {
336-             // if transaction is started we should use write connection for reading 
337-             return  $ writeAdapter ;
343+         if  ($ this  ->hasConnection ('write ' )) {
344+             $ writeAdapter  = $ this  ->_getWriteAdapter ();
345+             if  ($ writeAdapter  && $ writeAdapter ->getTransactionLevel () > 0 ) {
346+                 // if transaction is started we should use write connection for reading 
347+                 return  $ writeAdapter ;
348+             }
338349        }
350+ 
339351        return  $ this  ->_getConnection ('read ' );
340352    }
341353
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments