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

Notice: Undefined index: parameter_mapping_name #22

Closed
jonathaningram opened this issue Nov 22, 2011 · 1 comment
Closed

Notice: Undefined index: parameter_mapping_name #22

jonathaningram opened this issue Nov 22, 2011 · 1 comment

Comments

@jonathaningram
Copy link
Contributor

Notice: Undefined index: parameter_mapping_name in vendor/bundles/JMS/SecurityExtraBundle/Security/Authorization/Expression/Compiler/ParameterExpressionCompiler.php line 58

This is my method declaration:

<?php

/**
 * {@inheritdoc}
 * 
 * @PreAuthorize("hasPermission(#project.getCompany(), 'OPERATOR') or hasRole('ROLE_SUPERUSER')")
 */
public function updateProject(ProjectInterface $project)
{

}
@jonathaningram
Copy link
Contributor Author

More information:

In JMS\SecurityExtraBundle\Security\Authorization\Expression\ExpressionCompiler, we have:

<?php

public function compilePreconditions(ExpressionInterface $expr)
    {
        if ($typeCompiler = $this->findTypeCompiler(get_class($expr))) {
            $typeCompiler->compilePreconditions($this, $expr);

            return $this;
        }

        if ($expr instanceof FunctionExpression) {
            $this->getFunctionCompiler($expr->name)->compilePreconditions($this, $expr);

            foreach ($expr->args as $arg) {
                $this->compilePreconditions($arg);
            }

            return $this;
        }

        if ($expr instanceof VariableExpression) {
            $this->getVariableCompiler($expr->name)->compilePreconditions($this, $expr);

            return $this;
        }

        return $this;
    }

The $expr argument looks like this:

JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\MethodCallExpression object {
  CLASSNAME => (string) JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\MethodCallExpression
  object => JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\ParameterExpression object {
    CLASSNAME => (string) JMS\SecurityExtraBundle\Security\Authorization\Expression\Ast\ParameterExpression
    name => (string) project
  }
  method => (string) getCompany
  args => array(0)
}

and so the preconditions for this are not compiled because that type does not match any in the method.

Thus, once we get to JMS\SecurityExtraBundle\Security\Authorization\Expression\Compiler\ParameterExpressionCompiler:

<?php

public function compile(ExpressionCompiler $compiler, ExpressionInterface $parameter)
    {
        $compiler
            ->compileInternal(new VariableExpression('object'))
            ->write("->arguments[");
        $compiler
            ->write("\${$compiler->attributes['parameter_mapping_name']}")
            ->write("['{$parameter->name}']]")
        ;
    }

$compiler->attributes['parameter_mapping_name'] is empty.

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

No branches or pull requests

2 participants