ops-itop / itop-extensions

my extensions of itop
29 stars 12 forks source link

升级到iTop最新版本 #73

Closed annProg closed 5 years ago

annProg commented 6 years ago

最新版本用户体验有提高,特别是搜索方式,考虑升级到最新版本(2.5)。

目前的问题是插件有不兼容,部分函数变化。需要认真测试

annProg commented 6 years ago

https://www.itophub.io/wiki/page?id=2_5_0%3Ainstall%3A230_to_240_migration_notes

annProg commented 6 years ago

检查以下项目

annProg commented 6 years ago

2.6新功能

annProg commented 6 years ago

Attribute TagSet https://www.itophub.io/wiki/page?id=2_6_0%3Afeature%3Atag

annProg commented 6 years ago

ToArrayOfValues不能使用

ToArrayOfValues() 已经不能使用,Get link set返回ormLinkSet,不在返回DBObjectSet,但是ormLinkSet提供了ToDBObjectSet方法。或者use foreach($this as $oItem){} instead。涉及大量修改,需测试:

annProg commented 6 years ago

补全翻译

新版本部分翻译缺失,需补全

不补翻译了,2.5.1翻译缺失似乎会自动调用英文翻译,不影响使用

annProg commented 5 years ago

整理patch

annProg commented 5 years ago

Archiving

annProg commented 5 years ago

Call to undefined method MetaModel::GetExtKeyFriends()

annProg commented 5 years ago

'Class:$sClass/Name' not work

更新结论

问题的关键是 data/cache-production目录

调试

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无效

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();

中文白屏问题

出现英文正常,中文白屏问题。取消 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
annProg commented 5 years ago

上一个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"
annProg commented 5 years ago

基本可以合并,工单问题可以留待以后解决。目前用处不大。

annProg commented 5 years ago

merged #85