RE: [fw-general] Zend_Acl 1.11 broken my code

2010-11-14 Thread Terre Porter
Patch works like a charm here. 

Thanks for the fast turnaround Ralph.

Terre

-Original Message-
From: Ralph Schindler [mailto:ralph.schind...@zend.com] 
Sent: Friday, November 12, 2010 3:28 PM
To: fw-general@lists.zend.com
Subject: Re: [fw-general] Zend_Acl 1.11 broken my code

Hi All,

I've uploaded a patch to Zend_Acl that covers this use case while being 
completely backwards compatible.

I'd really like to see everyone test this so we can feel good about including 
it ASAP.

Issue:
http://framework.zend.com/issues/browse/ZF-10649

Patch:
http://framework.zend.com/issues/secure/attachment/13431/ZF-10649.patch

-ralph

On 11/11/10 6:50 PM, Terre Porter wrote:
> So I've taken a look since this problem affected my code also.
>
> If I understand the problem correctly would it not be better to just adjust 
> the isAllowed code to support the changes to the setRule?
>
>if (null !== $resource) {
>  // keep track of originally called resource
>  $this->_isAllowedResource = $resource;
>  $resource = $this->get($resource);
>  if (!$this->_isAllowedResource instanceof 
> Zend_Acl_Resource_Interface) {
>  $this->_isAllowedResource = $resource;
>  }
>// if resource is null, and resources exist then add them instead
>  } elseif ($resource === null&&  count($this->_resources)>  0) {
>   foreach (array_keys($this->_resources) as $k =>  $v ) {
>   if (null !== ($result = $this->isAllowed($role, $v, 
> $privilege))) {
>   return $result;
>   };
>   }
>  }
>
> The follow now works as expected.
>
> $acl = new Zend_Acl();
> $acl->addRole(new Zend_Acl_Role('role')); $acl->addResource(new 
> Zend_Acl_Resource('res'));
>
> $acl->allow('role','res', 'privilege'); echo 
> $acl->isAllowed('role','res','privilege')? "allowed" : "denied"; // 
> returns allowed
>
> $acl->removeAllow('role',null,'privilege');
> echo $acl->isAllowed('role',null,'privilege')? "allowed" : "denied"; 
> // returns denied
>
> And the second code
>
> $acl = new Zend_Acl();
> $acl->addRole(new Zend_Acl_Role('role')); $acl->addResource(new 
> Zend_Acl_Resource('res'));
>
> $acl->allow('role');
> echo $acl->isAllowed('administrator') ? "allowed" : "denied"; // 
> returns allowed
>
> Would be the same as : (since null resource is all defined resources)
>
> $acl->allow('role', 'res');
> echo $acl->isAllowed('administrator') ? "allowed" : "denied"; // 
> returns allowed
>
> Hope that helps.
> Terre
>
>
> -Original Message-
> From: Ralph Schindler [mailto:ralph.schind...@zend.com]
> Sent: Thursday, November 11, 2010 12:50 PM
> To: fw-general@lists.zend.com
> Subject: Re: [fw-general] Zend_Acl 1.11 broken my code
>
> I've been looking at this over the past day and I am attempting to find a 
> solution.  As you can see it was a fix for a previous issue:
>
> http://framework.zend.com/issues/browse/ZF-9643
>
> Fixing the previous issue did not break any existing unit tests.
>
> I will get to the bottom of it and figure out a solution that works for 
> everyone.
>
> -ralph
>
>
>
>
> On 11/11/10 12:32 AM, Valentin wrote:
>> Hi,
>> I'm impressed, is exactly the problem reported at bug
>> http://framework.zend.com/issues/browse/ZF-10649
>>
>> Thanxx
>>
>> 2010/11/10 Emmanuel Bouton
>>
>>> Hi,
>>>
>>> A bug has been created for that :
>>> http://framework.zend.com/issues/browse/ZF-10649
>>>
>>> I suggest you to vote for its fix ;)
>>>
>>> Manu
>>>
>>> 2010/11/10 Valentin
>>>
>>>> Hi,
>>>> New version 1.11 have only one change in Zend_Acl  line 636:
>>>>
>>>> Old line
>>>> $resources = array($resources);
>>>> change for this
>>>> $resources = ($resources == null&&   count($this->_resources)>   0) ?
>>>> array_keys($this->_resources) : array($resources);
>>>>
>>>>
>>>> I've been studying (and debug) all day and how it affects the code 
>>>> and
>>> not
>>>> understand what happens. Any ideas?
>>>> Thanks
>>>>
>>>
>>
>
>



Re: [fw-general] Zend_Acl 1.11 broken my code

2010-11-13 Thread Valentin
Hi!
Tahnxx Ralph
Works fine for me.

Regards


2010/11/12 Ralph Schindler 

> Hi All,
>
> I've uploaded a patch to Zend_Acl that covers this use case while being
> completely backwards compatible.
>
> I'd really like to see everyone test this so we can feel good about
> including it ASAP.
>
> Issue:
>
> http://framework.zend.com/issues/browse/ZF-10649
>
> Patch:
> http://framework.zend.com/issues/secure/attachment/13431/ZF-10649.patch
>
> -ralph
>
>


Re: [fw-general] Zend_Acl 1.11 broken my code

2010-11-13 Thread Emmanuel Bouton
Hi,

The issue tracker seems to be down :(
Can you send me the patch in private ?

Emmanuel

2010/11/12 Ralph Schindler :
> Hi All,
>
> I've uploaded a patch to Zend_Acl that covers this use case while being
> completely backwards compatible.
>
> I'd really like to see everyone test this so we can feel good about
> including it ASAP.
>
> Issue:
> http://framework.zend.com/issues/browse/ZF-10649
>
> Patch:
> http://framework.zend.com/issues/secure/attachment/13431/ZF-10649.patch
>
> -ralph
>
> On 11/11/10 6:50 PM, Terre Porter wrote:
>>
>> So I've taken a look since this problem affected my code also.
>>
>> If I understand the problem correctly would it not be better to just
>> adjust the isAllowed code to support the changes to the setRule?
>>
>>       if (null !== $resource) {
>>             // keep track of originally called resource
>>             $this->_isAllowedResource = $resource;
>>             $resource = $this->get($resource);
>>             if (!$this->_isAllowedResource instanceof
>> Zend_Acl_Resource_Interface) {
>>                 $this->_isAllowedResource = $resource;
>>             }
>>       // if resource is null, and resources exist then add them instead
>>         } elseif ($resource === null&&  count($this->_resources)>  0) {
>>                foreach (array_keys($this->_resources) as $k =>  $v ) {
>>                        if (null !== ($result = $this->isAllowed($role, $v,
>> $privilege))) {
>>                                return $result;
>>                        };
>>                }
>>         }
>>
>> The follow now works as expected.
>>
>> $acl = new Zend_Acl();
>> $acl->addRole(new Zend_Acl_Role('role'));
>> $acl->addResource(new Zend_Acl_Resource('res'));
>>
>> $acl->allow('role','res', 'privilege');
>> echo $acl->isAllowed('role','res','privilege')? "allowed" : "denied"; //
>> returns allowed
>>
>> $acl->removeAllow('role',null,'privilege');
>> echo $acl->isAllowed('role',null,'privilege')? "allowed" : "denied"; //
>> returns denied
>>
>> And the second code
>>
>> $acl = new Zend_Acl();
>> $acl->addRole(new Zend_Acl_Role('role'));
>> $acl->addResource(new Zend_Acl_Resource('res'));
>>
>> $acl->allow('role');
>> echo $acl->isAllowed('administrator') ? "allowed" : "denied"; // returns
>> allowed
>>
>> Would be the same as : (since null resource is all defined resources)
>>
>> $acl->allow('role', 'res');
>> echo $acl->isAllowed('administrator') ? "allowed" : "denied"; // returns
>> allowed
>>
>> Hope that helps.
>> Terre
>>
>>
>> -Original Message-
>> From: Ralph Schindler [mailto:ralph.schind...@zend.com]
>> Sent: Thursday, November 11, 2010 12:50 PM
>> To: fw-general@lists.zend.com
>> Subject: Re: [fw-general] Zend_Acl 1.11 broken my code
>>
>> I've been looking at this over the past day and I am attempting to find a
>> solution.  As you can see it was a fix for a previous issue:
>>
>> http://framework.zend.com/issues/browse/ZF-9643
>>
>> Fixing the previous issue did not break any existing unit tests.
>>
>> I will get to the bottom of it and figure out a solution that works for
>> everyone.
>>
>> -ralph
>>
>>
>>
>>
>> On 11/11/10 12:32 AM, Valentin wrote:
>>>
>>> Hi,
>>> I'm impressed, is exactly the problem reported at bug
>>> http://framework.zend.com/issues/browse/ZF-10649
>>>
>>> Thanxx
>>>
>>> 2010/11/10 Emmanuel Bouton
>>>
>>>> Hi,
>>>>
>>>> A bug has been created for that :
>>>> http://framework.zend.com/issues/browse/ZF-10649
>>>>
>>>> I suggest you to vote for its fix ;)
>>>>
>>>> Manu
>>>>
>>>> 2010/11/10 Valentin
>>>>
>>>>> Hi,
>>>>> New version 1.11 have only one change in Zend_Acl  line 636:
>>>>>
>>>>> Old line
>>>>> $resources = array($resources);
>>>>> change for this
>>>>> $resources = ($resources == null&&   count($this->_resources)>   0) ?
>>>>> array_keys($this->_resources) : array($resources);
>>>>>
>>>>>
>>>>> I've been studying (and debug) all day and how it affects the code
>>>>> and
>>>>
>>>> not
>>>>>
>>>>> understand what happens. Any ideas?
>>>>> Thanks
>>>>>
>>>>
>>>
>>
>>
>


Re: [fw-general] Zend_Acl 1.11 broken my code

2010-11-12 Thread Ralph Schindler

Hi All,

I've uploaded a patch to Zend_Acl that covers this use case while being 
completely backwards compatible.


I'd really like to see everyone test this so we can feel good about 
including it ASAP.


Issue:
http://framework.zend.com/issues/browse/ZF-10649

Patch:
http://framework.zend.com/issues/secure/attachment/13431/ZF-10649.patch

-ralph

On 11/11/10 6:50 PM, Terre Porter wrote:

So I've taken a look since this problem affected my code also.

If I understand the problem correctly would it not be better to just adjust the 
isAllowed code to support the changes to the setRule?

   if (null !== $resource) {
 // keep track of originally called resource
 $this->_isAllowedResource = $resource;
 $resource = $this->get($resource);
 if (!$this->_isAllowedResource instanceof 
Zend_Acl_Resource_Interface) {
 $this->_isAllowedResource = $resource;
 }
   // if resource is null, and resources exist then add them instead
 } elseif ($resource === null&&  count($this->_resources)>  0) {
foreach (array_keys($this->_resources) as $k =>  $v ) {
if (null !== ($result = $this->isAllowed($role, $v, 
$privilege))) {
return $result;
};
}
 }

The follow now works as expected.

$acl = new Zend_Acl();
$acl->addRole(new Zend_Acl_Role('role'));
$acl->addResource(new Zend_Acl_Resource('res'));

$acl->allow('role','res', 'privilege');
echo $acl->isAllowed('role','res','privilege')? "allowed" : "denied"; // 
returns allowed

$acl->removeAllow('role',null,'privilege');
echo $acl->isAllowed('role',null,'privilege')? "allowed" : "denied"; // returns 
denied

And the second code

$acl = new Zend_Acl();
$acl->addRole(new Zend_Acl_Role('role'));
$acl->addResource(new Zend_Acl_Resource('res'));

$acl->allow('role');
echo $acl->isAllowed('administrator') ? "allowed" : "denied"; // returns allowed

Would be the same as : (since null resource is all defined resources)

$acl->allow('role', 'res');
echo $acl->isAllowed('administrator') ? "allowed" : "denied"; // returns allowed

Hope that helps.
Terre


-Original Message-
From: Ralph Schindler [mailto:ralph.schind...@zend.com]
Sent: Thursday, November 11, 2010 12:50 PM
To: fw-general@lists.zend.com
Subject: Re: [fw-general] Zend_Acl 1.11 broken my code

I've been looking at this over the past day and I am attempting to find a 
solution.  As you can see it was a fix for a previous issue:

http://framework.zend.com/issues/browse/ZF-9643

Fixing the previous issue did not break any existing unit tests.

I will get to the bottom of it and figure out a solution that works for 
everyone.

-ralph




On 11/11/10 12:32 AM, Valentin wrote:

Hi,
I'm impressed, is exactly the problem reported at bug
http://framework.zend.com/issues/browse/ZF-10649

Thanxx

2010/11/10 Emmanuel Bouton


Hi,

A bug has been created for that :
http://framework.zend.com/issues/browse/ZF-10649

I suggest you to vote for its fix ;)

Manu

2010/11/10 Valentin


Hi,
New version 1.11 have only one change in Zend_Acl  line 636:

Old line
$resources = array($resources);
change for this
$resources = ($resources == null&&   count($this->_resources)>   0) ?
array_keys($this->_resources) : array($resources);


I've been studying (and debug) all day and how it affects the code
and

not

understand what happens. Any ideas?
Thanks










RE: [fw-general] Zend_Acl 1.11 broken my code

2010-11-11 Thread Terre Porter
So I've taken a look since this problem affected my code also.
 
If I understand the problem correctly would it not be better to just adjust the 
isAllowed code to support the changes to the setRule?

  if (null !== $resource) {
// keep track of originally called resource
$this->_isAllowedResource = $resource;
$resource = $this->get($resource);
if (!$this->_isAllowedResource instanceof 
Zend_Acl_Resource_Interface) {
$this->_isAllowedResource = $resource;
}
  // if resource is null, and resources exist then add them instead
} elseif ($resource === null && count($this->_resources) > 0) {
foreach (array_keys($this->_resources) as $k => $v ) {
if (null !== ($result = $this->isAllowed($role, $v, 
$privilege))) {
return $result;
};
}
}

The follow now works as expected.

$acl = new Zend_Acl();
$acl->addRole(new Zend_Acl_Role('role'));
$acl->addResource(new Zend_Acl_Resource('res'));

$acl->allow('role','res', 'privilege');
echo $acl->isAllowed('role','res','privilege')? "allowed" : "denied"; // 
returns allowed

$acl->removeAllow('role',null,'privilege');
echo $acl->isAllowed('role',null,'privilege')? "allowed" : "denied"; // returns 
denied

And the second code

$acl = new Zend_Acl();
$acl->addRole(new Zend_Acl_Role('role'));
$acl->addResource(new Zend_Acl_Resource('res'));

$acl->allow('role');
echo $acl->isAllowed('administrator') ? "allowed" : "denied"; // returns allowed

Would be the same as : (since null resource is all defined resources)

$acl->allow('role', 'res');
echo $acl->isAllowed('administrator') ? "allowed" : "denied"; // returns allowed

Hope that helps.
Terre


-Original Message-
From: Ralph Schindler [mailto:ralph.schind...@zend.com] 
Sent: Thursday, November 11, 2010 12:50 PM
To: fw-general@lists.zend.com
Subject: Re: [fw-general] Zend_Acl 1.11 broken my code

I've been looking at this over the past day and I am attempting to find a 
solution.  As you can see it was a fix for a previous issue:

http://framework.zend.com/issues/browse/ZF-9643

Fixing the previous issue did not break any existing unit tests.

I will get to the bottom of it and figure out a solution that works for 
everyone.

-ralph




On 11/11/10 12:32 AM, Valentin wrote:
> Hi,
> I'm impressed, is exactly the problem reported at bug
> http://framework.zend.com/issues/browse/ZF-10649
>
> Thanxx
>
> 2010/11/10 Emmanuel Bouton
>
>> Hi,
>>
>> A bug has been created for that :
>> http://framework.zend.com/issues/browse/ZF-10649
>>
>> I suggest you to vote for its fix ;)
>>
>> Manu
>>
>> 2010/11/10 Valentin
>>
>>> Hi,
>>> New version 1.11 have only one change in Zend_Acl  line 636:
>>>
>>> Old line
>>> $resources = array($resources);
>>> change for this
>>> $resources = ($resources == null&&  count($this->_resources)>  0) ?
>>> array_keys($this->_resources) : array($resources);
>>>
>>>
>>> I've been studying (and debug) all day and how it affects the code 
>>> and
>> not
>>> understand what happens. Any ideas?
>>> Thanks
>>>
>>
>



Re: [fw-general] Zend_Acl 1.11 broken my code

2010-11-11 Thread Ralph Schindler
I've been looking at this over the past day and I am attempting to find 
a solution.  As you can see it was a fix for a previous issue:


http://framework.zend.com/issues/browse/ZF-9643

Fixing the previous issue did not break any existing unit tests.

I will get to the bottom of it and figure out a solution that works for 
everyone.


-ralph




On 11/11/10 12:32 AM, Valentin wrote:

Hi,
I'm impressed, is exactly the problem reported at bug
http://framework.zend.com/issues/browse/ZF-10649

Thanxx

2010/11/10 Emmanuel Bouton


Hi,

A bug has been created for that :
http://framework.zend.com/issues/browse/ZF-10649

I suggest you to vote for its fix ;)

Manu

2010/11/10 Valentin


Hi,
New version 1.11 have only one change in Zend_Acl  line 636:

Old line
$resources = array($resources);
change for this
$resources = ($resources == null&&  count($this->_resources)>  0) ?
array_keys($this->_resources) : array($resources);


I've been studying (and debug) all day and how it affects the code and

not

understand what happens. Any ideas?
Thanks







Re: [fw-general] Zend_Acl 1.11 broken my code

2010-11-10 Thread Valentin
Hi,
I'm impressed, is exactly the problem reported at bug
http://framework.zend.com/issues/browse/ZF-10649

Thanxx

2010/11/10 Emmanuel Bouton 

> Hi,
>
> A bug has been created for that :
> http://framework.zend.com/issues/browse/ZF-10649
>
> I suggest you to vote for its fix ;)
>
> Manu
>
> 2010/11/10 Valentin 
>
> > Hi,
> > New version 1.11 have only one change in Zend_Acl  line 636:
> >
> > Old line
> > $resources = array($resources);
> > change for this
> > $resources = ($resources == null && count($this->_resources) > 0) ?
> > array_keys($this->_resources) : array($resources);
> >
> >
> > I've been studying (and debug) all day and how it affects the code and
> not
> > understand what happens. Any ideas?
> > Thanks
> >
>


Re: [fw-general] Zend_Acl 1.11 broken my code

2010-11-10 Thread Jurian Sluiman
On Wednesday 10 Nov 2010 20:08:54 Valentin wrote:
> Hi,
> New version 1.11 have only one change in Zend_Acl  line 636:
> 
> Old line
> $resources = array($resources);
> change for this
> $resources = ($resources == null && count($this->_resources) > 0) ?
> array_keys($this->_resources) : array($resources);
> 
> 
> I've been studying (and debug) all day and how it affects the code and not
> understand what happens. Any ideas?
> Thanks

If you use the blame function of svn, you see Ralph changed this line in 
update 22,581. The message was:

> Solution applied in setRule() as opposed to fix in previous commit in
> removeAllow() / removeDeny()

Which should solve issue 9643. Browse 
http://framework.zend.com/issues/browse/ZF-9643 to know more about this bug.

Perhaps you can find out what this fix was about and why your bug was 
introduced. A new issue with a new proposal to solve both bugs can be opened 
then :)

Regards, Jurian
-- 
Jurian Sluiman
Soflomo - http://soflomo.com


Re: [fw-general] Zend_Acl 1.11 broken my code

2010-11-10 Thread Matthew Weier O'Phinney
-- Valentin  wrote
(on Wednesday, 10 November 2010, 08:08 PM +0100):
> New version 1.11 have only one change in Zend_Acl  line 636:
> 
> Old line
> $resources = array($resources);
> change for this
> $resources = ($resources == null && count($this->_resources) > 0) ?
> array_keys($this->_resources) : array($resources);
> 
> 
> I've been studying (and debug) all day and how it affects the code and not
> understand what happens. Any ideas?

Most likely that code is in there as part of a feature request or
bugfix.

Can you explain to us the following:

 * How you're defining your ACLs
 * What operation you're calling that's not working as expected
   * and what you expect
   * and what is actually happening

If you can do that, we can check to see why the code was changed, and
whether your usage of it falls outside of the framework expectations, or
if something is indeed broken.

Thanks!

-- 
Matthew Weier O'Phinney
Project Lead| matt...@zend.com
Zend Framework  | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc


Re: [fw-general] Zend_Acl 1.11 broken my code

2010-11-10 Thread Emmanuel Bouton
Hi,

A bug has been created for that :
http://framework.zend.com/issues/browse/ZF-10649

I suggest you to vote for its fix ;)

Manu

2010/11/10 Valentin 

> Hi,
> New version 1.11 have only one change in Zend_Acl  line 636:
>
> Old line
> $resources = array($resources);
> change for this
> $resources = ($resources == null && count($this->_resources) > 0) ?
> array_keys($this->_resources) : array($resources);
>
>
> I've been studying (and debug) all day and how it affects the code and not
> understand what happens. Any ideas?
> Thanks
>


[fw-general] Zend_Acl 1.11 broken my code

2010-11-10 Thread Valentin
Hi,
New version 1.11 have only one change in Zend_Acl  line 636:

Old line
$resources = array($resources);
change for this
$resources = ($resources == null && count($this->_resources) > 0) ?
array_keys($this->_resources) : array($resources);


I've been studying (and debug) all day and how it affects the code and not
understand what happens. Any ideas?
Thanks