General developer forum

Is it possible to rename a plugin?

 
Me, with my new 'slow explosion' hair!
Is it possible to rename a plugin?
Core developersPlugin developers

I've just been 'given' the plugin I developed for my current employer as they're not going to be using Moodle much longer, so that I can maintain it myself.  One condition was that I remove all references to the company from the plugin, functions and all (which is not a problem as it's not a huge plugin).  Let's say the plugin is called `local_companyplugin`.

I have effectively renamed the plugin to `local_plugin`.  The issue I have is that when I try to upload a new version of the plugin with 'company' removed, the Moodle plugin database is still expecting the plugin to be called `local_companyplugin`, and complains about:

  • Component declared in version.php file: local_plugin does not match the expected component: local_companyplugin
  • Important English language file not found. Searching for file companyplugin/lang/en/local_companyplugin.php
...as it seems that it's expecting `local_companyplugin` as it was originally named.  
So, can I fundamentally rename the plugin, or so I need to deprecate this one and register a new one?

 
Average of ratings: -
Picture of Richard Oelmann
Re: Is it possible to rename a plugin?
Core developersParticularly helpful MoodlersPlugin developersTesters

Might be a silly question, but have you renamed the parent folder? That looks like it's still trying to find files in the folder /companyplugin but can't find them because you've renamed the files themselves and references in them. 

 
Average of ratings: Useful (1)
Me, with my new 'slow explosion' hair!
Re: Is it possible to rename a plugin?
Core developersPlugin developers

Hi Richard.  That's a fair question, and I've missed such things before, but in this case it was automatically pulling the code from GitHub.

Hmm, I've just tagged and uploaded a slightly older version of the plugin (basically the commit before I renamed everything) and that was accepted just fine.  Maybe I should deprecate this plugin and register a new one.

 
Average of ratings: -
Picture of Dan Marsden
Re: Is it possible to rename a plugin?
Core developersMoodle Course Creator Certificate holdersParticularly helpful MoodlersPlugin developersPlugins guardiansTestersTranslators
If you're talking about the Moodle plugins db - then yes you will need to register a new plugin. you can update the description of the old one to point to the new one. You may also want to write some form of upgrade/conversion script to allow people to upgrade from the old plugin to your new one. 


Here's how I managed the change from mod_attforblock to mod_attendance - it might be useful?

https://github.com/danmarsden/moodle-mod_attendance/blob/MOODLE_27_STABLE/version.php#L34

It's a bit nasty and is really an abuse of verison.php but worked ok - I then eventually removed it from version.php

 
Average of ratings: Useful (1)