[FIX] PHP5.2.4+Zend fatal error editing profile

16 years 4 months ago #50613 by beat
Replied by beat on topic Re:PHP5 fatal error when editing profile
That's the code for next CB version, working around that Zend bug in php 5.2.4:

[code:1]/**
* Translates text strings from CB and core cms ('_UE_....') into current language
*
* @param string $text
* @return string
*/
function getLangDefinition($text) {
// check for '::' as a workaround of bug #42770 in PHP 5.2.4 with optimizers:
if ( ( strpos( $text, '::' ) === false ) && defined( $text ) ) {
$returnText = constant( $text );
} else {
$returnText = $text;
}
return $returnText;
}
[/code:1]

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info

Please Log in to join the conversation.

16 years 4 months ago #50875 by bobepine
Replied by bobepine on topic Re:PHP5 fatal error when editing profile
Yes your code worked !!! Thanks for the rewrite of that function it helped me to find where was the semi column

it ended up being my new french language file for the plug_cbprofilegallery plugin ! wich had a line sayin
DEFINE("_pg_TotalAllowedQuotaItems","Quota:");

and was displayed as Quota:: on the user profile edit page !

Hmmm... those semi column !! lol

I left the code in my administrator/components/com_comprofiler/plugin.foundation.php

is there anywhere else I should put this code to prevent any future bugs ?

Thanks a lot !!!

Please Log in to join the conversation.

16 years 4 months ago #50929 by beat
Replied by beat on topic Re:PHP5 fatal error when editing profile
it's the only place.

However, you should ask your hoster to update the Zend Optimizer so it doesn't have that bug in that PHP 5.2.4 release...don't know if sams old Zend Optimizer is also affected in php 5.2.5.

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info

Please Log in to join the conversation.

16 years 4 months ago #51077 by tkapower
Replied by tkapower on topic Re:PHP5 fatal error when editing profile
Where should i put the code
my plugin.foundation.php

look like this and this and no go

"
<?php
/**
* Joomla/Mambo Community Builder
* @version $Id: plugin.foundation.php 610 2006-12-13 17:33:44Z beat $
* @package Community Builder
* @subpackage plugin.foundation.php
* @author JoomlaJoe and Beat
* @copyright (C) JoomlaJoe and Beat, www.joomlapolis.com
* @license www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU/GPL version 2
*/

// ensure this file is being included by a parent file
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

function getLangDefinition($text) {
if(defined($text)) $returnText = constant($text);
else $returnText = $text;
return $returnText;
}

/**
* Translates text strings from CB and core cms ('_UE_....') into current language
*
* @param string $text
* @return string
*/
function getLangDefinition($text) {
// check for '::' as a workaround of bug #42770 in PHP 5.2.4 with optimizers:
if ( ( strpos( $text, '::' ) === false ) && defined( $text ) ) {
$returnText = constant( $text );
} else {
$returnText = $text;
}
return $returnText;
}

/**
* includes CB stuff
* --- usage: cbimport('cb.xml.simplexml');
*
* @param string $path
*/
function cbimport( $lib ) {
global $mainframe;
static $imported = array();

if ( ! isset( $imported[$lib] ) ) {
$imported[$lib] = true;

$liblow = strtolower( $lib );
$pathAr = explode( '.', $liblow );
array_pop( $pathAr );
$filepath = implode( '/', $pathAr ) . '/' . $liblow . '.php';

require_once( $mainframe->getCfg('absolute_path') . '/administrator/components/com_comprofiler/library/' . $filepath );
}
}

/**
* Parameters handler
* @package Joomla/Mambo Community Builder
*/
class cbParamsBase {
/** @var object */
var $_params = null;
/** @var string The raw params string */
var $_raw = null;
/**
* Constructor
* @param string The raw parms text
* @param string Path to the xml setup file
* @param string The type of setup file
*/
function cbParamsBase( $paramsValues ) {
$this->_params = $this->parse( $paramsValues );
$this->_raw = $paramsValues;
}
/**
* Loads from the plugins database.
* @param string The plugin element name
* @return boolean true: could load, false: query error.
*/
function loadFromDB( $element ) {
global $_CB_database;

$_CB_database->setQuery("SELECT params FROM `#__comprofiler_plugin` WHERE element = '" . $_CB_database->getEscaped( $element ) . "'" );
$text = $_CB_database->loadResult();
$this->_params = $this->parse( $text );
$this->_raw = $text;
return ( $text !== null );
}
/**
* @param string The name of the param
* @param string The value of the parameter
* @return string The set value
*/
function set( $key, $value='' ) {
$this->_params->$key = $value;
return $value;
}
/**
* Sets a default value if not alreay assigned
* @param string The name of the param
* @param string The value of the parameter
* @return string The set value
*/
function def( $key, $value='' ) {
return $this->set( $key, $this->get( $key, $value ) );
}
/**
* @param string The name of the param
* @param mixed The default value if not found
* @return string
*/
function get( $key, $default=null ) {
if ( isset( $this->_params->$key ) ) {
if (is_array( $default ) ) {
return explode( '|*|', $this->_params->$key );
} else {
return $this->_params->$key;
}
} else {
return $default;
}
}
/**
* Parse an .ini string, based on phpDocumentor phpDocumentor_parse_ini_file function
* @param mixed The ini string or array of lines
* @param boolean add an associative index for each section [in brackets]
* @return object
*/
function parse( $txt, $process_sections = false, $asArray = false ) {
if (is_string( $txt )) {
$lines = explode( "\n", $txt );
} else if (is_array( $txt )) {
$lines = $txt;
} else {
$lines = array();
}
$obj = $asArray ? array() : new stdClass();

$sec_name = '';
$unparsed = 0;
if (!$lines) {
return $obj;
}
foreach ($lines as $line) {
// ignore comments
if ($line && $line[0] == ';') {
continue;
}
$line = trim( $line );

if ($line == '') {
continue;
}
if ($line && $line[0] == ' == ']') {
$sec_name = substr( $line, 1, strlen($line) - 2 );
if ($process_sections) {
if ($asArray) {
$obj[$sec_name] = array();
} else {
$obj->$sec_name = new stdClass();
}
}
} else {
if ($pos = strpos( $line, '=' )) {
$property = trim( substr( $line, 0, $pos ) );

if (substr($property, 0, 1) == '"' && substr($property, -1) == '"') {
$property = stripcslashes(substr($property,1,count($property) - 2));
}
$value = trim( substr( $line, $pos + 1 ) );
if ($value == 'false') {
$value = false;
}
if ($value == 'true') {
$value = true;
}
if (substr( $value, 0, 1 ) == '"' && substr( $value, -1 ) == '"') {
$value = stripcslashes( substr( $value, 1, count( $value ) - 2 ) );
}

if ($process_sections) {
$value = str_replace( array( '\n', '\r' ), array( "\n", "\r" ), $value );
if ($sec_name != '') {
if ($asArray) {
$obj[$sec_name][$property] = $value;
} else {
$obj->$sec_name->$property = $value;
}
} else {
if ($asArray) {
$obj[$property] = $value;
} else {
$obj->$property = $value;
}
}
} else {
$value = str_replace( array( '\n', '\r' ), array( "\n", "\r" ), $value );
if ($asArray) {
$obj[$property] = $value;
} else {
$obj->$property = $value;
}
}
} else {
if ($line && trim($line[0]) == ';') {
continue;
}
if ($process_sections) {
$property = '__invalid' . $unparsed++ . '__';
if ($process_sections) {
if ($sec_name != '') {
if ($asArray) {
$obj[$sec_name][$property] = trim($line);
} else {
$obj->$sec_name->$property = trim($line);
}
} else {
if ($asArray) {
$obj[$property] = trim($line);
} else {
$obj->$property = trim($line);
}
}
} else {
if ($asArray) {
$obj[$property] = trim($line);
} else {
$obj->$property = trim($line);
}
}
}
}
}
}
return $obj;
}
}

?>
"

Please Log in to join the conversation.

16 years 2 months ago #54931 by Xantoz
I got: Fatal error: Class 'Bruger ID' not found in /home/www/digifora.dk/administrator/components/com_comprofiler/plugin.foundation.php on line 16

This error only occurs when I install the danish translation package (com_comprofiler_1.1_da-DK_Language24-08-07), so it seems the translation plugin could be the problem. I get the error when I try to edit or create a user profile from the CB user manager.

Please Log in to join the conversation.

16 years 2 months ago #56295 by grawsom
I had the same problem - fixed it by removeing the :

in language file.

This was in file.

DEFINE('_UE_EMAIL','Email:');
DEFINE('_UE_UNAME','Bruger ID:');
DEFINE('_UE_PASS','Adgangskode:');


Changed it to

DEFINE('_UE_EMAIL','Email');
DEFINE('_UE_UNAME','Bruger ID');
DEFINE('_UE_PASS','Adgangskode');


I dont know much about coding but it worked for me, I belive the : is in another file, because they are still there when you go to user editing.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.267 seconds

Facebook Twitter LinkedIn