glpi-project / glpi

GLPI is a Free Asset and IT Management Software package, Data center management, ITIL Service Desk, licenses tracking and software auditing.
https://glpi-project.org
GNU General Public License v3.0
4.1k stars 1.27k forks source link

After update 9.4.5 > 10.0.5 all the knowledge base is duplicate in the root category. #13336

Closed AnthonyPayan closed 1 year ago

AnthonyPayan commented 1 year ago

Code of Conduct

Is there an existing issue for this?

Version

10.0.5

Bug description

Hello.

After update 9.4.5 > 10.0.5 all the knowledge base is duplicate in the root category.

ENVIRONMENT :

Screenshot -> https://postimg.cc/JycXgSYC Capture3

Relevant log output

During the update process: Update to 9.5.2
Processing completed. (8 seconds)

Building inline images data in glpi_documents_items
SQL Error "1146": La table 'my_glpi.glpi_knowbaseitems_knowbaseitemcategories' n'existe pas in query "SELECT * FROM `glpi_knowbaseitems_knowbaseitemcategories` WHERE `knowbaseitems_id` = '951'

Page URL

http://my_glpi/front/knowbaseitem.php

Steps To reproduce

  1. Recovery of FTP & BDD 9.4.5 from a web environment (OVH).
  2. Creation of a virtual host with wamp64.
  3. Copy paste from GLPI 10.0.5 on the FTP in 9.4.5.
  4. Replacement of already existing files during copy/paste.
  5. URL http://my_glpi/
  6. Follow-up of the steps created by GLPI.
  7. Connection to GLPI once the update is complete.
  8. On the reception of GLPI 10.0.5 errors which are easily corrected thanks to the migration commands provided by GLPI: [ UTF8 > UTF8MB4 ], [ DATETIME > TIMESTAMPS ], [ MIGRATION:UNSIGNED_KEYS ].

Your GLPI setup information

Informations sur le système, l'installation et la configuration
GLPI 10.0.5 ( => C:\wamp64\www\my_glpi)
Installation mode: TARBALL
Current language:fr_FR

Server
 
Operating system: Windows NT myc_omputer 10.0 build 19044 (Windows 10) AMD64
PHP 7.4.26 apache2handler (Core, PDO, Phar, Reflection, SPL, SimpleXML, Zend OPcache, apache2handler, bcmath, bz2, calendar,
    com_dotnet, ctype, curl, date, dom, exif, fileinfo, filter, gd, gettext, gmp, hash, iconv, imap, intl, json, ldap, libxml,
    mbstring, mysqli, mysqlnd, openssl, pcre, pdo_mysql, pdo_sqlite, readline, session, soap, sockets, sodium, sqlite3, standard,
    tokenizer, xdebug, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip, zlib)
Setup: max_execution_time="9999" memory_limit="1G" post_max_size="8M" safe_mode="" session.save_handler="files"
    upload_max_filesize="2M" 
Software: Apache/2.4.51 (Win64) PHP/7.4.26 (Apache/2.4.51 (Win64) PHP/7.4.26 Server at my_glpi Port 80
)
    Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
Server Software: MySQL Community Server (GPL)
    Server Version: 5.7.36
    Server SQL Mode: STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER
    Parameters: root@127.0.0.1/my_glp
    Host info: 127.0.0.1 via TCP/IP

PHP version (7.4.26) is supported.
Sessions configuration is OK.
Allocated memory is sufficient.
mysqli extension is installed.
Following extensions are installed: dom, fileinfo, json, simplexml.
curl extension is installed.
gd extension is installed.
intl extension is installed.
libxml extension is installed.
zlib extension is installed.
The constant SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES is present.
Database engine version (5.7.36) is supported.
No files from previous GLPI version detected.
The log file has been created successfully.
Write access to C:\wamp64\www\my_glpi /files/_cache has been validated.
Write access to C:\wamp64\www\my_glpi /config has been validated.
Write access to C:\wamp64\www\my_glpi /files/_cron has been validated.
Write access to C:\wamp64\www\my_glpi /files has been validated.
Write access to C:\wamp64\www\my_glpi /files/_dumps has been validated.
Write access to C:\wamp64\www\my_glpi /files/_graphs has been validated.
Write access to C:\wamp64\www\my_glpi /files/_lock has been validated.
Write access to C:\wamp64\www\my_glpi /files/_pictures has been validated.
Write access to C:\wamp64\www\my_glpi /files/_plugins has been validated.
Write access to C:\wamp64\wwwmy_glpi /_rss has been validated.
Write access to C:\wamp64\www\my_glpi /files/_sessions has been validated.
Write access to C:\wamp64\www\my_glpi /files/_tmp has been validated.
Write access to C:\wamp64\wwwmy_glpi /files/_uploads has been validated.
The following directories should be placed outside "C:\wamp64\www\my_glpi ":
‣ "C:\wamp64\www\my_glpi/files" ("GLPI_VAR_DIR")
‣ "C:\wamp64\www\my_glpi\config" ("GLPI_CONFIG_DIR")
You can ignore this suggestion if you are certain that these directories are not accessible through your web server.
PHP directive "session.cookie_httponly" should be set to "on" to prevent client-side script to access cookie values.
exif extension is installed.
ldap extension is installed.
openssl extension is installed.
zip extension is installed.
bz2 extension is installed.
Zend OPcache extension is installed.
Following extensions are installed: ctype, iconv, mbstring, sodium.
Write access to C:\wamp64\www\my_glpi/marketplace has been validated.
Timezones seems loaded in database.

GLPI constants
 
GLPI_ROOT: "C:\\wamp64\\www\\my_glpi"
GLPI_CONFIG_DIR: "C:\\wamp64\\www\\my_glpi/config"
GLPI_VAR_DIR: "C:\\wamp64\\www\\my_glpi/files"
GLPI_MARKETPLACE_DIR: "C:\\wamp64\\www\\my_glpi/marketplace"
GLPI_USE_CSRF_CHECK: "1"
GLPI_CSRF_EXPIRES: "7200"
GLPI_CSRF_MAX_TOKENS: "100"
GLPI_USE_IDOR_CHECK: "1"
GLPI_IDOR_EXPIRES: "7200"
GLPI_ALLOW_IFRAME_IN_RICH_TEXT: false
GLPI_SERVERSIDE_URL_ALLOWLIST: ["/^(https?|feed):\\/\\/[^@:]+(\\/.*)?$/"]
GLPI_TELEMETRY_URI: "https://telemetry.glpi-project.org"
GLPI_INSTALL_MODE: "TARBALL"
GLPI_NETWORK_MAIL: "glpi@teclib.com"
GLPI_NETWORK_SERVICES: "https://services.glpi-network.com"
GLPI_MARKETPLACE_ALLOW_OVERRIDE: true
GLPI_MARKETPLACE_MANUAL_DOWNLOADS: true
GLPI_USER_AGENT_EXTRA_COMMENTS: ""
GLPI_DISABLE_ONLY_FULL_GROUP_BY_SQL_MODE: "1"
GLPI_AJAX_DASHBOARD: "1"
GLPI_CALDAV_IMPORT_STATE: 0
GLPI_DEMO_MODE: "0"
GLPI_CENTRAL_WARNINGS: "1"
GLPI_DOC_DIR: "C:\\wamp64\\www\my_glpi/files"
GLPI_CACHE_DIR: "C:\\wamp64\\www\\my_glpi/files/_cache"
GLPI_CRON_DIR: "C:\\wamp64\\www\\my_glpi/files/_cron"
GLPI_DUMP_DIR: "C:\\wamp64\\www\\my_glpi/files/_dumps"
GLPI_GRAPH_DIR: "C:\\wamp64\\www\\my_glpi/files/_graphs"
GLPI_LOCAL_I18N_DIR: "C:\\wamp64\\www\\my_glpi/files/_locales"
GLPI_LOCK_DIR: "C:\\wamp64\\www\my_glpi/files/_lock"
GLPI_LOG_DIR: "C:\\wamp64\\www\\my_glpi/files/_log"
GLPI_PICTURE_DIR: "C:\\wamp64\\www\\my_glpi/files/_pictures"
GLPI_PLUGIN_DOC_DIR: "C:\\wamp64\\www\\my_glpi/files/_plugins"
GLPI_RSS_DIR: "C:\\wamp64\\www\my_glpi/files/_rss"
GLPI_SESSION_DIR: "C:\\wamp64\\www\\my_glpi/files/_sessions"
GLPI_TMP_DIR: "C:\\wamp64\\www\\my_glpi/files/_tmp"
GLPI_UPLOAD_DIR: "C:\\wamp64\\www\\my_glpi/files/_uploads"
GLPI_INVENTORY_DIR: "C:\\wamp64\\www\\my_glpi/files/_inventories"
GLPI_NETWORK_REGISTRATION_API_URL: "https://services.glpi-network.com/api/registration/"
GLPI_MARKETPLACE_PLUGINS_API_URI: "https://services.glpi-network.com/api/glpi-plugins/"
GLPI_I18N_DIR: "C:\\wamp64\\www\\my_glpi/locales"
GLPI_VERSION: "10.0.5"
GLPI_SCHEMA_VERSION: "10.0.5@628dbfbb91eb4caf10c35969d9162b9300b141e0"
GLPI_MARKETPLACE_PRERELEASES: false
GLPI_MIN_PHP: "7.4.0"
GLPI_MAX_PHP: "8.3.0"
GLPI_YEAR: "2022"

Libraries
 
htmlawed/htmlawed version 1.2.9 in (C:\wamp64\www\my_glpi\vendor\htmlawed\htmlawed)
phpmailer/phpmailer version 6.6.0 in (C:\wamp64\www\my_glpi\vendor\phpmailer\phpmailer\src)
simplepie/simplepie version 1.5.8 in (C:\wamp64\www\my_glpi\vendor\simplepie\simplepie\library)
tecnickcom/tcpdf version 6.5.0 in (C:\wamp64\www\my_glpi\vendor\tecnickcom\tcpdf)
michelf/php-markdown in (C:\wamp64\www\my_glpi\vendor\michelf\php-markdown\Michelf)
true/punycode in (C:\wamp64\www\my_glpi\vendor\true\punycode\src)
iamcal/lib_autolink in (C:\wamp64\www\my_glpi\vendor\iamcal\lib_autolink)
sabre/dav in (C:\wamp64\www\my_glpi\vendor\sabre\dav\lib\DAV)
sabre/http in (C:\wamp64\www\my_glpi\vendor\sabre\http\lib)
sabre/uri in (C:\wamp64\www\my_glpi\vendor\sabre\uri\lib)
sabre/vobject in (C:\wamp64\www\my_glpi\vendor\sabre\vobject\lib)
laminas/laminas-i18n in (C:\wamp64\www\my_glpi\vendor\laminas\laminas-i18n\src)
laminas/laminas-servicemanager in (C:\wamp64\www\my_glpi\vendor\laminas\laminas-servicemanager\src)
monolog/monolog in (C:\wamp64\www\my_glpi\vendor\monolog\monolog\src\Monolog)
sebastian/diff in (C:\wamp64\www\my_glpi\vendor\sebastian\diff\src)
donatj/phpuseragentparser in (C:\wamp64\www\my_glpi\vendor\donatj\phpuseragentparser\src\UserAgent)
elvanto/litemoji in (C:\wamp64\www\my_glpi\vendor\elvanto\litemoji\src)
symfony/console in (C:\wamp64\www\my_glpi\vendor\symfony\console)
scssphp/scssphp in (C:\wamp64\wwwmy_glpi\vendor\scssphp\scssphp\src)
laminas/laminas-mail in (C:\wamp64\www\my_glpi\vendor\laminas\laminas-mail\src\Protocol)
laminas/laminas-mime in (C:\wamp64\www\my_glpi\vendor\laminas\laminas-mime\src)
rlanvin/php-rrule in (C:\wamp64\www\my_glpi\vendor\rlanvin\php-rrule\src)
blueimp/jquery-file-upload in (C:\wamp64\www\my_glpi\vendor\blueimp\jquery-file-upload\server\php)
ramsey/uuid in (C:\wamp64\www\my_glpi\vendor\ramsey\uuid\src)
psr/log in (C:\wamp64\www\my_glpi\vendor\psr\log\Psr\Log)
psr/simple-cache in (C:\wamp64\www\my_glpi\vendor\psr\simple-cache\src)
psr/cache in (C:\wamp64\www\my_glpi\vendor\psr\cache\src)
league/csv in (C:\wamp64\www\my_glpi\vendor\league\csv\src)
mexitek/phpcolors in (C:\wamp64\wwwmy_glpi\vendor\mexitek\phpcolors\src\Mexitek\PHPColors)
guzzlehttp/guzzle in (C:\wamp64\www\my_glpi\vendor\guzzlehttp\guzzle\src)
guzzlehttp/psr7 in (C:\wamp64\www\my_glpi\vendor\guzzlehttp\psr7\src)
glpi-project/inventory_format in (C:\wamp64\wwwmy_glpi\vendor\glpi-project\inventory_format\lib\php)
wapmorgan/unified-archive in (C:\wamp64\www\my_glpi\vendor\wapmorgan\unified-archive\src)
paragonie/sodium_compat in (C:\wamp64\www\my_glpi\vendor\paragonie\sodium_compat\src)
symfony/cache in (C:\wamp64\www\my_glpi\vendor\symfony\cache)
html2text/html2text in (C:\wamp64\www\my_glpi\vendor\html2text\html2text\src)
symfony/css-selector in (C:\wamp64\www\my_glpi\vendor\symfony\css-selector)
symfony/dom-crawler in (C:\wamp64\www\my_glpi\vendor\symfony\dom-crawler)
twig/twig in (C:\wamp64\wwwmy_glpi\vendor\twig\twig\src)
twig/string-extra in (C:\wamp64\www\my_glpi\vendor\twig\string-extra)
symfony/polyfill-ctype not found
symfony/polyfill-iconv not found
symfony/polyfill-mbstring not found
symfony/polyfill-php80 in (C:\wamp64\www\my_glpi\vendor\symfony\polyfill-php80)
symfony/polyfill-php81 in (C:\wamp64\www\my_glp\vendor\symfony\polyfill-php81)
symfony/polyfill-php82 in (C:\wamp64\www\my_glp\vendor\symfony\polyfill-php82)

SQL replicas
 
Not active

Notifications
 
Way of sending emails: SMTP+SSL SSL0.OVH.NET)

Plugins list
 
    fields               Name: Champs supplémentaires         Version: 1.10.3     State: Installed / not activated               
        Install Method: Manual
    behaviors            Name: Comportements                  Version: 2.2.2      State: Installed / not activated               
        Install Method: Manual

Anything else?

No response

cedric-anne commented 1 year ago

Hi,

Could you provide the full log trace for the error SQL Error "1146": La table 'my_glpi.glpi_knowbaseitems_knowbaseitemcategories' n'existe pas in query "SELECT * FROM `glpi_knowbaseitems_knowbaseitemcategories` WHERE `knowbaseitems_id` = '951' ?

AnthonyPayan commented 1 year ago

Hi, I did not find the error for id 951 but I have the same error for another id

[2022-11-17 14:26:06] glpisqllog.ERROR: DBmysql::query() in C:\wamp64\www\my_glpi\src\DBmysql.php line 370 ** MySQL query error: SQL: SELECT FROM glpi_knowbaseitems_knowbaseitemcategories WHERE knowbaseitems_id = '904' Error: La table 'my_glpi.glpi_knowbaseitems_knowbaseitemcategories' n'existe pas Backtrace : src\DBmysqlIterator.php:112
src\DBmysql.php:1056 DBmysqlIterator->execute() src\CommonDBTM.php:577 DBmysql->request() src\CommonDBTM.php:6258 CommonDBTM->find() src\KnowbaseItem.php:423 CommonDBTM->load1NTableData() src\CommonDBTM.php:311 KnowbaseItem->post_getFromDB() src\CommonDBConnexity.php:253 CommonDBTM->getFromDB() src\CommonDBConnexity.php:155 CommonDBConnexity::getItemFromArray() src\CommonDBRelation.php:841 CommonDBConnexity->getConnexityItem() src\Document_Item.php:227 CommonDBRelation->post_addItem() src\CommonDBTM.php:1325 Document_Item->post_addItem() install\migrations\update_9.5.1_to_9.5.2.php:104 CommonDBTM->add() src\Update.php:258 update951to952() install\update.php:143 Update->doUpdates() install\update.php:252 doUpdateDb() {"user":"@ANTHONY","mem_usage":"0.009\", 5.46Mio)"}

AnthonyPayan commented 1 year ago

for the content that comes out of the html feed, it's because I'm in super admin mode and there are php errors much further down the list Capture5

AnthonyPayan commented 1 year ago

When I dump in glpi/ajax/knowbase.php file

I get cat_id = 0 when I display the root category.

C:\wamp64\www\my_glpi\ajax\knowbase.php:57: array (size=3) 'action' => string 'getItemslist' (length=12) 'cat_id' => string '0' (length=1) 'start' => string '0' (length=1)

And the cat_id changes well when I click on another category, and displays ONLY the files of the requested category. the problem is really on the root category cat_id = '0' = all the knowledge base to display.

AnthonyPayan commented 1 year ago

Hello,

We need more informations ?

cedric-anne commented 1 year ago

Hi,

1) You had following errors during migration, so maybe you have some inconsistent data in your database. You should have restored your backup until we provide a fix, but if you cannot restore your backup, you will have to deal with this.

Building inline images data in glpi_documents_items
SQL Error "1146": La table 'my_glpi.glpi_knowbaseitems_knowbaseitemcategories' n'existe pas in query "SELECT * FROM `glpi_knowbaseitems_knowbaseitemcategories` WHERE `knowbaseitems_id` = '951'

2) Following error is probably due to orphaned data in glpi_document_items.

for the content that comes out of the html feed, it's because I'm in super admin mode and there are php errors much further down the list Capture5

You should be able to ignore these entries by applying this patch:

diff --git a/src/KnowbaseItem.php b/src/KnowbaseItem.php
index 9a2689b792..ee524cd633 100644
--- a/src/KnowbaseItem.php
+++ b/src/KnowbaseItem.php
@@ -2005,10 +2005,13 @@ class KnowbaseItem extends CommonDBVisible implements ExtraVisibilityCriteria
                         ] + getEntitiesRestrictCriteria('', '', '', true)
                     ]);
                     foreach ($iterator as $docs) {
-                          $doc = new Document();
-                          $doc->getFromDB($docs["documents_id"]);
-                          echo $doc->getDownloadLink();
-                          $j++;
+                        $doc = new Document();
+                        if (!$doc->getFromDB($docs["documents_id"])) {
+                            // Orphan row, ignore it
+                            continue;
+                        }
+                        echo $doc->getDownloadLink();
+                        $j++;
                         if ($j > 1) {
                             echo "<br>";
                         }

3) For the initial issue, I do not have time to investigate on it, so I do not know if provided information is sufficient.

cedric-anne commented 1 year ago

@AnthonyPayan

Could you test #13443 ?

AnthonyPayan commented 1 year ago

@AnthonyPayan

Could you test #13443 ?

Helo, i test #13443 and it's ok problem solved !

Thank you for the work provided!

Best wishes

AnthonyPayan commented 1 year ago

Hi,

  1. You had following errors during migration, so maybe you have some inconsistent data in your database. You should have restored your backup until we provide a fix, but if you cannot restore your backup, you will have to deal with this.
Building inline images data in glpi_documents_items
SQL Error "1146": La table 'my_glpi.glpi_knowbaseitems_knowbaseitemcategories' n'existe pas in query "SELECT * FROM `glpi_knowbaseitems_knowbaseitemcategories` WHERE `knowbaseitems_id` = '951'
  1. Following error is probably due to orphaned data in glpi_document_items.

for the content that comes out of the html feed, it's because I'm in super admin mode and there are php errors much further down the list Capture5

You should be able to ignore these entries by applying this patch:

diff --git a/src/KnowbaseItem.php b/src/KnowbaseItem.php
index 9a2689b792..ee524cd633 100644
--- a/src/KnowbaseItem.php
+++ b/src/KnowbaseItem.php
@@ -2005,10 +2005,13 @@ class KnowbaseItem extends CommonDBVisible implements ExtraVisibilityCriteria
                         ] + getEntitiesRestrictCriteria('', '', '', true)
                     ]);
                     foreach ($iterator as $docs) {
-                          $doc = new Document();
-                          $doc->getFromDB($docs["documents_id"]);
-                          echo $doc->getDownloadLink();
-                          $j++;
+                        $doc = new Document();
+                        if (!$doc->getFromDB($docs["documents_id"])) {
+                            // Orphan row, ignore it
+                            continue;
+                        }
+                        echo $doc->getDownloadLink();
+                        $j++;
                         if ($j > 1) {
                             echo "<br>";
                         }
  1. For the initial issue, I do not have time to investigate on it, so I do not know if provided information is sufficient.

same for this solution it works,

Thanks !