Details
-
Bug
-
Resolution: Fixed
-
Medium
-
1.13.1, 2.0.2, 1.7.7
-
None
Description
Currently, the method eZ\Publish\Core\FieldType\Page\Value::__toString() does not always return String. It returns null if the page layout equals null. This can cause further issues because PHP throws an error if magic method __toString() returns something different then String.
Most of the other Value classes are casting the value returned from __toString() to String, so this is what most probably should also be done in this case.
Steps to reproduce
- Set up new eZ Platform installation.
- Create a new Symfony Command with the following code:
<?php namespace AppBundle\Command; use eZ\Publish\Core\FieldType\Page\Parts\Page; use eZ\Publish\Core\FieldType\Page\Value; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class TestCommand extends ContainerAwareCommand { protected function configure() { $this ->setName('app:test_command'); } protected function execute(InputInterface $input, OutputInterface $output) { $page = new Page(); $pageValue = new Value($page); echo $pageValue; } }
- Run the created command by executing the following:
php app/console app:test_command
You will be presented with the following error:
[Symfony\Component\Debug\Exception\ContextErrorException] Catchable Fatal Error: Method eZ\Publish\Core\FieldType\Page\Value::__toString() must return a string value
The expected behaviour is that the code runs without any error.