Jump to content

MT Activity Log Plugin Errors


thejerm

Recommended Posts

In my movabletype activity log I am recieving hundreds of "plugin error messages" examples below:

 

>Plugin error: /home/uusername/public_html/cgi-bin/mt/plugins/BookQueueToo/BookQueueToo.pl Can't locate MTPlugins/BookQueueToo.pm in @INC (@INC contains: /home/uusername/public_html/cgi-bin/mt/plugins/spamlookup/plugins/BookQueueToo/lib plugins/Protect/lib ./p

 

>Plugin error: /home/uusername/public_html/cgi-bin/mt/plugins/Protect/Protect.pl Can't locate Protect/CMS.pm in @INC (@INC contains: plugins/Protect/lib ./plugins/Blogroll/lib plugins/Blacklist/lib /home/uusername/public_html/cgi-bin/mt/extlib /home/uusername/pu

 

>Plugin error: /home/uusername/public_html/cgi-bin/mt/plugins/Blogroll/Blogroll.pl Can't locate Blogroll/Blogroll.pm in @INC (@INC contains: ./plugins/Blogroll/lib plugins/Blacklist/lib /home/uusername/public_html/cgi-bin/mt/extlib /home/uusername/public_html/cg

 

 

Does anyone know what are causing these messages, I belive they started after I upgraded to 3.16 but not sure. I am running spamlookup, mt-protect, mt-blogroll, BookQueueToo, mt-amazon....

Link to comment
Share on other sites

I have no doubt that these error messages started after you upgraded to MT 3.16, but the errors are actually being caused by one or more plugins you have installed. Some plugins make erroneous assumptions about where they are installed relative to the script that is currently running, and thus cause the wrong directories to be searched for library files.

 

The key to correcting these errors is finding the code where a plugin is specifying an incorrect library path (usually a relative one), and replacing that path with a full server path (a path from /).

 

Your list of installed plugins does not appear to be complete:

I am running spamlookup, mt-protect, mt-blogroll, BookQueueToo, mt-amazon....

...so I don't know if what I'm going to tell you will fix all of the errors or not. In the instructions below, be sure to replace 'cpanelName' with your actual CPanel username.

 

MT-Protect: In plugins/Protect/Protect.pl, you should see the following around line 9:

>use lib File::Spec->catdir('plugins','Protect','lib');

Comment out that line by typing a "#" at the beginning of the line, and insert the line as shown below right after that line:

># use lib File::Spec->catdir('plugins','Protect','lib');
use lib /home/cpanelName/public_html/cgi-bin/mt/plugins/Protect/lib;

 

MT-Blogroll: In plugins/Blogroll/Blogroll.pl, you should see the following around line 8:

>if (eval { use lib './plugins/Blogroll/lib'; 1 }) {
 use lib './plugins/Blogroll/lib';
}

Comment out all 3 lines by typing a "#" at the beginning of each line, and insert the line as shown below right after the last line:

># if (eval { use lib './plugins/Blogroll/lib'; 1 }) {
#   use lib './plugins/Blogroll/lib';
# }
use lib /home/cpanelName/public_html/cgi-bin/mt/plugins/Blogroll/lib;

 

BookQueueToo: In plugins/BookQueueToo/BookQueueToo.pl, you should see the following around line 12:

>use lib File::Spec->catdir(abs_path(dirname($0)),'plugins','BookQueueToo','lib');

Comment out that line by typing a "#" at the beginning of the line, and insert the line as shown below right after that line:

># use lib File::Spec->catdir(abs_path(dirname($0)),'plugins','BookQueueToo','lib');
use lib /home/cpanelName/public_html/cgi-bin/mt/plugins/BookQueueToo/lib;

 

I noticed that you have MT-Blacklist installed, and it produces errors like the above unless it is fixed also. In plugins/Blacklist/Blacklist.pl, you should see the following around line 20:

>use lib 'plugins/Blacklist/lib';

Comment out that line by typing a "#" at the beginning of the line, and insert the line as shown below right after that line:

># use lib 'plugins/Blacklist/lib';
use lib /home/cpanelName/public_html/cgi-bin/mt/plugins/Blacklist/lib;

 

If you are using MT-Moderate along with the SpamLookup plugin, MT-Moderate needs to be fixed too. In plugins/jayseae/moderate.pl, you should see the following around line 30:

>if (eval { use lib './plugins/jayseae/lib'; 1 }) {
 use lib './plugins/jayseae/lib';
}

Comment out all 3 lines by typing a "#" at the beginning of each line, and insert the line as shown below right after the last line:

># if (eval { use lib './plugins/jayseae/lib'; 1 }) {
#   use lib './plugins/jayseae/lib';
# }
use lib /home/cpanelName/public_html/cgi-bin/mt/plugins/jayseae/lib;

 

The above changes should make most of your plugin errors go away (if not all of them). :)

Link to comment
Share on other sites

That looks like it took you a long time, hope I wasnt to much trouble.

You were not too much trouble - that's why we're here. ;) But it did take a while to research the code on 7 different plugins (4 of which I don't use and didn't have a copy of), then document the changes to 5 of them. :)

 

I am guessing there is an error in some of the 3.16 code?

No, it is not an error in the MT 3.16 code. As I said:

Some plugins make erroneous assumptions about where they are installed relative to the script that is currently running,...
...the problem is with the code in each of the plugins I had you fix. If it was a problem with the MT 3.16 code, I would have shown you how to fix that instead. :dance:

 

Thanks David that fixed all the problems. 

Glad to hear they're all fixed and that there's no stragglers. :clapping:

Link to comment
Share on other sites

Actually from what I hear it is a problem with MT, I've tried several methods of the use lib line and only one prevents the error, that one method is what David's instructed you to do which is to use a full path to lib. I'm not sure how we can do that from a plugin POV.

Link to comment
Share on other sites

Actually from what I hear it is a problem with MT, I've tried several methods of the use lib line and only one prevents the error, that one method is what David's instructed you to do which is to use a full path to lib. I'm not sure how we can do that from a plugin POV.

The current design of MT3 allows for the running of MT code to begin from more than one directory. The standard MT scripts (such as mt.cgi, mt-comments.cgi, and mt-tb.cgi) start running their code from the main MT installation directory. Plugins may have their own *.cgi scripts located in the MT/plugins/<PluginName> directory where they are installed.

 

MT initializes all plugins when any MT cgi script or plugin cgi script is run, which includes the setting of library paths requested by plugins. The reason why using relative directory paths to identify a plugin's lib directory doesn't work is because the "current working directory" could be 1) the main MT directory, 2) the plugin's main installation directory where its own cgi script is installed and currently running, or 3) another plugin's main installation directory, where *it's* cgi script is installed and currently running. There is no relative path that a plugin can specify that will result in the same, correct directory path in all 3 cases.

 

Take an example from your own plugin, MT-Protect. The current code you have evaluates to the following statement:

>use lib plugins/Protect/lib;

If a main MT script is running, MT will look for MT-Protect's lib directory here...

><MT_dir>/plugins/Protect/lib;

...which is correct.

 

If MT-Protect's cgi script is running, MT will look for MT-Protect's lib directory here...

><MT_dir>/plugins/Protect/plugins/Protect/lib

...which is not correct, and you got around that issue by adding the following to MT-Protect's cgi script:

>use lib 'lib';

If another plugin's cgi script is running, let's say MT-Blacklist for example, MT will look for MT-Protect's lib directory here:

><MT_dir>/plugins/Blacklist/plugins/Protect/lib

In this case, the user will see a plugin error whenever they run MT-Blacklist (or any other plugin's cgi script).

 

The only sure way to specify a consistent library path, no matter what cgi script is running, is to use an absolute one. This is not a problem with MT, unless you consider MT3's plugin architecture to be a problem (which I do not).

 

To get an absolute path to a plugin's lib directory, a plugin must be able to at least determine the absolute path to the main MT directory. Once you have that, completing the path to the plugin's lib directory is easy.

 

A plugin could do a bunch of backflips in its own code to try to find the MT directory and determine the absolute path to it, but this isn't necessary. Before plugins are initialized, an MT object is initialized and the absolute path to MT is stored in this object (MT->{mt_dir}) All you need to do is access the MT object and get the absolute path to the main MT directory from it.

 

Assuming MT versions >= 3.1, your plugin code could specify an absolute library path with just the following two lines of code:

>require File::Spec;
use lib File::Spec->catdir(MT->instance->{mt_dir}, 'plugins', 'Protect', 'lib');

MT versions prior to 3.1 don't support the instance() method, so you'd have to come up with an alternate method if you intend for your code to run on older versions of MT.

 

The above code is not thoroughly tested, although I did test it on my install of MT-Blacklist, and it appears to be working fine. Seems like a workable solution to me. :thumbup1:

Link to comment
Share on other sites

Ahh I didn't know about the instance() thing, thanks for the heads up. I can't be bothered with MT versions prior to 3.1 really (most of the code relies on stuff from 3.0+ and if people are still on 3.0x then god help them!)

Link to comment
Share on other sites

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...