Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
a9e71d55
Commit
a9e71d55
authored
Aug 23, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better handling with exceptions in __toString()
parent
528f8c82
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
Response.php
framework/yii/web/Response.php
+1
-1
ActiveField.php
framework/yii/widgets/ActiveField.php
+8
-1
No files found.
framework/yii/web/Response.php
View file @
a9e71d55
...
@@ -781,7 +781,7 @@ class Response extends \yii\base\Response
...
@@ -781,7 +781,7 @@ class Response extends \yii\base\Response
if
(
is_array
(
$this
->
content
))
{
if
(
is_array
(
$this
->
content
))
{
$this
->
content
=
'array()'
;
$this
->
content
=
'array()'
;
}
elseif
(
is_object
(
$this
->
content
))
{
}
elseif
(
is_object
(
$this
->
content
))
{
$this
->
content
=
method_exists
(
$this
->
content
,
'__toString'
)
?
(
string
)
$this
->
content
:
get_class
(
$this
->
content
);
$this
->
content
=
method_exists
(
$this
->
content
,
'__toString'
)
?
$this
->
content
->
__toString
()
:
get_class
(
$this
->
content
);
}
}
}
}
}
}
framework/yii/widgets/ActiveField.php
View file @
a9e71d55
...
@@ -128,7 +128,14 @@ class ActiveField extends Component
...
@@ -128,7 +128,14 @@ class ActiveField extends Component
*/
*/
public
function
__toString
()
public
function
__toString
()
{
{
return
$this
->
render
();
// __toString cannot throw exception
// use trigger_error to bypass this limitation
try
{
return
$this
->
render
();
}
catch
(
\Exception
$e
)
{
trigger_error
(
$e
->
getMessage
());
return
''
;
}
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment