mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-11-04 14:46:19 +08:00 
			
		
		
		
	Fixes #13501: Fixed yii\rbac\DbManager::getRule() and yii\rbac\DbManager::getRules() to properly handle resource data came from Rule table when using PostgreSQL
				
					
				
			This commit is contained in:
		
				
					committed by
					
						
						Alexander Makarov
					
				
			
			
				
	
			
			
			
						parent
						
							25b78aa615
						
					
				
				
					commit
					97c43c2480
				
			@ -4,9 +4,9 @@ Yii Framework 2 Change Log
 | 
				
			|||||||
2.0.11.2 under development
 | 
					2.0.11.2 under development
 | 
				
			||||||
--------------------------
 | 
					--------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Bug #13501: Fixed `yii\rbac\DbManager::getRule()` and `yii\rbac\DbManager::getRules()` to properly handle resource data came from Rule table when using PostgreSQL (StalkAlex)
 | 
				
			||||||
- Bug #13508: Fixed duplicate attachment of behavior BC break (cebe)
 | 
					- Bug #13508: Fixed duplicate attachment of behavior BC break (cebe)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
2.0.11.1 February 02, 2017
 | 
					2.0.11.1 February 02, 2017
 | 
				
			||||||
------------------------
 | 
					------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -631,7 +631,15 @@ class DbManager extends BaseManager
 | 
				
			|||||||
            ->from($this->ruleTable)
 | 
					            ->from($this->ruleTable)
 | 
				
			||||||
            ->where(['name' => $name])
 | 
					            ->where(['name' => $name])
 | 
				
			||||||
            ->one($this->db);
 | 
					            ->one($this->db);
 | 
				
			||||||
        return $row === false ? null : unserialize($row['data']);
 | 
					        if ($row === false) {
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        $data = $row['data'];
 | 
				
			||||||
 | 
					        if (is_resource($data)) {
 | 
				
			||||||
 | 
					            $data = stream_get_contents($data);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return unserialize($data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@ -647,7 +655,11 @@ class DbManager extends BaseManager
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $rules = [];
 | 
					        $rules = [];
 | 
				
			||||||
        foreach ($query->all($this->db) as $row) {
 | 
					        foreach ($query->all($this->db) as $row) {
 | 
				
			||||||
            $rules[$row['name']] = unserialize($row['data']);
 | 
					            $data = $row['data'];
 | 
				
			||||||
 | 
					            if (is_resource($data)) {
 | 
				
			||||||
 | 
					               $data = stream_get_contents($data);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            $rules[$row['name']] = unserialize($data);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $rules;
 | 
					        return $rules;
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user