vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   setting function pointers, need syntax (https://vborg.vbsupport.ru/showthread.php?t=155123)

Jakeman 08-13-2007 04:48 PM

setting function pointers, need syntax
 
I am in the process of updating my custom scripts for 3.6.x. Some pages generate this error:

print_standard_error(...)
is now redundant. Instead, use
standard_error(fetch_error(...))


My errors messages are hard-coded strings. They don't use the phrase system, so I don't think I need fetch_error(). I just need to map print_standard_error() to standard_error().

What is the code to point the old function to the new one so I don't have to change the references? I don't know the syntax.

Opserty 08-13-2007 05:40 PM

standard_error('This is the error message') works I think.

nico_swd 08-13-2007 05:44 PM

standard_error (line 2366)

Halts execution and shows the specified error message
void standard_error ([string $error = ''], [string $headinsert = ''], [boolean $savebadlocation = true], [string $override_template = ''])
  • string $error: Error message
  • string $headinsert: Optional HTML code to insert in the <head> of the error page
  • boolean $savebadlocation: If true, set the visitor's status on WOL to error page
  • string $override_template: Optional template to force the display to use. Ignored if showing a lite error


http://members.vbulletin.com/api/vBu...tions_php.html

Jakeman 08-13-2007 06:03 PM

I know how to use the function. I have references to the old function name in my scripts. I want to change the pointers to use the new function without modifying the references in the code. See my post.

For example, I added this to a plugin in the global scope:

$DB_site =& $vbulletin->db;

This makes it so the references to the old $DB_site variable now refer to the new $vbulletin class so I don't have to change every instance of $DB_site within my code.

I want to do a similar thing for the references to the old print_standard_error() function.

nico_swd 08-13-2007 06:26 PM

As far as I know, there's no way to override functions in PHP. But isn't the point of updating changing your code?

You could do a batch search and replace...

http://www.abacre.com/afr/


It would take 2 seconds to update all your code. Unless you have a specific reason for not wanting to replace?

Jakeman 08-13-2007 06:41 PM

Because it's easier to change pointers if possible.

Opserty 08-13-2007 07:06 PM

You can't redefine functions in PHP as far as I am aware so I don't think it is possible. Haven't tested though but I don't think it would work.

Adrian Schneider 08-13-2007 07:38 PM

You can't redefine functions in PHP, so edit print_standard_error() in functions.php to work with your old code.

Paul M 08-13-2007 10:02 PM

I think all you will need to do is comment out the 'die' statement in the existing print_standard_error() - in functions.php (not tested).


All times are GMT. The time now is 02:55 PM.

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.01192 seconds
  • Memory Usage 1,725KB
  • 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
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete