Afform.revert - Refuse to revert if there are no "where" constraints
authorTim Otten <totten@civicrm.org>
Sat, 9 Feb 2019 05:53:02 +0000 (00:53 -0500)
committerCiviCRM <info@civicrm.org>
Wed, 16 Sep 2020 02:13:17 +0000 (19:13 -0700)
Bulk reverting everything would be... a bit... dangerous?

ext/afform/core/Civi/Api4/Action/Afform/Revert.php

index f194e6f1753803dbdc6ebdf7882ced8cb1c7ff77..377dd2683ace916870d05790db235059bd75a7e7 100644 (file)
@@ -9,6 +9,10 @@ class Revert extends Get {
   protected $select = ['name'];
 
   public function _run(Result $result) {
+    if (empty($this->where)) {
+      throw new \API_Exception('Cannot revert with no "where" paramater specified');
+    }
+
     $scanner = \Civi::service('afform_scanner');
 
     parent::_run($result);