[fixed] code error in class.CmsLayoutTemplateType.php

Forum rules
Only administrators can post or move items here.
Post Reply
bess
Language Partners
Language Partners
Posts: 282
Joined: Thu Dec 18, 2008 9:37 am
Location: Bretagne

[fixed] code error in class.CmsLayoutTemplateType.php

Post by bess »

will work :

CmsLayoutTemplateType::load("__CORE__::Page");
CmsLayoutTemplateType::load(1);

won't work :

CmsLayoutTemplateType::load("Core::Page");
CmsLayoutTemplateType::load("core::page");
CmsLayoutTemplateType::load("Core::whatever");

to fix that : in lib/classes/class.CmsLayoutTemplateType.php there is an error into the function &load($val) (line 573)

the patch/diff : https://github.com/besstiolle/f2/commit ... 7b0c70f6cd
/**
* Load a CmsLayoutTemplateType object from the database.
*
* This method throws an exception when the requested object cannot be found.
*
* @param mixed $val An integer template type id, or a string in the form of Originator::Name
* @return CmsLayoutTemplateType
*/
public static function &load($val)
{
$db = cmsms()->GetDb();
$row = null;
if( (int)$val > 0 ) {
if( isset(self::$_cache[$val]) ) return self::$_cache[$val];

$query = 'SELECT * FROM '.cms_db_prefix().self::TABLENAME.' WHERE id = ?';
$row = $db->GetRow($query,array($val));
}
elseif( strlen($val) > 0 ) {
if( isset(self::$_name_cache[$val]) ) {
$id = self::$_name_cache[$val];
return self::$_cache[$id];
}

$tmp = explode('::',$val);
if( count($tmp) == 2 ) {
$query = 'SELECT * FROM '.cms_db_prefix().self::TABLENAME.' WHERE originator = ? AND name = ?';
if( $tmp[0] == 'Core' or $tmp[0] == 'core' ) $tmp[0] == self::CORE;
$row = $db->GetRow($query,array(trim($tmp[0]),trim($tmp[1])));
}
}
if( !is_array($row) || count($row) == 0 ) throw new CmsDataNotFoundException('Could not find template type identified by '.$val);

return self::_load_from_data($row);
}
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: [Major] code error in class.CmsLayoutTemplateType.php

Post by calguy1000 »

fixed. thanks.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Post Reply

Return to “Closed Issues”