Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LOPS-1990] Fix fatal error on payment methods. #2522

Merged
merged 2 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/Collections/PaymentMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PaymentMethods extends UserOwnedCollection
* @throws TerminusException When there is more than one matching payment method
* @throws TerminusNotFoundException When there are no matching payment methods
*/
public function get($id): ?TerminusModel
public function get($id): TerminusModel
{
$payment_methods = $this->all();
if (isset($payment_methods[$id])) {
Expand Down
4 changes: 4 additions & 0 deletions src/Collections/TerminusCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ public function all()
public function fetch()
{
foreach ($this->getData() as $id => $model_data) {
if (!$id && !is_object($model_data)) {
// Empty model, just skip it.
continue;
}
if (!is_object($model_data)) {
// This should always be an object, however occasionally it is returning as a string
// We need more information about what it is and to handle the error
Expand Down
Loading