| Installation / Upgrade Questions Questions or issues concerning the installation of the Easy PHP Calendar script. |
 |
Fatal error: Cannot redeclare utf8_substr() |
 |
12-23-2008, 03:49 PM
|
#1
|
|
Calendar User
Amelia Pereira is offline
Join Date: Oct 2008
Posts: 66
|
Fatal error: Cannot redeclare utf8_substr()
Hello, I installed easycalendar on 2 sites in the same domain. The 2 calendars share the same DB, and at the beginnning they worked fine.
Suddenly, on one site appeared the error :
Fatal error: Cannot redeclare utf8_substr() (previously declared in /home/estcsite/public_html/dmh/modules/calendar/functions/calendar.php:191) in /home/estcsite/public_html/dmh/libraries/phputf8/mbstring/core.php on line 90
and the joomla site does not show. I have to disable the easycalendar module. But on the other site it works fine.
site with problem: www.es-tc.net/dmh
site with no problem: www.es-tc.net/dmhestc
What happened??
|
|
|
|
12-23-2008, 03:52 PM
|
#2
|
|
EPC Developer
Brian is offline
Join Date: Jun 2001
Location: Florida, USA
Posts: 10,885
|
Does the calendar/demo.php file work correctly on the problem domain?
Has anything changed on the server recently (PHP version, etc)?
Are the paths correct for each installation of the calendar in the calendar directory?
|
|
|
|
12-23-2008, 03:56 PM
|
#3
|
|
Calendar User
Amelia Pereira is offline
Join Date: Oct 2008
Posts: 66
|
Hello
yes, the demo file worked... php did not change, and if it had, it would affect both calendars sib«nce they are in the same place, just in diferent folders...
as for the paths... I think they are OK. How can I check them?
|
|
|
|
12-23-2008, 03:57 PM
|
#4
|
|
EPC Developer
Brian is offline
Join Date: Jun 2001
Location: Florida, USA
Posts: 10,885
|
Check the Paths Errors link in my signature below.
|
|
|
|
12-23-2008, 04:07 PM
|
#5
|
|
Calendar User
Amelia Pereira is offline
Join Date: Oct 2008
Posts: 66
|
Well Brian
I just erased the path form the config file and entered setup... the paths were updates but the error remains.
I also compared the config file with the one on the working site, and everythingseems to be the same... except for the paths...
|
|
|
|
12-23-2008, 04:17 PM
|
#6
|
|
EPC Developer
Brian is offline
Join Date: Jun 2001
Location: Florida, USA
Posts: 10,885
|
The error is not actually the calendar, but something in your core.php file (full path in your first post).
The calendar uses a function called utf8_substr and apparently the core.php file does also. However, the calendar checks to make sure this variable hasn't been used before trying to declare it. It appears that core.php does not and it is trying to re-declare this function (which PHP doesn't allow).
Can you edit the core.php file?
|
|
|
|
 |
|
 |
12-23-2008, 04:29 PM
|
#7
|
|
Calendar User
Amelia Pereira is offline
Join Date: Oct 2008
Posts: 66
|
of course Brian, here it is:
<?php
/**
* @version $Id: core.php 10381 2008-06-01 03:35:53Z pasamio $
* @package utf8
* @subpackage strings
*/
/**
* Define UTF8_CORE as required
*/
if ( !defined('UTF8_CORE') ) {
define('UTF8_CORE',TRUE);
}
//--------------------------------------------------------------------
/**
* Assumes mbstring internal encoding is set to UTF-8
* Wrapper around mb_strpos
* Find position of first occurrence of a string
* @param string haystack
* @param string needle (you should validate this with utf8_is_valid)
* @param integer offset in characters (from left)
* @return mixed integer position or FALSE on failure
* @package utf8
* @subpackage strings
*/
function utf8_strpos($str, $search, $offset = FALSE){
if(strlen($str) && strlen($search)) {
if ( $offset === FALSE ) {
return mb_strpos($str, $search);
} else {
return mb_strpos($str, $search, $offset);
}
} else return FALSE;
}
//--------------------------------------------------------------------
/**
* Assumes mbstring internal encoding is set to UTF-8
* Wrapper around mb_strrpos
* Find position of last occurrence of a char in a string
* @param string haystack
* @param string needle (you should validate this with utf8_is_valid)
* @param integer (optional) offset (from left)
* @return mixed integer position or FALSE on failure
* @package utf8
* @subpackage strings
*/
function utf8_strrpos($str, $search, $offset = FALSE){
if ( $offset === FALSE ) {
# Emulate behaviour of strrpos rather than raising warning
if ( empty($str) ) {
return FALSE;
}
return mb_strrpos($str, $search);
} else {
if ( !is_int($offset) ) {
trigger_error('utf8_strrpos expects parameter 3 to be long',E_USER_WARNING);
return FALSE;
}
$str = mb_substr($str, $offset);
if ( FALSE !== ( $pos = mb_strrpos($str, $search) ) ) {
return $pos + $offset;
}
return FALSE;
}
}
//--------------------------------------------------------------------
/**
* Assumes mbstring internal encoding is set to UTF-8
* Wrapper around mb_substr
* Return part of a string given character offset (and optionally length)
* @param string
* @param integer number of UTF-8 characters offset (from left)
* @param integer (optional) length in UTF-8 characters from offset
* @return mixed string or FALSE if failure
* @package utf8
* @subpackage strings
*/
function utf8_substr($str, $offset, $length = FALSE){
if ( $length === FALSE ) {
return mb_substr($str, $offset);
} else {
return mb_substr($str, $offset, $length);
}
}
|
|
|
|
 |
12-23-2008, 05:01 PM
|
#8
|
|
Calendar User
Amelia Pereira is offline
Join Date: Oct 2008
Posts: 66
|
could it be some other joomla module that messed with that core.php file, and easyphpcalendar stopped working because of that?
because the only thing I was doing was to install some moduleson my site...
|
|
|
|
12-23-2008, 05:09 PM
|
#9
|
|
Calendar User
Amelia Pereira is offline
Join Date: Oct 2008
Posts: 66
|
Well, now I decided to uninstall and install the joomla module again, and when I access the module I get this message
JFolder::files: Path is not a folder /home/estcsite/public_html/dmh/calendar/templates
I thought it was supposed to install calendar inside the modules folder...  right?
I really don't understand why it is not working on this site, and it works on the other one. how strange...
|
|
|
|
12-23-2008, 05:38 PM
|
#10
|
|
EPC Developer
Brian is offline
Join Date: Jun 2001
Location: Florida, USA
Posts: 10,885
|
The calendar is working. Something in core.php added a function with the same name as the calendar and is trying to re-declare it and causing PHP to show an error.
That function in core.php would need to be renamed and it could be caused by a module. (I don't know anything about Joomla so I can't be sure.)
|
|
|
|
12-23-2008, 05:44 PM
|
#11
|
|
Calendar User
Amelia Pereira is offline
Join Date: Oct 2008
Posts: 66
|
well, I accessed the core.php file and changed the function name from utf8_substr to utf8_subs... and the page now works... the question is: what consequences has this change??? I'll have to wait and see. Thanks Brian.
|
|
|
|
 |
|
 |
12-23-2008, 06:54 PM
|
#12
|
|
Support Team
ve9gra is offline
Join Date: Jun 2003
Location: New Brunswick, Canada
Posts: 4,965
|
More than likely that it was a setting that you changed in your Joomla setup to enable UTF-8. Or you installed a module that uses that function. Like Brian said, it is not related to the calendar as it properly does a check (whereas the Joomla function doesn't).
Changing the Joomla function's name without digging into what the function does might break Joomla things. To properly do a name change, you would have to do a search and replace on all the Joomla code to a new name.... and that would of course bring you out of line with the official Joomla package, so you wouldn't be able to use the patches. Any time that you'd install a new version (if not using a patch), that modification would need to be redone.
Your best course of action is to figure out what triggered the usage of that function, and change that setting back.
__________________
-- Gervais
EPC Tutorials... We're here to help!
Offering custom integration services. Contact me here.
* Not affiliated with EasyPHPCalendar or NashTech Inc.
|
|
|
|
 |
12-23-2008, 06:58 PM
|
#13
|
|
Support Team
ve9gra is offline
Join Date: Jun 2003
Location: New Brunswick, Canada
Posts: 4,965
|
Brian, can you check the code in utf8_substr() in the calendar code and see if this code is similar?
PHP Code:
function utf8_substr($str, $offset, $length = FALSE){ if ( $length === FALSE ) { return mb_substr($str, $offset); } else { return mb_substr($str, $offset, $length); } }
__________________
-- Gervais
EPC Tutorials... We're here to help!
Offering custom integration services. Contact me here.
* Not affiliated with EasyPHPCalendar or NashTech Inc.
|
|
|
|
12-23-2008, 09:29 PM
|
#14
|
|
EPC Developer
Brian is offline
Join Date: Jun 2001
Location: Florida, USA
Posts: 10,885
|
They are not remotely similar...
|
|
|
|
12-24-2008, 06:14 AM
|
#15
|
|
Support Team
ve9gra is offline
Join Date: Jun 2003
Location: New Brunswick, Canada
Posts: 4,965
|
That's what I was expecting... which means that if the Joomla function is renamed, and producing a specific output, when Joomla will finally use that function and receive something unexpected, you might get into problems.
The Joomla forums would be better equipped to let you know either what feature to disable, or how to fix this issue.
__________________
-- Gervais
EPC Tutorials... We're here to help!
Offering custom integration services. Contact me here.
* Not affiliated with EasyPHPCalendar or NashTech Inc.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 04:53 AM.
|