Skip to content

Also audit when model is already bootstrapped before auditing was enabled#1040

Open
gisostallenberg wants to merge 1 commit intoowen-it:masterfrom
gisostallenberg:audit-when-enabling-after-model-boot
Open

Also audit when model is already bootstrapped before auditing was enabled#1040
gisostallenberg wants to merge 1 commit intoowen-it:masterfrom
gisostallenberg:audit-when-enabling-after-model-boot

Conversation

@gisostallenberg
Copy link
Copy Markdown
Contributor

No description provided.

Comment thread src/Auditable.php
*/
public static function bootAuditable()
{
if (App::getFacadeRoot() && static::isAuditingEnabled()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@erikn69 I can't remember why the App::getFacadeRoot() check is required but I definitely remember needing it at some point, does that ring any bells for you?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, but that will in some cases make audits not happen at all (because when the app is not spun up, but the model gets booted, it will never observe)

The tests succeed, even OutsideOfAppContextTest

Copy link
Copy Markdown
Contributor

@erikn69 erikn69 Nov 28, 2025

Choose a reason for hiding this comment

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

I think something is being reversed; I believe it was perhaps for performance reasons, to avoid always registering observers, I don't remember.

It seems it's always been like this: #134

Comment thread src/AuditableObserver.php
return;
}
$modelClass = $model::class;
if (method_exists($modelClass, 'isAuditingEnabled') && ! $modelClass::isAuditingEnabled()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it seems like one check has been replaced by two, is this one definitely needed? should there be a separate test to pick it up?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants