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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
1 deletion
+8
-1
Response.php
framework/yii/web/Response.php
+1
-1
ActiveField.php
framework/yii/widgets/ActiveField.php
+7
-0
No files found.
framework/yii/web/Response.php
View file @
a9e71d55
...
...
@@ -781,7 +781,7 @@ class Response extends \yii\base\Response
if
(
is_array
(
$this
->
content
))
{
$this
->
content
=
'array()'
;
}
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
*/
public
function
__toString
()
{
// __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