mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-11-04 14:46:19 +08:00 
			
		
		
		
	Fix #17881: yii\db\Query::queryScalar() wasn’t reverting the select, orderBy, limit, and offset params if an exception occurred
				
					
				
			This commit is contained in:
		@ -11,6 +11,7 @@ Yii Framework 2 Change Log
 | 
				
			|||||||
- Bug #17829: `yii\helpers\ArrayHelper::filter` now correctly filters data when passing a filter with more than 2 levels (rhertogh)
 | 
					- Bug #17829: `yii\helpers\ArrayHelper::filter` now correctly filters data when passing a filter with more than 2 levels (rhertogh)
 | 
				
			||||||
- Enh #7622: Allow `yii\data\ArrayDataProvider` to control the sort flags for `sortModels` through `yii\data\Sort::sortFlags` property (askobara)
 | 
					- Enh #7622: Allow `yii\data\ArrayDataProvider` to control the sort flags for `sortModels` through `yii\data\Sort::sortFlags` property (askobara)
 | 
				
			||||||
- Bug #17863: `\yii\helpers\BaseInflector::slug()` doesn't work with an empty string as a replacement argument (haruatari)
 | 
					- Bug #17863: `\yii\helpers\BaseInflector::slug()` doesn't work with an empty string as a replacement argument (haruatari)
 | 
				
			||||||
 | 
					- Bug #17881: `yii\db\Query::queryScalar()` wasn’t reverting the `select`, `orderBy`, `limit`, and `offset` params if an exception occurred (brandonkelly)
 | 
				
			||||||
- Bug #17875: Use `move_uploaded_file()` function instead of `copy()` and `unlink()` for saving uploaded files in case of POST request (sup-ham)
 | 
					- Bug #17875: Use `move_uploaded_file()` function instead of `copy()` and `unlink()` for saving uploaded files in case of POST request (sup-ham)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -461,13 +461,25 @@ class Query extends Component implements QueryInterface, ExpressionInterface
 | 
				
			|||||||
            $this->orderBy = null;
 | 
					            $this->orderBy = null;
 | 
				
			||||||
            $this->limit = null;
 | 
					            $this->limit = null;
 | 
				
			||||||
            $this->offset = null;
 | 
					            $this->offset = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $e = null;
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
                $command = $this->createCommand($db);
 | 
					                $command = $this->createCommand($db);
 | 
				
			||||||
 | 
					            } catch (\Exception $e) {
 | 
				
			||||||
 | 
					                // throw it later
 | 
				
			||||||
 | 
					            } catch (\Throwable $e) {
 | 
				
			||||||
 | 
					                // throw it later
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $this->select = $select;
 | 
					            $this->select = $select;
 | 
				
			||||||
            $this->orderBy = $order;
 | 
					            $this->orderBy = $order;
 | 
				
			||||||
            $this->limit = $limit;
 | 
					            $this->limit = $limit;
 | 
				
			||||||
            $this->offset = $offset;
 | 
					            $this->offset = $offset;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if ($e !== null) {
 | 
				
			||||||
 | 
					                throw $e;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return $command->queryScalar();
 | 
					            return $command->queryScalar();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user