| @@ -97,11 +97,37 @@ | ||
| 97 | 97 | if ($public) |
| 98 | 98 | { |
| 99 | 99 | foreach ($vars as $key => $value) |
| 100 | 100 | { |
| 101 | - if ('_' == substr($key, 0, 1)) | |
| 101 | + if (substr($key, 0, 1) === '_') | |
| 102 | 102 | { |
| 103 | 103 | unset($vars[$key]); |
| 104 | + } | |
| 105 | + } | |
| 106 | + | |
| 107 | + /** | |
| 108 | + * Collect all none public properties of the current class and it's parents. | |
| 109 | + * This way, protected and private properties won't be returned. | |
| 110 | + * | |
| 111 | + * @since 10.1.68 | |
| 112 | + */ | |
| 113 | + $nonePublicProperties = []; | |
| 114 | + $reflection = new ReflectionObject($this); | |
| 115 | + | |
| 116 | + do { | |
| 117 | + $nonePublicProperties = array_merge( | |
| 118 | + $reflection->getProperties(ReflectionProperty::IS_PRIVATE | ReflectionProperty::IS_PROTECTED), | |
| 119 | + $nonePublicProperties | |
| 120 | + ); | |
| 121 | + } while ($reflection = $reflection->getParentClass()); | |
| 122 | + | |
| 123 | + // unset all none public properties, this is needed as get_object_vars returns now all vars | |
| 124 | + // from the current object and not only the CMSObject and the public ones from the inheriting classes | |
| 125 | + foreach ($nonePublicProperties as $prop) | |
| 126 | + { | |
| 127 | + if (array_key_exists($prop->getName(), $vars)) | |
| 128 | + { | |
| 129 | + unset($vars[$prop->getName()]); | |
| 104 | 130 | } |
| 105 | 131 | } |
| 106 | 132 | } |
| 107 | 133 | |