Fatal error: Cannot redeclare make_clickable()

Discussion forum for MOD Writers regarding MOD Development.
Locked
sammybeats
Registered User
Posts: 8
Joined: Mon Jun 07, 2010 3:25 pm

Fatal error: Cannot redeclare make_clickable()

Post by sammybeats »

I've searched through all sorts of forums including this one for the answer to this question and I couldn't find it. My forum at beatmatters.com/forum was working fine until I purged the cache earlier today. Now when I try to go there all I get is a white screen with:

Fatal error: Cannot redeclare make_clickable() (previously declared in /xxx/xxxx/xxxx/forum/includes/functions_content.php:643) in /xxx/xxxx/xxxx/wp-includes/formatting.php on line 1373

I've read and reread the install directions. Here is my code for includes/functions_content.php

Code: Select all

if (!function_exists('make_clickable'))
{
function make_clickable($text, $server_url = false, $class = 'postlink')
{
		global $IN_WORDPRESS;
	if ($IN_WORDPRESS)
	{
		return wp_make_clickable($text); //WP version
	} else {//phpBB version 
	if ($server_url === false)
	{
		$server_url = generate_board_url();
	}

	static $magic_url_match;
	static $magic_url_replace;
	static $static_class;

	if (!is_array($magic_url_match) || $static_class != $class)
	{
		$static_class = $class;
		$class = ($static_class) ? ' class="' . $static_class . '"' : '';
		$local_class = ($static_class) ? ' class="' . $static_class . '-local"' : '';

		$magic_url_match = $magic_url_replace = array();
		// Be sure to not let the matches cross over. ;)

		// relative urls for this board
		$magic_url_match[] = '#(^|[\n\t (>.])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#ie';
		$magic_url_replace[] = "make_clickable_callback(MAGIC_URL_LOCAL, '\$1', '\$2', '\$3', '$local_class')";

		// matches a xxxx://aaaaa.bbb.cccc. ...
		$magic_url_match[] = '#(^|[\n\t (>.])(' . get_preg_expression('url_inline') . ')#ie';
		$magic_url_replace[] = "make_clickable_callback(MAGIC_URL_FULL, '\$1', '\$2', '', '$class')";

		// matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing
		$magic_url_match[] = '#(^|[\n\t (>])(' . get_preg_expression('www_url_inline') . ')#ie';
		$magic_url_replace[] = "make_clickable_callback(MAGIC_URL_WWW, '\$1', '\$2', '', '$class')";

		// matches an email@domain type address at the start of a line, or after a space or after what might be a BBCode.
		$magic_url_match[] = '/(^|[\n\t (>])(' . get_preg_expression('email') . ')/ie';
		$magic_url_replace[] = "make_clickable_callback(MAGIC_URL_EMAIL, '\$1', '\$2', '', '')";
	}
	
	return preg_replace($magic_url_match, $magic_url_replace, $text);
}}
}
Can anyone figure out what I'm doing wrong?
sammybeats
Registered User
Posts: 8
Joined: Mon Jun 07, 2010 3:25 pm

Re: Fatal error: Cannot redeclare make_clickable()

Post by sammybeats »

Do you need any further information to help you solve this?
User avatar
Noxwizard
Support Team Leader
Support Team Leader
Posts: 10406
Joined: Mon Jun 27, 2005 8:41 pm
Location: Texas, USA
Name: Patrick Webster
Contact:

Re: Fatal error: Cannot redeclare make_clickable()

Post by Noxwizard »

If you look at the error, you will see that it's not coming from phpBB's copy of the function. You will need to put that if statement around the one in WordPress as well.
[Support Template] - [Read Before Posting] - [phpBB Knowledge Base]
Do not contact me for private support, please share the question in our forums.
sammybeats
Registered User
Posts: 8
Joined: Mon Jun 07, 2010 3:25 pm

Re: Fatal error: Cannot redeclare make_clickable()

Post by sammybeats »

No way--that was so easy. Thanks a million!
yourwhiteshadow
Registered User
Posts: 12
Joined: Sun Jun 20, 2010 11:23 pm

Re: Fatal error: Cannot redeclare make_clickable()

Post by yourwhiteshadow »

sorry to bump an old thread, but i'm having the same issue after installing WP-united. where exactly do i post the new code in the WP side?
User avatar
tascrafts
Registered User
Posts: 13
Joined: Sun Aug 20, 2006 5:21 am
Contact:

Re: Fatal error: Cannot redeclare make_clickable()

Post by tascrafts »

In your WordPress installation, look for file

wp-includes/formatting.php

And find:

Code: Select all

    function make_clickable($ret) {
        $ret = ' ' . $ret;
        // in testing, using arrays here was found to be faster
        $ret = preg_replace_callback('#(?<=[\s>])(\()?([\w]+?://(?:[\w\\x80-\\xff\#$%&~/=?@\[\](+-]|[.,;:](?![\s<]|(\))?([\s]|$))|(?(1)\)(?![\s<.,;:]|$)|\)))+)#is', '_make_url_clickable_cb', $ret);
        $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret);
        $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret);
        // this one is not in an array because we need it to run last, for cleanup of accidental links within links
        $ret = preg_replace("#(<a( [^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i", "$1$3</a>", $ret);
        $ret = trim($ret);
        return $ret;
    }
Replace it with:

Code: Select all

if (!function_exists('make_clickable'))
{
    function make_clickable($ret) {
        $ret = ' ' . $ret;
        // in testing, using arrays here was found to be faster
        $ret = preg_replace_callback('#(?<=[\s>])(\()?([\w]+?://(?:[\w\\x80-\\xff\#$%&~/=?@\[\](+-]|[.,;:](?![\s<]|(\))?([\s]|$))|(?(1)\)(?![\s<.,;:]|$)|\)))+)#is', '_make_url_clickable_cb', $ret);
        $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret);
        $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret);
        // this one is not in an array because we need it to run last, for cleanup of accidental links within links
        $ret = preg_replace("#(<a( [^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i", "$1$3</a>", $ret);
        $ret = trim($ret);
        return $ret;
    }
}
That should get rid of the error. I just troubleshooted my own installation now.
"Malum consilium quod mutari non potest"

- http://www.tascrafts.com
- http://www.ngbs.co.nr
bendy20
Registered User
Posts: 2
Joined: Sun Oct 03, 2010 6:45 am

Re: Fatal error: Cannot redeclare make_clickable()

Post by bendy20 »

Hi All

This thread has been most helpful in resolving a wp-united install issue. The previous post fixed the error durring my wp-united install and wp-united reports to have successfully installed.

I now get a similar error when browsing to my site http://pacificdunes.99k.org/

"Fatal error: Cannot redeclare make_clickable() (previously declared in /www/.../htdocs/wp-includes/formatting.php:1365) in /www/99k.org/.../htdocs/phpbb3/includes/functions_content.php on line 685"

Have I now got to somehow offset the previous code edit?

I've searched and searched and this is the closest I've come to making this mod work. Any hints are most welcome and appreciated. Thank you in advance.

Ben
User avatar
Noxwizard
Support Team Leader
Support Team Leader
Posts: 10406
Joined: Mon Jun 27, 2005 8:41 pm
Location: Texas, USA
Name: Patrick Webster
Contact:

Re: Fatal error: Cannot redeclare make_clickable()

Post by Noxwizard »

You need to wrap the functions with this:

Code: Select all

if (!function_exists('make_clickable'))
{
...
}
[Support Template] - [Read Before Posting] - [phpBB Knowledge Base]
Do not contact me for private support, please share the question in our forums.
bendy20
Registered User
Posts: 2
Joined: Sun Oct 03, 2010 6:45 am

Re: Fatal error: Cannot redeclare make_clickable()

Post by bendy20 »

Thanks for that :)
dmerkys
Registered User
Posts: 10
Joined: Mon Sep 13, 2010 4:32 pm
Location: Lithuania, Zarasai
Name: Donatas Merkys
Contact:

Re: Fatal error: Cannot redeclare make_clickable()

Post by dmerkys »

me not help this function when i make this method and including php file into phpBB template file me automaticly redirect to wp-install/install.php when i go to forum. i using phpBB 3.0.8 and wordpress 3.0.4
dmerkys
Registered User
Posts: 10
Joined: Mon Sep 13, 2010 4:32 pm
Location: Lithuania, Zarasai
Name: Donatas Merkys
Contact:

Re: Fatal error: Cannot redeclare make_clickable()

Post by dmerkys »

Is there any other method to solve this problem?
Ozo
Registered User
Posts: 330
Joined: Mon Dec 13, 2010 7:57 pm

Re: Fatal error: Cannot redeclare make_clickable()

Post by Ozo »

There is a fix for this in the BETA thread of this MOD you folks are referring about.

dmerkys wrote:Is there any other method to solve this problem?
User avatar
Igor Isaias Banlian
Registered User
Posts: 2
Joined: Thu Sep 27, 2007 1:38 am
Location: Brazil / São Paulo / SP
Name: Igor Isaias Banlian

Re: Fatal error: Cannot redeclare make_clickable()

Post by Igor Isaias Banlian »

Important to know that:

Incompatibility with "Plugin Dean's FCKEditor For Wordpress 3.3.1" causes the error "Fatal error: Cannot redeclare wptexturize() in /wp-includes/formatting.php on line 29" when accessing the "WP-United User Integration Manager".

Therefore, disabling this plugin before you install WP-United!


Sorry for my bad English, I'm Brazilian!

Regards,
Igor Isaias Banlian
User avatar
okada1314
Registered User
Posts: 209
Joined: Sat Oct 29, 2005 10:51 am

Re: Fatal error: Cannot redeclare make_clickable()

Post by okada1314 »

i got erro too
i got
Fatal error: Cannot redeclare make_clickable() (previously declared in C:\xampp\htdocs\www\wordpress\community\includes\functions_content.php:644) in C:\xampp\htdocs\www\wordpress\wp-includes\formatting.php on line 1400
Locked

Return to “[3.0.x] MOD Writers Discussion”