升级到iTop最新版本
annProg opened this issue · 13 comments
最新版本用户体验有提高,特别是搜索方式,考虑升级到最新版本(2.5)。
目前的问题是插件有不兼容,部分函数变化。需要认真测试
检查以下项目
- 更新
toolkit
到最新版 - 各页面正常访问,无报错, toolkit无报错
- obsolete对象是否能搜索到
- 唯一性检查是否包含obsolete
- 工单能否自动指派
- 时间bug是否仍需patch
- 删除不需要的patch
2.6新功能
- New attribute: dashboard contextualized to the containing object
- New attribute: tag set
- Triggers on object update and object delete
- Uniqueness rules on objects
Uniqueness rule,写插件时应该能省很多代码
tag attribute可能可以作为多选
Attribute TagSet
https://www.itophub.io/wiki/page?id=2_6_0%3Afeature%3Atag
ToArrayOfValues不能使用
ToArrayOfValues()
已经不能使用,Get link set返回ormLinkSet
,不在返回DBObjectSet
,但是ormLinkSet
提供了ToDBObjectSet
方法。或者use foreach($this as $oItem){} instead
。涉及大量修改,需测试:
- kubernetes子对象能否正常添加联系人
- kubernetes子对象权限控制(HIDDEN,修改,删除等)是否正常
- lnk ingress是否正常
补全翻译
新版本部分翻译缺失,需补全
不补翻译了,2.5.1翻译缺失似乎会自动调用英文翻译,不影响使用
整理patch
- date_zh_bug.patch
- fix_attributetext_edit.patch
- fix_css.patch
- fix_portal_url_notification.patch
- fix_restapi_customfields.patch
Archiving
- obsolete对象无法搜索到, OQL语句也无法查询到,可能需要在配置文件中设置
'show_obsolete_data' => true,
Call to undefined method MetaModel::GetExtKeyFriends()
'Class:$sClass/Name' not work
- update: 全新安装测试,发现是因为缓存,关闭缓存之后无此问题。因此唯一性检查不能直接用friendlyname了(目前线上环境是关闭apc缓存的,使用的是
opcache
) - https://sourceforge.net/p/itop/tickets/1683/
- 不同语言的friendlyname可以是不同的,用friendlyname做唯一性检查可能不太准确,需考虑新方法。更新,如果friendlyname和用户语言定义的Name格式一致,那么用friendlyname检查是准确的。现在的问题是,cache是在登录前就生成的,获取的是默认语言格式(EN US),登陆后获取了正确语言(ZH CN),这时MetaModel::GetNameSpec能够获取到正确的格式,导致唯一性检查失效。
更新结论
问题的关键是 data/cache-production
目录
- 如果此目录可写,能够写入
expressioncache.php
文件,那么无论apc缓存是否启用,都会有问题 - 删除此目录,apc缓存启用,会自动重建此目录
- 删除此目录,apc缓存禁用,不会自动重建此目录,但是会尝试写入
expressioncache.php
文件,会产生warning报错信息。能够正确显示friendlyname,如果启用了display error,restapi接口返回数据也会包含warning,导致不能正确工作
调试
core/expressioncache.class.inc.php
中
static private function GetSerializedExpression($sClass, $sAttCode)
{
$sKey = static::GetKey($sClass, $sAttCode);
$oExpr = DBObjectSearch::GetPolymorphicExpression($sClass, $sAttCode);
$oExpr = DBObjectSearch::GetPolymorphicExpression('Deployment', 'friendlyname');
print_r($oExpr);die();
return "'".$sKey."' => '".serialize($oExpr)."',\n";
}
发现只有英文翻译生效,中文翻译中定义的Name无效
DBObjectSearch::GetPolymorphicExpression
MetaModel:GetAttributeDef(($sSubClass, 'friendlyname)
返回AttributeFriendlyName对象
AttributeFriendlyName
的GetOQLExpression
MetaModel::GetNameExpression
MetaModel::GetNameSpec
Dict::S
中GetUserLanguage
获取到的结果是错误的
Dict::S
中添加如下代码
$trace = debug_backtrace();
print_r($trace);
print_r(self::GetUserLanguage() . "\n");
发现 expressioncache.class.inc.php
在Dologin之前就执行了,这时获取的语言是EN US
。Dologin之后才获取到当前语言是ZH CN
, 在pages/UI.php
中添加如下代码可以验证
require_once(APPROOT.'/application/loginwebpage.class.inc.php');
var_dump(Dict::GetUserLanguage());die();
$sLoginMessage = LoginWebPage::DoLogin(); // Check user rights and prompt if needed
var_dump(Dict::GetUserLanguage());die();
中文白屏问题
- 修改
expressioncache.class.inc.php
的GetCacheFileName
方法,让不同语言生成不同的缓存文件 - 将
metamodel.class.php
的Starup()
函数中的ExpressionCache::Warmup
注释掉,并在pages/UI.php
的DoLogin之后加上ExpressionCache::Warmup
,实现登录后在读取缓存
出现英文正常,中文白屏问题。取消 expresscache.class.inc.php
中@include_once (static::GetCacheFileName());
前的@
符号,打印出报错信息:
Fatal error: Cannot declare class ExpressionCacheData, because the name is already in use in /home/wwwroot/default/cmdb/2.5.1/data/cache-production/expressioncache-ZH-CN.php on line 5
上一个expressioncache fix对Person不生效问题
function GetCachedExpression(
函数里添加如下代码
if($sClass == "Deployment" && $sAttCode == "friendlyname") {
$trace = debug_backtrace();
print_r("###################################\n");
foreach($trace as $k => $v) {
print_r("In " . $v['file'] . " Line " . $v['line'] . "; Function " . $v['function'] . "; Class " . $v['class'] . "; Type " . $v['type'] . "\n");
}
print_r("###################################\n");
//var_dump($oExpr);
var_dump($className);
}
获取缓存只在RenderContent
函数调用时
###################################
--
| In /home/wwwroot/default/cmdb/2.5.1/core/dbobjectsearch.class.php Line 2319; Function GetCachedExpression; Class ExpressionCache; Type ::
| In /home/wwwroot/default/cmdb/2.5.1/core/dbobjectsearch.class.php Line 1869; Function GetPolymorphicExpression; Class DBObjectSearch; Type ::
| In /home/wwwroot/default/cmdb/2.5.1/core/dbobjectsearch.class.php Line 1721; Function MakeSQLObjectQuery; Class DBObjectSearch; Type ->
| In /home/wwwroot/default/cmdb/2.5.1/core/dbobjectsearch.class.php Line 1687; Function BuildSQLQueryStruct; Class DBObjectSearch; Type ->
| In /home/wwwroot/default/cmdb/2.5.1/core/dbsearch.class.php Line 613; Function GetSQLQueryStructure; Class DBObjectSearch; Type ->
| In /home/wwwroot/default/cmdb/2.5.1/core/dbsearch.class.php Line 579; Function GetSQLQuery; Class DBSearch; Type ->
| In /home/wwwroot/default/cmdb/2.5.1/core/dbobjectset.class.php Line 778; Function MakeSelectQuery; Class DBSearch; Type ->
| In /home/wwwroot/default/cmdb/2.5.1/application/displayblock.class.inc.php Line 617; Function CountWithLimit; Class DBObjectSet; Type ->
| In /home/wwwroot/default/cmdb/2.5.1/application/displayblock.class.inc.php Line 232; Function GetRenderContent; Class DisplayBlock; Type ->
| In /home/wwwroot/default/cmdb/2.5.1/application/displayblock.class.inc.php Line 213; Function GetDisplay; Class DisplayBlock; Type ->
| In /home/wwwroot/default/cmdb/2.5.1/application/menunode.class.inc.php Line 905; Function Display; Class DisplayBlock; Type ->
| In /home/wwwroot/default/cmdb/2.5.1/application/menunode.class.inc.php Line 871; Function RenderOQLSearch; Class OQLMenuNode; Type ::
| In /home/wwwroot/default/cmdb/2.5.1/pages/UI.php Line 1749; Function RenderContent; Class OQLMenuNode; Type ->
| ###################################
| string(23) "ExpressionCacheDataZHCN"
sClass
换成Person
,发现DoLogin时就开始调用缓存
###################################
--
| In /home/wwwroot/default/cmdb/2.5.1/core/dbobjectsearch.class.php Line 2319; Function GetCachedExpression; Class ExpressionCache; Type ::
| In /home/wwwroot/default/cmdb/2.5.1/core/dbobjectsearch.class.php Line 1869; Function GetPolymorphicExpression; Class DBObjectSearch; Type ::
| In /home/wwwroot/default/cmdb/2.5.1/core/dbobjectsearch.class.php Line 2246; Function MakeSQLObjectQuery; Class DBObjectSearch; Type ->
| In /home/wwwroot/default/cmdb/2.5.1/core/dbobjectsearch.class.php Line 1958; Function MakeSQLObjectQuerySingleTable; Class DBObjectSearch; Type ->
| In /home/wwwroot/default/cmdb/2.5.1/core/dbobjectsearch.class.php Line 1721; Function MakeSQLObjectQuery; Class DBObjectSearch; Type ->
| In /home/wwwroot/default/cmdb/2.5.1/core/dbobjectsearch.class.php Line 1687; Function BuildSQLQueryStruct; Class DBObjectSearch; Type ->
| In /home/wwwroot/default/cmdb/2.5.1/core/dbsearch.class.php Line 613; Function GetSQLQueryStructure; Class DBObjectSearch; Type ->
| In /home/wwwroot/default/cmdb/2.5.1/core/dbsearch.class.php Line 579; Function GetSQLQuery; Class DBSearch; Type ->
| In /home/wwwroot/default/cmdb/2.5.1/core/dbobjectset.class.php Line 700; Function MakeSelectQuery; Class DBSearch; Type ->
| In /home/wwwroot/default/cmdb/2.5.1/core/dbobjectset.class.php Line 637; Function _makeSelectQuery; Class DBObjectSet; Type ->
| In /home/wwwroot/default/cmdb/2.5.1/core/dbobjectset.class.php Line 817; Function Load; Class DBObjectSet; Type ->
| In /home/wwwroot/default/cmdb/2.5.1/core/userrights.class.inc.php Line 1304; Function Fetch; Class DBObjectSet; Type ->
| In /home/wwwroot/default/cmdb/2.5.1/core/userrights.class.inc.php Line 1269; Function FindUser; Class UserRights; Type ::
| In /home/wwwroot/default/cmdb/2.5.1/core/userrights.class.inc.php Line 634; Function FindUser; Class UserRights; Type ::
| In /home/wwwroot/default/cmdb/2.5.1/application/loginwebpage.class.inc.php Line 487; Function Login; Class UserRights; Type ::
| In /home/wwwroot/default/cmdb/2.5.1/application/loginwebpage.class.inc.php Line 742; Function Login; Class LoginWebPage; Type ::
| In /home/wwwroot/default/cmdb/2.5.1/application/loginwebpage.class.inc.php Line 722; Function DoLoginEx; Class LoginWebPage; Type ::
| In /home/wwwroot/default/cmdb/2.5.1/pages/UI.php Line 359; Function DoLogin; Class LoginWebPage; Type ::
| ###################################
| string(23) "ExpressionCacheDataENUS"
if条件改为if($sAttCode == "friendlyname")
,可以看到在DoLogin执行完成之前,以下3个类用了EN US
string(38) "UserInternal - ExpressionCacheDataENUS"
string(32) "Person - ExpressionCacheDataENUS"
string(38) "Organization - ExpressionCacheDataENUS"
基本可以合并,工单问题可以留待以后解决。目前用处不大。