# Cannot register classes after MINIT

- Thread: https://externals.io/message/49765
- Original archive: https://news-web.php.net/php.internals/49765
- Started by Jeff Brown on 2010-09-18T20:01:11+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

---

## #49765 — Jeff Brown — 2010-09-18T20:01:11+00:00

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

I have recently tried registering a class (via zend_register_class) inside of a PHP_FUNCTION, though this may sound weird and an unecessary function I ask that you ignore this request.I have noticed that registering goes fine but every time I declare a class after the call to my function, e.g:create_class_function('class_name');class Test { }
My PHP process crashes, not declaring the Test classes causes no crash, I also noticed that If I move my code to the MINIT part no crash occurs and all goes well as with other PHP extensions.
That got me wondering as to what was causing the crash and if it is indeed not possible to register classes after module & request init (no matter the reason for the registration), if there is a way after all I would like to know about it but I mostly wonder as to why this is not possible.
Thank you

---

## #49767 — johannes@schlueters.de — 2010-09-19T16:51:56+00:00

URL: https://externals.io/message/49765#49767 · In reply to: #49765

> I have recently tried registering a class (via zend_register_class)
> inside of a PHP_FUNCTION, though this may sound weird and an
> unecessary function I ask that you ignore this request.I have noticed
> that registering goes fine but every time I declare a class after the
> call to my function, e.g:create_class_function('class_name');class
> Test { }
> My PHP process crashes, not declaring the Test classes causes no
> crash, I also noticed that If I move my code to the MINIT part no
> crash occurs and all goes well as with other PHP extensions.

I have no idea why it crashes, but in general there are a few
assumptions around "built in" classes, like not freeing them on request
shutdown etc.

Adding them at run time really is no good idea ...

johannes

---

## #49768 — Jeff Brown — 2010-09-19T19:00:29+00:00

URL: https://externals.io/message/49765#49768

What differentiates user declared classes from "built in" classes? I am not sure whether 'extension' defined classes (PDO for example) are what you consider "built in", but to better understand, is there some special treatment PHP gives classes defined in a certain manner (like those defined at the MINIT stage)? If you could elaborate that would help me greatly.
Furthermore I have decided with the kind help of the #php.pecl people (some of them are here I guess) to debug PHP (thank god for --enable-debug) and see what goes on, will let you know if I find anything.
Thanks :D

> From: johannes@schlueters.de
> To: jb_jeff@hotmail.com
> CC: internals@lists.php.net
> Date: Sun, 19 Sep 2010 18:51:56 +0200
> Subject: Re: [PHP-DEV] Cannot register classes after MINIT
> 
> 
> > […]
> 
> I have no idea why it crashes, but in general there are a few
> assumptions around "built in" classes, like not freeing them on request
> shutdown etc.
> 
> Adding them at run time really is no good idea ...
> 
> johannes
