Skip to content

Conversation

@cconard96
Copy link
Contributor

Checklist before requesting a review

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.

Description

Adds a few restrictions for webhook management.

public function canCreateItem(): bool
{
$itemtype = $this->fields['itemtype'];
return empty($itemtype) || (is_subclass_of($itemtype, CommonGLPI::class) && $itemtype::canView());
Copy link
Member

Choose a reason for hiding this comment

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

Should be allow creation of hooks not related to any itemtype?

Copy link
Contributor Author

@cconard96 cconard96 Nov 19, 2025

Choose a reason for hiding this comment

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

Not really, but those webhooks wouldn't be usable at all so from a restriction standpoint it isn't a big deal. There is already a block in Webhook::handleInput when the itemtype is missing. The empty check here was more to prevent errors in the subclass/canView check.

@trasher trasher requested a review from cedric-anne November 21, 2025 09:21
@cedric-anne cedric-anne added this to the 11.0.3 milestone Nov 26, 2025
@cedric-anne cedric-anne merged commit f1d7635 into glpi-project:11.0/bugfixes Nov 26, 2025
13 of 14 checks passed
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.

4 participants