Skip to content

Commit

Permalink
Fixed #3034
Browse files Browse the repository at this point in the history
`craft\fields\data\MultiOptionsFieldData` no longer implements the `craft\base\Serializable` interface, as its `serialize()` method conflicted with PHP’s `Serializable` interface.
  • Loading branch information
brandonkelly committed Jun 30, 2018
1 parent e67236f commit aaa868f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Fixed a bug where user verification links could get mangled when emails were parsed as Markdown, if the verification code contained two or more underscores.
- Fixed a bug where Craft was misinterpreting `X-Forwarded-For` headers as the user’s IP instead of the server’s IP. ([#3036](https://github.com/craftcms/cms/issues/3036))
- Fixed a bug where Craft wasn’t auto-scrolling the content container when dragging items near a window edge. ([#2340](https://github.com/craftcms/cms/issues/2340))
- Fixed a PHP error that occurred when loading a Debug Toolbar panel on a page that contained serialized Checkboxes or Multi-Select field data. ([#3034](https://github.com/craftcms/cms/issues/3034))

## 3.0.13.2 - 2018-06-27

Expand Down
17 changes: 17 additions & 0 deletions src/fields/BaseOptionsField.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,23 @@ public function normalizeValue($value, ElementInterface $element = null)
return $value;
}

/**
* @inheritdoc
*/
public function serializeValue($value, ElementInterface $element = null)
{
if ($value instanceof MultiOptionsFieldData) {
$serialized = [];
foreach ($value as $selectedValue) {
/** @var OptionData $selectedValue */
$serialized[] = $selectedValue->value;
}
return Json::encode($serialized);
}

return parent::serializeValue($value, $element);
}

/**
* @inheritdoc
*/
Expand Down
20 changes: 1 addition & 19 deletions src/fields/data/MultiOptionsFieldData.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@

namespace craft\fields\data;

use craft\base\Serializable;
use craft\helpers\Json;

/**
* Multi-select option field data class.
*
* @author Pixel & Tonic, Inc. <support@pixelandtonic.com>
* @since 3.0
*/
class MultiOptionsFieldData extends \ArrayObject implements Serializable
class MultiOptionsFieldData extends \ArrayObject
{
// Properties
// =========================================================================
Expand Down Expand Up @@ -66,19 +63,4 @@ public function contains($value): bool

return false;
}

/**
* @inheritdoc
*/
public function serialize()
{
$serialized = [];

foreach ($this as $selectedValue) {
/** @var OptionData $selectedValue */
$serialized[] = $selectedValue->value;
}

return Json::encode($serialized);
}
}

0 comments on commit aaa868f

Please sign in to comment.