Skip to content

Commit

Permalink
BAP-22546: Fix application crash after update to symfony/property-acc…
Browse files Browse the repository at this point in the history
…ess v6.4.6 (#38013)

- since symfony/property-access 6.4.6 the application crashed with a lot of exceptions like "Can't get a way to read the property ... in class ...", see symfony/symfony#54194
  • Loading branch information
vsoroka authored and RocKordier committed Apr 9, 2024
1 parent e362d55 commit a079f35
Show file tree
Hide file tree
Showing 9 changed files with 234 additions and 235 deletions.
435 changes: 219 additions & 216 deletions dev.lock

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions src/Oro/Bundle/ActionBundle/Form/Type/OperationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* The form type for action operations.
*/
class OperationType extends AbstractType
{
const NAME = 'oro_action_operation';
Expand Down Expand Up @@ -105,7 +108,7 @@ function (FormEvent $event) use ($options) {
$data = $event->getData();

foreach ($options['attribute_default_values'] as $attributeName => $value) {
$data->$attributeName = $this->contextAccessor->getValue($data, $value);
$data->set($attributeName, $this->contextAccessor->getValue($data, $value));
}
}
);
Expand Down Expand Up @@ -145,8 +148,8 @@ protected function addAttributes(FormBuilderInterface $builder, array $options)
$attributeOptions = [];
}

if (isset($actionData->$attributeName)) {
$attributeOptions['options']['data'] = $actionData->$attributeName;
if ($actionData->has($attributeName)) {
$attributeOptions['options']['data'] = $actionData->get($attributeName);
}

$attributeOptions = $this->prepareAttributeOptions($attribute, $attributeOptions, $options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public function testIssetGetSetUnset()
{
$data = new ActionData();

$this->assertFalse(isset($data->foo));
$this->assertTrue(isset($data->foo));
$this->assertNull($data->foo);

$data->foo = 'bar';
$this->assertTrue(isset($data->foo));
$this->assertEquals('bar', $data->foo);

unset($data->foo);
$this->assertFalse(isset($data->foo));
$this->assertTrue(isset($data->foo));
$this->assertNull($data->foo);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ public function call(EntityFieldProcessTransport $transport): void
*/
public function isset(EntityFieldProcessTransport $transport): void
{
$this->propertyExists($transport);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ protected function getCachedExtensionItem(

public function isset(EntityFieldProcessTransport $transport): void
{
$this->propertyExists($transport);
}

protected function getMethodsData(EntityFieldProcessTransport $transport): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,6 @@ public function call(EntityFieldProcessTransport $transport): void
}
}

public function isset(EntityFieldProcessTransport $transport): void
{
$properties = $this->getProperties($transport);
if (array_key_exists($transport->getName(), $properties)) {
$transport->setResult(true);
$transport->setProcessed(true);
}
}

public function propertyExists(EntityFieldProcessTransport $transport): void
{
$properties = $this->getProperties($transport);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ public function testHasGetSetRemove()

public function testIssetGetSetUnset()
{
$this->assertFalse(isset($this->data->foo));
$this->assertTrue(isset($this->data->foo));
$this->assertNull($this->data->foo);

$this->data->foo = 'bar';
$this->assertTrue(isset($this->data->foo));
$this->assertEquals('bar', $this->data->foo);

unset($this->data->foo);
$this->assertFalse(isset($this->data->foo));
$this->assertTrue(isset($this->data->foo));
$this->assertNull($this->data->foo);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ public function testHasGetSetRemove()

public function testIssetGetSetUnset()
{
$this->assertFalse(isset($this->result->foo));
$this->assertTrue(isset($this->result->foo));
$this->assertNull($this->result->foo);

$this->result->foo = 'bar';
$this->assertTrue(isset($this->result->foo));
$this->assertEquals('bar', $this->result->foo);

unset($this->result->foo);
$this->assertFalse(isset($this->result->foo));
$this->assertTrue(isset($this->result->foo));
$this->assertNull($this->result->foo);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Oro/Component/Action/Model/AbstractStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public function __unset($name)
*/
public function __isset($name)
{
return $this->has($name);
return true;
}

/**
Expand Down

0 comments on commit a079f35

Please sign in to comment.