We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Currently Phalcon\Http\Message\AbstractCommon::cloneInstance clones the passed object and directly modifies object's property:
Phalcon\Http\Message\AbstractCommon::cloneInstance
cphalcon/phalcon/Http/Message/AbstractCommon.zep
Lines 32 to 40 in d59613f
This is not always correct because in some cases object's property is private. For example:
cphalcon/phalcon/Http/Message/Uri.zep
Lines 52 to 59 in d59613f
There is a PoC on PHP just to show the problem:
<?php abstract class AbstractCommon { final protected function cloneInstance($element, string $property) { $newInstance = clone $this; $newInstance->{$property} = $element; return $newInstance; } } final class Uri extends AbstractCommon { private $path = ""; public function withPath(string $path) { return $this->cloneInstance($path, "path"); } } $test = new Uri(); $test->withPath('action/reaction');
Output:
PHP Fatal error: Uncaught Error: Cannot access private property Uri::$path in /mnt/work/phalcon/cphalcon/manual.php:8 Stack trace: #0 /mnt/work/phalcon/cphalcon/manual.php(20): AbstractCommon->cloneInstance('action/reaction', 'path') #1 /mnt/work/phalcon/cphalcon/manual.php(25): Uri->withPath('action/reaction') #2 {main} thrown in /mnt/work/phalcon/cphalcon/manual.php on line 8 Fatal error: Uncaught Error: Cannot access private property Uri::$path in /mnt/work/phalcon/cphalcon/manual.php:8 Stack trace: #0 /mnt/work/phalcon/cphalcon/manual.php(20): AbstractCommon->cloneInstance('action/reaction', 'path') #1 /mnt/work/phalcon/cphalcon/manual.php(25): Uri->withPath('action/reaction') #2 {main} thrown in /mnt/work/phalcon/cphalcon/manual.php on line 8
The text was updated successfully, but these errors were encountered:
[#15040] - Changed visibility of the properties
88d57bb
[#15040] - Updating changelog
c114752
Fixed in 4.0.x branch
Sorry, something went wrong.
558b915
e539baa
a1a4da7
48c8fb1
niden
Successfully merging a pull request may close this issue.
Currently
Phalcon\Http\Message\AbstractCommon::cloneInstance
clones the passed object and directly modifies object's property:cphalcon/phalcon/Http/Message/AbstractCommon.zep
Lines 32 to 40 in d59613f
This is not always correct because in some cases object's property is private. For example:
cphalcon/phalcon/Http/Message/Uri.zep
Lines 52 to 59 in d59613f
There is a PoC on PHP just to show the problem:
Output:
The text was updated successfully, but these errors were encountered: