View Full Version : Plugin Problem
thunderclap82
07-18-2011, 08:47 PM
I have a plugin working fine on one vB site (running 4.1.2) and when I try implementing the same plugin on another site (4.1.4) it crashes the system with an Internal Error. Here is the actual plug-in code:
The Product is vBulletin, the Hook Location is template_register_var and the Execution Order is 5.
$templater = vB_Template::create('banner_rotator');
$templatevalues['banner_rotator'] = $templater->render();
vB_Template::preRegister('header', $templatevalues);
It references a template I created called banner_rotator.
Like I said, on my vB 4.1.2 site it works fine but on the newer 4.1.4 site it crashes. I was wondering if there was something that vB updated that changes some of this code?
Lynne
07-18-2011, 08:56 PM
Have you tried changing the Execution Order? Do you have any other modifications that use the same hook location? Have you tried disabling your other products (or even going one-by-one) to see if it is a problem between two mods that is causing the error?
I don't see anything obviously wrong with that code you posted.
thunderclap82
07-19-2011, 01:06 AM
I tried changing the execution order to 1 and 10 and neither worked. No other mod uses that hook location, and I've tried disabling all mods as well as their plug-ins.
Is it possible something in the template that the plugin is calling at fault? (I did change the template name that's called in the plugin but that resulted in the same error.)
And here is the exact error message:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@[domain].com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache mod_fcgid/2.3.6 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at www.repairmanjack.com Port 80
And I did check the error log and all I get is:
[Mon Jul 18 21:14:59 2011] [error] [client {IP ADDRESS}] File does not exist: /home/fpaul46/public_html/500.shtml
--------------- Added 1311082958 at 1311082958 ---------------
After some more digging this seems to be the actual error message when trying to activate the plugin:
[19-Jul-2011 00:51:15] PHP Warning: chdir() [<a href='function.chdir'>function.chdir</a>]: No such file or directory (errno 2) in /home/fpaul46/public_html/forum/index.php on line 38
This is the code in index.php:
chdir('./' . VB_RELATIVE_PATH);
Does that help at all?
Lynne
07-19-2011, 05:30 PM
Actually, the full code there is:
// Do not edit.
if (defined('VB_RELATIVE_PATH'))
{
chdir('./' . VB_RELATIVE_PATH);
}
So, did you define VB_RELATIVE_PATH in the code above there? By default, it is commented out, so it shouldn't be defined and that line should never be evaled.
thunderclap82
07-19-2011, 06:12 PM
Actually, the full code there is:
// Do not edit.
if (defined('VB_RELATIVE_PATH'))
{
chdir('./' . VB_RELATIVE_PATH);
}
So, did you define VB_RELATIVE_PATH in the code above there? By default, it is commented out, so it shouldn't be defined and that line should never be evaled.
Nope. It's not defined as the index file in in the forum directory, and not the root.
That seems strange to me - why should something in a plugin affect code in index.php, and how is it even getting there? Maybe an include() or require() is loading the wrong file or something?
Does the same thing happen if you put some totally different code in the plugin?
thunderclap82
07-19-2011, 09:09 PM
That seems strange to me - why should something in a plugin affect code in index.php, and how is it even getting there? Maybe an include() or require() is loading the wrong file or something?
Does the same thing happen if you put some totally different code in the plugin?
I'm really not a programmer, just someone who can usually muddle his way through it. So I have no idea what else I can put in the plugin to test your idea.
I double checked with our host and this is what they said:
From the php code the plugin introduces, the following is causing the error:
$templatevalues['banner_rotator'] = $templater->render();
They asked me to double check the template code (I have) and it's the same as it is on the other site I run.
Lynne
07-19-2011, 10:15 PM
And what is that template code? And are you sure that template exists in that style?
And what happens if you remove line 38 from your index.php page? Then what is the error in your error_log?
thunderclap82
07-19-2011, 11:34 PM
And what is that template code? And are you sure that template exists in that style?
Here is the mod which, incidentally, you helped me with. :) And the template is in the style.
https://vborg.vbsupport.ru/showthread.php?t=252398
And what happens if you remove line 38 from your index.php page? Then what is the error in your error_log?
Same error page appears, but nothing appears in the log.
Lynne
07-20-2011, 01:54 AM
Here is the mod which, incidentally, you helped me with. :) And the template is in the style.
https://vborg.vbsupport.ru/showthread.php?t=252398
But your template doesn't actually look like that unless you left "your URL" and "link to your image file" in there (which you should not have). So, exactly what does your template look like?
thunderclap82
07-20-2011, 01:15 PM
But your template doesn't actually look like that unless you left "your URL" and "link to your image file" in there (which you should not have). So, exactly what does your template look like?
Here is the template code:
<link rel="stylesheet" href="clientscript/nivo-slider.css" type="text/css" media="screen" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="clientscript/jquery.nivo.slider.pack.js" type="text/javascript"></script>
<div id="slider">
<a href="http://www.repairmanjack.com"><img src="http://www.repairmanjack.com/forum/animate_logo/rj_logo00.png" /></a>
<a href="http://www.repairmanjack.com"><img src="http://www.repairmanjack.com/forum/animate_logo/rj_logo01.png" /></a>
<a href="http://www.repairmanjack.com"><img src="http://www.repairmanjack.com/forum/animate_logo/rj_logo02.png" /></a>
<a href="http://www.repairmanjack.com"><img src="http://www.repairmanjack.com/forum/animate_logo/rj_logo00.png" /></a>
<a href="http://www.repairmanjack.com"><img src="http://www.repairmanjack.com/forum/animate_logo/rj_logo03.png" /></a>
<a href="http://www.repairmanjack.com"><img src="http://www.repairmanjack.com/forum/animate_logo/rj_logo04.png" /></a>
<a href="http://www.repairmanjack.com"><img src="http://www.repairmanjack.com/forum/animate_logo/rj_logo00.png" /></a>
<a href="http://www.repairmanjack.com"><img src="http://www.repairmanjack.com/forum/animate_logo/rj_logo05.png" /></a>
<a href="http://www.repairmanjack.com"><img src="http://www.repairmanjack.com/forum/animate_logo/rj_logo.png" /></a>
</div>
<vb:literal>
<script type="text/javascript">
$(window).load(function() {
var total = $('#slider img').length;
var rand = Math.floor(Math.random()*total);
$('#slider').nivoSlider({
effect:'random',
slices:15,
animSpeed:500,
pauseTime:7000,
startSlide:rand,
directionNav:false,
directionNavHide:true,
controlNav:false,
controlNavThumbs:false,
controlNavThumbsFromRel:false,
keyboardNav:true,
pauseOnHover:true,
manualAdvance:false,
captionOpacity:0.8,
beforeChange: function(){},
afterChange: function(){},
slideshowEnd: function(){}
});
});
</script>
</vb:literal>
I also did an experiment where the plugin called a non-existent template. Not sure if an Internal Server Error would normally cause this, but it did.
I tested to make sure - using a non-existent template should just result in a (more or less) empty string.
If you haven't already, maybe try this code:
$templatevalues['banner_rotator'] = "Test Banner Rotator";
vB_Template::preRegister('header', $templatevalues);
I'm not really an expert on these kinds of thing, but based on what I've seen before I'm kind of getting a feeling like it's a problem other than what you're doing, like maybe a php configuration issue or something wrong with the vb installation. Is this a new install of vb? Did you try running "Suspect File Versions" under Maintenance in the adminCP?
thunderclap82
07-20-2011, 03:34 PM
I tested to make sure - using a non-existent template should just result in a (more or less) empty string.
If you haven't already, maybe try this code:
$templatevalues['banner_rotator'] = "Test Banner Rotator";
vB_Template::preRegister('header', $templatevalues);
I'm not really an expert on these kinds of thing, but based on what I've seen before I'm kind of getting a feeling like it's a problem other than what you're doing, like maybe a php configuration issue or something wrong with the vb installation. Is this a new install of vb? Did you try running "Suspect File Versions" under Maintenance in the adminCP?
This is an upgrade to vB 4.1.4 from 3.8.4.
I changed the plugin code and that stopped the Internal Server Error. Not sure why
$templater->render()
was crashing the system, but it seems to have been the cause.
But the images in the slider won't load. Not sure what's up with that, but that's a different problem entirely.
Well, in retrospect I guess that didn't help much since you already knew it was the call to render causing the problem. But taking it out isn't really a fix since you should be able to reder a template there if you want.
thunderclap82
07-20-2011, 03:59 PM
Well, in retrospect I guess that didn't help much since you already knew it was the call to render causing the problem. But taking it out isn't really a fix since you should be able to reder a template there if you want.
Could that rendering command being deleted cause the images not to load? Those are called in the template itself.
Also, should it be
$template->render()
as opposed to
$templater->render()
with emphasis on the r in templater?
Lynne
07-20-2011, 04:24 PM
$templater->render() is correct since that is what he defined.
Try this for preregistering:
vB_Template::preRegister('header', array('templatevalues' => $templatevalues));
And did you already define $templatevalues as an array somewhere?
Lynne
07-20-2011, 04:43 PM
Also, is it *any* template you render via a plugin on that site that causes issues, or just this one? If it is any template, then I would suspect something like mod_security or suhosin to be the problem. Have you run diagnostics > problematic webserver modules?
thunderclap82
07-20-2011, 05:47 PM
Try this for preregistering:
vB_Template::preRegister('header', array('templatevalues' => $templatevalues));
And did you already define $templatevalues as an array somewhere?
I added that line but it didn't fix the problem. And I haven't definre $templatevalues as an array anywhere.
Also, is it *any* template you render via a plugin on that site that causes issues, or just this one? If it is any template, then I would suspect something like mod_security or suhosin to be the problem. Have you run diagnostics > problematic webserver modules?
Nope... just this plugin. And our host said that mod_security was blocking it but they whitelist it for us.
Problematic Webserver pops up with No to "Module Loaded" and "AJAX Unicode Issue".
--------------- Added 1311209342 at 1311209342 ---------------
Just a minor update. When I add your code:
vB_Template::preRegister('header', array('templatevalues' => $templatevalues));
This is the error I get:
Fatal error: Call to a member function render() on a non-object in /home/fpaul46/public_html/forum/includes/class_core.php(4257) : eval()'d code on line 2
thunderclap82
07-21-2011, 09:03 PM
No other ideas?
Ah, yeah, I can't believe I didn't think of this before, but did you try a different hook location, like maybe parse_templates? The one you're using is actually in the vB_Template code and is called when a variable is registered, so that could be causing strange things to happen.
thunderclap82
07-21-2011, 11:59 PM
Ah, yeah, I can't believe I didn't think of this before, but did you try a different hook location, like maybe parse_templates? The one you're using is actually in the vB_Template code and is called when a variable is registered, so that could be causing strange things to happen.
Bingo! That did it. Thank you very much for all your help in this matter!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.