vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Plugins for Forum Postbit generate errors in CMS? (https://vborg.vbsupport.ru/showthread.php?t=248773)

djbaxter 08-17-2010 12:00 AM

Plugins for Forum Postbit generate errors in CMS?
 
I adapted the Latest Blog Using Carp add-on to vB4 here: https://vborg.vbsupport.ru/showthread.php?t=234254

At the time, I was using only the Forum (CMS and Blog disabled in the Suite) and it worked fine, displaying the title of the latest (external) blog feed in the postbit for any forum post by that member.

The add-on uses two small plug-ins:

1. Carp Configuration, attached to the "global_start" hook location (I realize this should now be changed to global_bootstrap_init_start but doing that makes no difference - I still get the errors).

PHP Code:

require_once '/path/to/forum/carp/carp.php';
CarpConf('carperrors',0);
CarpConf('cacheinterval',120);
/** You may want to set a cachepath specifically for your forum **/
/** CarpConf('cachepath','/path/to/carp_cache/'); **/
/** CarpConf('cacherelative',0); **/
/** You can omit the above two lines without a problem **/
CarpConf('cborder','');
CarpConf('poweredby','');
CarpConf('maxitems',1);
CarpConf('iorder','link');
CarpConf('linktarget',1); 


2. Get Users Blog Entry, attached to postbit_display_start

PHP Code:

ob_start();
CarpCacheShow($post[field6]);
$blogentry ob_get_contents();
ob_end_clean();
vB_Template::preRegister('postbit',array('blogentry' => $blogentry)); 

When I enable CMS, however, I get errors like this depending on which hook I attach the two plgins to:

Quote:

Warning: Invalid argument supplied for foreach() in [path]/includes/class_postbit.php(321) : eval()'d code on line 21

Warning: Invalid argument supplied for foreach() in [path]/includes/class_postbit.php(321) : eval()'d code on line 21

Warning: Invalid argument supplied for foreach() in [path]/includes/class_postbit.php(321) : eval()'d code on line 21

Warning: Invalid argument supplied for foreach() in [path]/includes/class_postbit.php(321) : eval()'d code on line 21
The thing is that this should only function for forum posts anyway. It isn't needed in CMS (or the vBulletin Blog for that matter although I haven't enabled that yet). For me, the errors are seen whenever I try to edit the CMS article or add or edit a comment. Another user who has this installed reported the same problems.

What do I need to do to eliminate these errors?

Lynne 08-17-2010 03:39 AM

If you only want it to work on the showthread page, then wrap the plugin at the global_start location with a THIS_SCRIPT == 'showthread' condition otherwise it is evaled on every single page.

djbaxter 08-17-2010 04:03 AM

Tried this:

PHP Code:

if (THIS_SCRIPT == 'showthread' OR THIS_SCRIPT == 'showpost')
{
require_once 
'/path/to/forum/carp/carp.php'
CarpConf('carperrors',0); 
CarpConf('cacheinterval',120); 
/** You may want to set a cachepath specifically for your forum **/ 
/** CarpConf('cachepath','/path/to/carp_cache/'); **/ 
/** CarpConf('cacherelative',0); **/ 
/** You can omit the above two lines without a problem **/ 
CarpConf('cborder',''); 
CarpConf('poweredby',''); 
CarpConf('maxitems',1); 
CarpConf('iorder','link'); 
CarpConf('linktarget',1);  
}; 


Error:

Quote:

Fatal error: Call to undefined function CarpCacheShow() in /path/to/forum/includes/class_postbit.php(284) : eval()'d code on line 13
And if I wrap both plugins in that conditional, I get:

Quote:

Warning: Invalid argument supplied for foreach() in [path]/includes/class_postbit.php(321) : eval()'d code on line 21

Warning: Invalid argument supplied for foreach() in [path]/includes/class_postbit.php(321) : eval()'d code on line 21

Warning: Invalid argument supplied for foreach() in [path]/includes/class_postbit.php(321) : eval()'d code on line 21

Warning: Invalid argument supplied for foreach() in [path]/includes/class_postbit.php(321) : eval()'d code on line 21

Lynne 08-17-2010 03:10 PM

And where is that function defined? You need to include that file with the function also.

djbaxter 08-17-2010 04:15 PM

What function? I've shown you the entire contents of the plug-ins. The only additional code is in postbit which displays the custom field:

PHP Code:

<!-- latest blog hack for members in good standing only -->
<
vb:if condition="!in_array($bbuserinfo[usergroupid],array(2,20,22,28,30))">
<
vb:if condition="$post['field6']">
<!-- <
span class="smallfont">Recent Blog: <a href="{vb:raw post[field8]}" target="_blank">{vb:raw blogentry}</a></span> -->
<
span class="smallfont">Recent Blog: <a href="{vb:raw post[field8]}" target="_blank">{vb:raw post[field7]}</a></span>
</
vb:if>
</
vb:if>
<!-- 
end latest blog hack for members in good standing only --> 


The referenced line 13 in class_postbit.php in the first error is:

Code:

if (!isset($GLOBALS['vbulletin']->db))
The referenced line 21 in class_postbit.php in is:

Code:

require_once(DIR . '/includes/class_bbcode.php');

djbaxter 08-19-2010 02:22 PM

I'm still unable to get this to stop throwing errors in CMS.

Any suggestions on how to proceed to locate the source of the errors?

Lynne 08-19-2010 02:32 PM

Quote:

Originally Posted by djbaxter (Post 2085360)
What function? I've shown you the entire contents of the plug-ins. The only additional code is in postbit which displays the custom field:

PHP Code:

<!-- latest blog hack for members in good standing only -->
<
vb:if condition="!in_array($bbuserinfo[usergroupid],array(2,20,22,28,30))">
<
vb:if condition="$post['field6']">
<!-- <
span class="smallfont">Recent Blog: <a href="{vb:raw post[field8]}" target="_blank">{vb:raw blogentry}</a></span> -->
<
span class="smallfont">Recent Blog: <a href="{vb:raw post[field8]}" target="_blank">{vb:raw post[field7]}</a></span>
</
vb:if>
</
vb:if>
<!-- 
end latest blog hack for members in good standing only --> 

The referenced line 13 in class_postbit.php in the first error is:

Code:

if (!isset($GLOBALS['vbulletin']->db))
The referenced line 21 in class_postbit.php in is:

Code:

require_once(DIR . '/includes/class_bbcode.php');

That's actually not how you read the error.
Code:

Fatal error: Call to undefined function CarpCacheShow() in  /path/to/forum/includes/class_postbit.php(284) : eval()'d code on line  13
That means, look at line 284 of class_postbit.php which is calling something which then has a problem on line 13. So, line 284 of class_postbit.php is this:
PHP Code:

($hook vBulletinHook::fetch_hook('postbit_display_start')) ? eval($hook) : false

The problem is with line 13 of something being called by that hook location.

But look at the error... "Call to undefined function CarpCacheShow()" A function is being called that doesn't exist on that page. That is why I asked where the function is defined. Cuz wherever that is, you need to make sure that file is included at that point.


Quote:

Originally Posted by djbaxter (Post 2086344)
I'm still unable to get this to stop throwing errors in CMS.

Any suggestions on how to proceed to locate the source of the errors?

You need to do something to make sure those plugins are not called on the CMS page (which is why I was suggesting using THIS_SCRIPT)

djbaxter 08-19-2010 02:46 PM

But see above: I tried using the conditional for THIS_SCRIPT and that didn't help.

Quote:

But look at the error... "Call to undefined function CarpCacheShow()" A function is being called that doesn't exist on that page. That is why I asked where the function is defined. Cuz wherever that is, you need to make sure that file is included at that point.
The function is defined in the second plugin, Get Users Blog Entry, attached to postbit_display_start:

PHP Code:

ob_start(); 
CarpCacheShow($post[field6]); 
$blogentry ob_get_contents(); 
ob_end_clean(); 
vB_Template::preRegister('postbit',array('blogentry' => $blogentry)); 

It simply pulls the information from field6.

Lynne 08-19-2010 02:59 PM

I think I'm misunderstanding something here. You say when you enable the CMS you get those errors, I had assumed you meant on the CMS page, but think I'm wrong. *What* exact page are you getting the errors on?

Are you sure $post[field6] is valid? Try entering something else and see if it works.

And this is not valid - {vb:raw post[field7]} - it's {vb:raw post.field7}

djbaxter 08-19-2010 03:05 PM

Quote:

Originally Posted by Lynne (Post 2086372)
I think I'm misunderstanding something here. You say when you enable the CMS you get those errors, I had assumed you meant on the CMS page, but think I'm wrong. *What* exact page are you getting the errors on?

The errors occur when I try to edit a CMS article or when someone enters a comment.

Quote:

Originally Posted by Lynne (Post 2086372)
Are you sure $post[field6] is valid? Try entering something else and see if it works.

Yes, it's valid. Doublechecked.

Quote:

Originally Posted by Lynne (Post 2086372)
And this is not valid - {vb:raw post[field7]} - it's {vb:raw post.field7}

OK, I'll change that, although it doesn't seem likely that's creating the errors, does it?

--------------- Added [DATE]1282234229[/DATE] at [TIME]1282234229[/TIME] ---------------

Examples of pages with errors:

http://forum.psychlinks.ca/content.p...ew-server/edit

Quote:

Warning: Invalid argument supplied for foreach() in [path]/includes/class_postbit.php(321) : eval()'d code on line 21

Warning: Invalid argument supplied for foreach() in [path]/includes/class_postbit.php(321) : eval()'d code on line 21

Warning: Invalid argument supplied for foreach() in [path]/includes/class_postbit.php(321) : eval()'d code on line 21

Warning: Invalid argument supplied for foreach() in [path]/includes/class_postbit.php(321) : eval()'d code on line 21
http://forum.psychlinks.ca/content/2...ml#new_comment

Quote:

Warning: Invalid argument supplied for foreach() in [path]/includes/class_postbit.php(321) : eval()'d code on line 21

Warning: Invalid argument supplied for foreach() in [path]/includes/class_postbit.php(321) : eval()'d code on line 21T

Warning: Invalid argument supplied for foreach() in [path]/includes/class_postbit.php(321) : eval()'d code on line 21

Warning: Invalid argument supplied for foreach() in [path]/includes/class_postbit.php(321) : eval()'d code on line 21
--------------- Added [DATE]1282235618[/DATE] at [TIME]1282235618[/TIME] ---------------

OK. The errors also show on the actual article page: e.g., http://forum.psychlinks.ca/content/2...ew-server.html

They do NOT show on the CMS Home page.

Other information:

Reported elsewhere and still no fix yet for this - it just occurred to me that it might be related rather than a separate issue: Articles created or promoted from forum threads show as Unpublished although all the correct checks are there to make it Published.


All times are GMT. The time now is 10:10 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01243 seconds
  • Memory Usage 1,811KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (7)bbcode_php_printable
  • (11)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete