recurly/recurly-client-php — Issue #22: Recurly_Resource::getChangedAttributes doesn't return changed Recurly_Plan attributes
Author: p-n-p
Created: 2011-12-06 13:16:31+00:00
State: open

Trying to change plan price:

```php
$plan = Recurly_Plan::get($plan_code);
$plan->unit_amount_in_cents['GBP']->amount_in_cents = $price;
$plan->update();
```

In such a case the xml() method returns empty XML, because Recurly_Resource::getChangedAttributes doesn't detect changes done to Recurly_Plan::unit_amount_in_cents and Recurly_Plan::setup_fee_in_cents.

I used the following workaround:
in Recurly_Resource::getChangedAttributes added this line to the condition inside foreach:

```php
|| (isset($this->$attr) && (is_array($this->$attr) || $this->$attr instanceof ArrayAccess))
```

to make the whole condition look like this:

```php
if (isset($this->_unsavedKeys[$attr]) || (isset($this->_values[$attr]) && is_array($this->_values[$attr]))
|| (isset($this->$attr) && (is_array($this->$attr) || $this->$attr instanceof ArrayAccess))) {
```