Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions common/models/Tabby.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ public function addTransaction($data) {

if (!$tt->save()) {
TabbyTransaction::ddlog('error', 'addTransaction', null, $tt->errors);
echo "<pre />";
print_r($tt->errors);
die();
throw new \yii\base\Exception('Unable to persist Tabby transaction.');
}
}
}
Expand Down Expand Up @@ -132,9 +130,7 @@ public function updateTransaction($data) {

if (!$tt->save()) {
TabbyTransaction::ddlog('error', 'addTransaction', null, $tt->errors);
echo "<pre />";
print_r($tt->errors);
die();
throw new \yii\base\Exception('Unable to update Tabby transaction.');
}
Comment on lines 131 to 134

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix copy-paste error in log context.

The ddlog call on line 132 uses 'addTransaction' as the context, but this code is inside the updateTransaction() method. This inconsistency will make log analysis and debugging more difficult.

🐛 Proposed fix
 if (!$tt->save()) {
-    TabbyTransaction::ddlog('error', 'addTransaction', null, $tt->errors);
+    TabbyTransaction::ddlog('error', 'updateTransaction', null, $tt->errors);
     throw new \yii\base\Exception('Unable to update Tabby transaction.');
 }

Additionally, consider using a more specific exception type for consistency:

 if (!$tt->save()) {
     TabbyTransaction::ddlog('error', 'updateTransaction', null, $tt->errors);
-    throw new \yii\base\Exception('Unable to update Tabby transaction.');
+    throw new \yii\db\Exception('Unable to update Tabby transaction.');
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!$tt->save()) {
TabbyTransaction::ddlog('error', 'addTransaction', null, $tt->errors);
echo "<pre />";
print_r($tt->errors);
die();
throw new \yii\base\Exception('Unable to update Tabby transaction.');
}
if (!$tt->save()) {
TabbyTransaction::ddlog('error', 'updateTransaction', null, $tt->errors);
throw new \yii\base\Exception('Unable to update Tabby transaction.');
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@common/models/Tabby.php` around lines 131 - 134, The log context is
incorrect: inside updateTransaction() the TabbyTransaction::ddlog call uses the
string 'addTransaction' which is a copy-paste error; update the ddlog invocation
in updateTransaction() to use the correct context string (e.g.,
'updateTransaction') so logs reflect the right method, and while here consider
throwing a more specific exception class instead of \yii\base\Exception (for
example \RuntimeException or your domain-specific exception) to keep error
handling consistent.


//} else {
Expand Down Expand Up @@ -862,4 +858,4 @@ public function delete($transaction_id, $restaurant_uuid) {
public function getErrors($attribute = null) {
return $this->errors;
}
}
}