# #45351: Exception::getTrace() should return 'object' array-element

- Thread: https://externals.io/message/48755
- Original archive: https://news-web.php.net/php.internals/48755
- Started by Jille Timmermans on 2010-06-13T11:16:49+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #48755 — Jille Timmermans — 2010-06-13T11:16:49+00:00

URL: https://externals.io/message/48755#48755

http://bugs.php.net/45351

I have attached a patch to the feature request. IIRC I should just ask
here whether someone is willing to commit it. So, anyone willing to help
me? :)


-- Jille

---

## #48756 — Kalle Sommer Nielsen — 2010-06-13T13:05:12+00:00

URL: https://externals.io/message/48755#48756 · In reply to: #48755

Hello Jille

2010/6/13 Jille Timmermans <jille@quis.cx>:
> http://bugs.php.net/45351
>
> I have attached a patch to the feature request. IIRC I should just ask
> here whether someone is willing to commit it. So, anyone willing to help
> me? :)

The patch is incorrect (according to what the user requests, and for
consistency with `debug_backtrace()`). What the patch should do is to:

1) Add a new parameter to the arginfo, so reflection can pick this new
parameter up, named provide_object
2) Alter the implementation of Exception::getTrace(),
::getTraceAsString() and possibly also ::__toString() so it sends to
the proper parameters to the function that builds the trace
array/string

If you simply change the 0 to 1, then it will be forced every time,
and without looking closer to the implementation i can imagine it
could cause some unwanted overheat if its not used, or lookup time.

-- 
regards,

Kalle Sommer Nielsen
kalle@php.net

---

## #48757 — Jille Timmermans — 2010-06-13T16:10:01+00:00

URL: https://externals.io/message/48755#48757 · In reply to: #48756

Hello Kalle,

First of all, thanks for yor feedback!

Kalle Sommer Nielsen schreef:
> Hello Jille
> 
> 2010/6/13 Jille Timmermans <jille@quis.cx>:
> > […]
> 
> The patch is incorrect (according to what the user requests, and for
> consistency with `debug_backtrace()`). What the patch should do is to:
> 
> 1) Add a new parameter to the arginfo, so reflection can pick this new
> parameter up, named provide_object
I succeeded with that part.
> 2) Alter the implementation of Exception::getTrace(),
> ::getTraceAsString() and possibly also ::__toString() so it sends to
> the proper parameters to the function that builds the trace
> array/string
The trace is generated at the construction of the exception; because we
don't know whether getTrace() will get called with provide_object we
need to save it anyway.
I have tried to alter ::getTrace() to remove the 'object' key from the
stack frames if provide_object was given as false. Unfortunately I
didn't succeed there. (I don't know much of the internals; and after
playing around calling 'random' functies I decided the patch I would
create wouldn't be perfect anyway.) So I trashed the parts I was
uncertain of and built the following diff:
  http://junk.quis.cx/XlUKZqbe/zend_exceptions.diff

If someone has time and is willing to finish the patch, please go for
it. (Or instructing me how to do it; but I assume that will take more time.)

-- Jille
> 
> If you simply change the 0 to 1, then it will be forced every time,
> and without looking closer to the implementation i can imagine it
> could cause some unwanted overheat if its not used, or lookup time.
