markhuot/craft-forced-eager

Installs: 12

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:yii2-extension

1.0.1 2023-02-10 22:10 UTC

This package is auto-updated.

Last update: 2024-11-11 02:12:45 UTC


README

A Yii2 Extension that will throw errors whenever a relationship field is accessed lazily.

Forced Eager Loading

Scrolling down the stack trace should show you the exact line of Twig code that prompted the error.

You can prevent exceptions in one of two ways,

  1. Use the .with(['fieldHandle']) syntax to eager load the field (preferred)
  2. Silence the error with .allowLazyRelations() on the query, e.g., craft.entries.allowLazyRelations().limit(10).