问题
I have a strange issue with CakePHP 3.0 and virtual properties on our server. We have a Photo Entity with the following virtual property:
protected function _getPath()
{
[...]
return $path; // array with path for different photo sizes
}
On our development server (Ubuntu, Apache, PHP 5.5.9-1ubuntu4.6) everything works perfectly. On our production server (Linux, Apache, PHP 5.5.23) the site is working great, except that the virtual properties are missing in the data object.
The photo entity is read from db via Entries Table->contain and echoed like this:
$entry->photos[0]['path']['wide'];
The basic properties of the Photo entity can be read on both servers with e.g.:
$entry->photos[0]['filename'];
In addition I just found out, that a pr() on $entry->photo[0] (or $photo in foreach loop) is different on both servers. On the server where everything works as expected i get:
App\Model\Entity\Photo Object
(
[_accessible:protected] => Array
(
[user_id] => 1
[entry_id] => 1
[filename] => 1
[org_name] => 1
[description] => 1
[user] => 1
[entry] => 1
)
[_virtual:protected] => Array
(
[0] => path
)
[...]
and on the server where the virtual property is missing i get:
Cake\ORM\Entity Object
(
[_properties:protected] => Array
(
[id] => 37
[user_id] => 1
[entry_id] => 4
[filename] => p19fng7349bb2p6nsac14j51qnu4.jpg
[...]
Any idea why the virtual property on the production environment is missing, and why the objects on both servers are of different types?
Thanks a lot!
Simon
来源:https://stackoverflow.com/questions/29275998/cakephp-3-0-virtual-property-missing-on-production-server