Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 03-07-2013, 03:57 AM
dwooding dwooding is offline
 
Join Date: Jul 2009
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Call to undefined function fetch_phrase

I'm using a custom php script to create users in VBulletin 4.x. The scripts calls core VBulletin files, ex - require_once(CWD . '/includes/class_core.php');.

Unfortunately, when a username already exists, the script throws a fatal error:

Quote:
Fatal error: Call to undefined function fetch_phrase() in /home/xxxxx/public_html/members/includes/functions.php on line 4030
Line 4030 in the functions looks like this:

Code:
	// API only needs error phrase name and args.
	if (defined('VB_API') AND VB_API === true)
	{
		return $args;
	}

	$args[0] = fetch_phrase($args[0], 'error', '', false);   // line 4030
	if (sizeof($args) > 1)
	{
		return call_user_func_array('construct_phrase', $args);
	}
	else
	{
		return $args[0];
	}
Of course, the fetch_phrase function does exist, in /includes/functions_misc.php.

Within functions.php, the only time I see the fetch_phrase function get loaded is within the print_standard_redirect function

Code:
			if (!function_exists('fetch_phrase'))
			{
				require_once(DIR . '/includes/functions_misc.php');
			}
My take after looking around the functions.php file is that when an error occurs, there is an attempt to redirect ????

Given what I have shown, any idea on why I'm getting the "Call to ?" error message.

I'm using vBulletin 4.2.0 Patch Level 2.

Thanks.

Dave

Other related posts:

http://www.vbulletin.com/forum/forum...php-line-3518?

https://vborg.vbsupport.ru/showthrea...t=fetch_phrase
Reply With Quote
  #2  
Old 03-07-2013, 12:23 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It seems strange that someone else was getting that error on the same line, but I don't understand why a missing phrase would be the problem.

I have the code for version 4.2.0PL2, and I have this code at line 4008:
Code:
if (!function_exists('fetch_phrase') AND !VB_API)
{
	require_once(DIR . '/includes/functions_misc.php');
}
It seems to me that the only way that could not load is if your script was defining VB_API as something other than 'true' (or if fetch_phrase was already loaded, of course).

In any case, if it were me, I'd put in some debug statements. For example, I'd probably put a die() right before the require_once and see if it's getting there at all. Or maybe comment out the 'if' line and the closing } and so it's always included, and see if that fixes it. (Of course those changes are just temporary, you'd remove them after you see what happens).
Reply With Quote
  #3  
Old 03-07-2013, 01:35 PM
ForumsMods ForumsMods is offline
 
Join Date: Aug 2007
Location: Argentina
Posts: 667
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You need to add this to your code:
PHP Code:
define('VB_API'false); 
Reply With Quote
Благодарность от:
kh99
  #4  
Old 03-07-2013, 01:39 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ForumsMods View Post
You need to add this to your code:
PHP Code:
define('VB_API'false); 
Yeah, that makes sense. That's done in init.php, but it could be that his script isn't including that.
Reply With Quote
  #5  
Old 03-07-2013, 02:13 PM
ForumsMods ForumsMods is offline
 
Join Date: Aug 2007
Location: Argentina
Posts: 667
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes.
This will always return false: !VB_API, because VB_API is not defined.
It is defined in includes/init.php which is included in includes/class_bootstrap.php and this is included in global.php.
And because he is not including any of the above files, VB_API is not defined.
Reply With Quote
  #6  
Old 03-07-2013, 02:21 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ForumsMods View Post
And because he is not including any of the above files, VB_API is not defined.
Oh right - I missed the first line where it said he was including class_core.php, and assumed he must be including global.php.
Reply With Quote
  #7  
Old 03-08-2013, 02:05 AM
dwooding dwooding is offline
 
Join Date: Jul 2009
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You're great! Works perfect. Thanks. Dave
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:29 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07523 seconds
  • Memory Usage 2,225KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (2)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (1)post_thanks_box_bit
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete