[pLog-svn] r5388 - plog/branches/lifetype-1.2/class/action/admin

Oscar Renalias oscar at renalias.net
Fri May 11 13:59:53 EDT 2007


By looking at my own comments in the PluginBase class, this is what  
it says about it:

	         * This function is called only once when the plugin is  
registered. Please use this method
		 * in case your plugin needs to perform some initializations before  
it is used, specially
		 * if the initialization process requires access to the plugin/blog  
settings (because the
		 * BlogInfo and UserInfo objects are not available in the  
constructor *yet* so this method
		 * will be called once they are available)

So if the plugin needs to attach to an event, it must be done right  
away in the constructor and not in the register() method. The only  
reason why you might need to use the register() method instead of the  
constructor is because you need to access any of the properties of  
the BlogInfo and/or UserInfo objects and you can't do it later on in  
your process() or whatever other method your method implements.

Now if some plugins moved some of their initialization stuff to the  
register() method and expected it to be called right away, there's  
nothing we can do if they misused the API :-)

Hopefully this is what you needed to know!

On 11 May 2007, at 10:28, Jon Daley wrote:

>  	No, it still doesn't really work.  reverting to 5387 causes the
> tagcloud to not be recreated because the register was never called  
> prior
> to the process.
>  	If I change $plugMgr=&getPluginMananger... to skip that but
> instead use the already created $this->_pm it still doesn't work,  
> though
> if I add in a $this->_pm->getPlugins() then it does, because that  
> calls
> register.  However, the order that the plugin gets called is a  
> little odd.
>  	On a temp cleanup, I get a
> register()
> process() on a class that didn't have register called on him
> process() that did have register called previously
> register()
>
> So, that isn't really the best thing either, though if you only  
> look at
> the output, it would appear to do the right thing.
>
>  	My guess is this has been this way for a long time, and that is
> why the plugin authors have been adding register() to their code,  
> and no
> one ever happened to mention it before.
>
> On Fri, 11 May 2007, Jon Daley wrote:
>
>> 	Ah, I see.  I am only looking at one blog at the moment.  I'll see
>> if putting it back will now call register for us.
>>
>> On Fri, 11 May 2007, Oscar Renalias wrote:
>>
>>> I don't think your change does what you think it does :)
>>>
>>> The idea of the original code is to process the
>>> EVENT_POST_ADMIN_PURGE_TEMP_FOLDER event using each one of the  
>>> active
>>> blogs in the system. For that reason we need to call
>>> PluginBase::setBlogInfo() every time within the loop, so that the
>>> plugin has the right blog in its context, otherwise the event is
>>> thrown and processed only by the current blog.
>>>
>>> On 5/11/07, jondaley at devel.lifetype.net  
>>> <jondaley at devel.lifetype.net> wrote:
>>>> Author: jondaley
>>>> Date: 2007-05-10 23:21:41 -0400 (Thu, 10 May 2007)
>>>> New Revision: 5388
>>>>
>>>> Modified:
>>>>    plog/branches/lifetype-1.2/class/action/admin/ 
>>>> admincleanupaction.class.php
>>>> Log:
>>>> as long as we call notifyEvent *after* setCommonData, the plugin  
>>>> manager is already setup for us
>>>>
>>>> Modified: plog/branches/lifetype-1.2/class/action/admin/ 
>>>> admincleanupaction.class.php
>>>> ===================================================================
>>>> --- plog/branches/lifetype-1.2/class/action/admin/ 
>>>> admincleanupaction.class.php  2007-05-11 03:20:21 UTC (rev 5387)
>>>> +++ plog/branches/lifetype-1.2/class/action/admin/ 
>>>> admincleanupaction.class.php  2007-05-11 03:21:41 UTC (rev 5388)
>>>> @@ -177,16 +177,7 @@
>>>>
>>>>                         $blogs = new Blogs();
>>>>                 $activeBlogs = $blogs->getAllBlogs 
>>>> ( BLOG_STATUS_ACTIVE );
>>>> -            // Get the plugin manager
>>>> -            $plugMgr =& PluginManager::getPluginManager();
>>>>
>>>> -               foreach( $activeBlogs as $blogInfo ) {
>>>> -                   $plugMgr->setBlogInfo( $blogInfo);
>>>> -                   $plugMgr->loadPlugins( "admin" );
>>>> -                   // Send the  
>>>> EVENT_POST_ADMIN_PURGE_TEMP_FOLDER message
>>>> -                   $plugMgr->notifyEvent 
>>>> ( EVENT_POST_ADMIN_PURGE_TEMP_FOLDER );
>>>> -               }
>>>> -
>>>>                         $this->_message = $this->_locale->tr 
>>>> ( "temp_folder_reset_ok" );
>>>>
>>>>                         return true ;
>>>> @@ -232,6 +223,9 @@
>>>>
>>>>                         $this->setCommonData();
>>>>
>>>> +            if($this->_op == "cleanupTemp")
>>>> +                $this->notifyEvent 
>>>> (EVENT_POST_ADMIN_PURGE_TEMP_FOLDER );
>>>> +
>>>>                         return true;
>>>>                 }
>>>>         }
>>>>
>>>> _______________________________________________
>>>> pLog-svn mailing list
>>>> pLog-svn at devel.lifetype.net
>>>> http://limedaley.com/mailman/listinfo/plog-svn
>>>>
>>> _______________________________________________
>>> pLog-svn mailing list
>>> pLog-svn at devel.lifetype.net
>>> http://limedaley.com/mailman/listinfo/plog-svn
>>>
>>
>> -- 
>> Jon Daley
>> http://jon.limedaley.com/
>>
>> Faith is a simple trust in a personal redeemer.
>> The simpler our trust in Christ for all things, the surer our peace.
>> -- William Adams
>> _______________________________________________
>> pLog-svn mailing list
>> pLog-svn at devel.lifetype.net
>> http://limedaley.com/mailman/listinfo/plog-svn
>>
>
> -- 
> Jon Daley
> http://jon.limedaley.com/
>
> To be upset over what you don't have is to waste what you do have.
> -- Unknown
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://limedaley.com/mailman/listinfo/plog-svn
>



More information about the pLog-svn mailing list