Skip to content
This repository was archived by the owner on Jul 17, 2020. It is now read-only.

Commit b791192

Browse files
committed
Fix UploadTrait::getFileUploadPropertyName for Doctrine proxy entity
1 parent 303b4e0 commit b791192

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

Model/UploadTrait.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function getFileUploads()
5151
*/
5252
public function setFileUpload(UploadedFile $file = null)
5353
{
54-
$propertyName = $this->getFileUploadPropertyName();
54+
$propertyName = $this->getFileUploadPropertyName(__FUNCTION__);
5555

5656
unset($this->fileUploads[$propertyName]);
5757
if ($file instanceof UploadedFile) {
@@ -74,8 +74,14 @@ public function setFileUploadPath($directory)
7474
*
7575
* @return string
7676
*/
77-
private function getFileUploadPropertyName()
77+
private function getFileUploadPropertyName($realCallerMethod)
7878
{
79-
return lcfirst(substr(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)[1]['function'], 3, -6));
79+
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
80+
$callerMethodName = $backtrace[1]['function'];
81+
if ($callerMethodName === $realCallerMethod) {
82+
$callerMethodName = $backtrace[2]['function'];
83+
}
84+
85+
return lcfirst(substr($callerMethodName, 3, -6));
8086
}
8187
}

0 commit comments

Comments
 (0)