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

Validate the scope when validating operations #36814

Merged
merged 2 commits into from
Feb 23, 2023

Conversation

nickvergessen
Copy link
Member

  • Resolves: #

Summary

TODO

  • ...

Checklist

Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
@@ -200,6 +200,13 @@
return $scopesByOperation[$operationClass];
}

try {
/** @var IOperation $operation */
$operation = $this->container->query($operationClass);

Check notice

Code scanning / Psalm

DeprecatedMethod

The method OCP\IContainer::query has been marked as deprecated
$scopesByOperation[$operationClass] = [];
while ($row = $result->fetch()) {
$scope = new ScopeContext($row['type'], $row['value']);

if (!$operation->isAvailableForScope((int) $row['type'])) {

Check notice

Code scanning / Psalm

ArgumentTypeCoercion

Argument 1 of OCP\WorkflowEngine\IOperation::isAvailableForScope expects 0|1, but parent type int provided

$this->operations[$scopeContext->getHash()] = [];
while ($row = $result->fetch()) {
try {
/** @var IOperation $operation */
$operation = $this->container->query($row['class']);

Check notice

Code scanning / Psalm

DeprecatedMethod

The method OCP\IContainer::query has been marked as deprecated
continue;
}

if (!$operation->isAvailableForScope((int) $row['scope_type'])) {

Check notice

Code scanning / Psalm

ArgumentTypeCoercion

Argument 1 of OCP\WorkflowEngine\IOperation::isAvailableForScope expects 0|1, but parent type int provided
* @throws \UnexpectedValueException
*/
public function validateOperation($class, $name, array $checks, $operation, string $entity, array $events) {
public function validateOperation($class, $name, array $checks, $operation, ScopeContext $scope, string $entity, array $events) {

Check notice

Code scanning / Psalm

MissingReturnType

Method OCA\WorkflowEngine\Manager::validateOperation does not have a return type, expecting void
@@ -513,6 +539,10 @@
throw new \UnexpectedValueException($this->l->t('Operation %s is invalid', [$class]));
}

if (!$instance->isAvailableForScope($scope->getScope())) {

Check notice

Code scanning / Psalm

ArgumentTypeCoercion

Argument 1 of OCP\WorkflowEngine\IOperation::isAvailableForScope expects 0|1, but parent type int provided
@skjnldsv skjnldsv merged commit 5b86ebd into master Feb 23, 2023
@skjnldsv skjnldsv deleted the bugfix/noid/validate-scope-when-validating-operation branch February 23, 2023 06:34
@skjnldsv skjnldsv mentioned this pull request Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants