Jump to content

[SOLVED] Odd singleton error


Recommended Posts

I decided to download Google Chrome to see how it handled some light AJAX stuff.  I decided to navigate to a small test script I wrote a while ago.  It was working fine, and I haven't touched its source code in months.  It's basically a test of the Front Controller in Zandstra's book with a tidbit of AJAX on top.  Nothing particularly useful outside of a learning exercise for myself.


In any event, I'm now getting the following error:

Fatal error: Call to private MP_base_Registry::__construct() from context 'MP_base_RequestRegistry' in /home/nights/www/www/MP/base/RequestRegistry.php5 on line 8


The line in question is pretty innocent looking (for those who read through the coding style thread in the Polls section, this is my old coding style, which should illustrate how old this is):

   class MP_base_RequestRegistry extends MP_base_Registry{
      private static $instance;
      private $requests = array();

      static function getInstance(){
            self::$instance = new self(); // <-- line in question

         return self::$instance;

      protected function get($key){
         return self::$instance->requests[$key];

      protected function set($key, $value){
         self::$instance->requests[$key] = $value;

      static function getRequest(){
         return self::$instance->get('request');

      static function setRequest(MP_controller_Request $request){
         self::$instance->set('request', $request);


And the base class, for poops and giggles:

   abstract class MP_base_Registry{
      private function __construct(){}
      abstract protected function get($key);
      abstract protected function set($key, $value);


Looking over the news items my hosting company has sent out, it doesn't look like they changed anything on the backend that should effect this, and I never attempt to directly call the abstract registry class at all anywhere in these, or other, files.  I'm a bit stumped.


Link to comment
Share on other sites

Declare the constructor protected and the problem goes away.


There we go...had to do the same with the session registry, too.  I could've sworn it was working before, though.  I wonder if the upgrade to 5.2.6 a couple months ago caused it to break (or, looking at it now, behave properly)?


In any event, thanks. :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.