Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
glpi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
GLPI
glpi
Commits
e58cc1ee
Commit
e58cc1ee
authored
May 06, 2019
by
Johan Cwiklinski
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '9.4/bugfixes' into 9.5/bugfixes
parents
3a77fb51
88636e36
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
140 additions
and
6 deletions
+140
-6
CHANGELOG.md
CHANGELOG.md
+3
-1
inc/update.class.php
inc/update.class.php
+2
-1
install/update_940_941.php
install/update_940_941.php
+2
-2
install/update_941_942.php
install/update_941_942.php
+2
-2
install/update_942_943.php
install/update_942_943.php
+131
-0
No files found.
CHANGELOG.md
View file @
e58cc1ee
...
...
@@ -55,7 +55,9 @@ The present file will list all changes made to the project; according to the
-
`CommonDBTM::getTablesOf()`
-
`CommonDBTM::getForeignKeyFieldsOf()`
## [9.4.2] unreleased
## [9.4.3] unreleased
## [9.4.2] 2019-04-11
### API changes
...
...
inc/update.class.php
View file @
e58cc1ee
...
...
@@ -450,8 +450,9 @@ class Update extends CommonGLPI {
update941to942
();
case
"9.4.2"
:
include_once
"
{
$updir
}
update_942_943.php"
;
update942to943
();
case
"9.4.3"
:
case
"9.4.4"
:
case
"9.4.5"
:
case
"9.4.6"
:
case
"9.4.7"
:
...
...
install/update_940_941.php
View file @
e58cc1ee
...
...
@@ -115,7 +115,7 @@ function update940to941() {
]
);
foreach
(
$elements_to_fix
as
$data
)
{
$data
[
'content'
]
=
$
fix_content_fct
(
$data
[
'content'
],
$data
[
'items_id'
],
$itil_fkey
);
$data
[
'content'
]
=
$
DB
->
escape
(
$fix_content_fct
(
$data
[
'content'
],
$data
[
'items_id'
],
$itil_fkey
)
);
$DB
->
update
(
$itil_element_table
,
$data
,
[
'id'
=>
$data
[
'id'
]]);
}
}
...
...
@@ -131,7 +131,7 @@ function update940to941() {
]
);
foreach
(
$tasks_to_fix
as
$data
)
{
$data
[
'content'
]
=
$
fix_content_fct
(
$data
[
'content'
],
$data
[
$itil_fkey
],
$itil_fkey
);
$data
[
'content'
]
=
$
DB
->
escape
(
$fix_content_fct
(
$data
[
'content'
],
$data
[
$itil_fkey
],
$itil_fkey
)
);
$DB
->
update
(
$task_table
,
$data
,
[
'id'
=>
$data
[
'id'
]]);
}
}
...
...
install/update_941_942.php
View file @
e58cc1ee
...
...
@@ -119,7 +119,7 @@ function update941to942() {
]
);
foreach
(
$elements_to_fix
as
$data
)
{
$data
[
'content'
]
=
$
fix_content_fct
(
$data
[
'content'
],
$data
[
'items_id'
],
$itil_fkey
);
$data
[
'content'
]
=
$
DB
->
escape
(
$fix_content_fct
(
$data
[
'content'
],
$data
[
'items_id'
],
$itil_fkey
)
);
$DB
->
update
(
$itil_element_table
,
$data
,
[
'id'
=>
$data
[
'id'
]]);
}
}
...
...
@@ -135,7 +135,7 @@ function update941to942() {
]
);
foreach
(
$tasks_to_fix
as
$data
)
{
$data
[
'content'
]
=
$
fix_content_fct
(
$data
[
'content'
],
$data
[
$itil_fkey
],
$itil_fkey
);
$data
[
'content'
]
=
$
DB
->
escape
(
$fix_content_fct
(
$data
[
'content'
],
$data
[
$itil_fkey
],
$itil_fkey
)
);
$DB
->
update
(
$task_table
,
$data
,
[
'id'
=>
$data
[
'id'
]]);
}
}
...
...
install/update_942_943.php
0 → 100644
View file @
e58cc1ee
<?php
/**
* ---------------------------------------------------------------------
* GLPI - Gestionnaire Libre de Parc Informatique
* Copyright (C) 2015-2018 Teclib' and contributors.
*
* http://glpi-project.org
*
* based on GLPI - Gestionnaire Libre de Parc Informatique
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
*
* ---------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GLPI.
*
* GLPI is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GLPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
* ---------------------------------------------------------------------
*/
/**
* Update from 9.4.2 to 9.4.3
*
* @return bool for success (will die for most error)
**/
function
update942to943
()
{
global
$DB
,
$migration
;
$updateresult
=
true
;
//TRANS: %s is the number of new version
$migration
->
displayTitle
(
sprintf
(
__
(
'Update to %s'
),
'9.4.3'
));
$migration
->
setVersion
(
'9.4.3'
);
/** Fix URL of images inside ITIL objects contents */
// This is an exact copy of the same process used in "update940to941()" and "update941to942()"
// which was not working for elements having a simple quote in their content.
// It has been fixed there for people who had not yet updated to 9.4.1 / 9.4.2 but have to
// be put back here for people already having updated to 9.4.1 / 9.4.2.
$migration
->
displayMessage
(
sprintf
(
__
(
'Fix URL of images in ITIL tasks, followups ans solutions.'
)));
// Search for contents that does not contains the itil object parameter after the docid parameter
// (i.e. having a quote that ends the href just after the docid param value).
// 1st capturing group is the end of href attribute value
// 2nd capturing group is the href attribute ending quote
$quotes_possible_exp
=
[
'\''
,
'''
,
'''
,
'''
,
'"'
,
'"'
,
'"'
,
'"'
];
$missing_param_pattern
=
'(document\.send\.php\?docid=[0-9]+)('
.
implode
(
'|'
,
$quotes_possible_exp
)
.
')'
;
$itil_mappings
=
[
'Change'
=>
[
'itil_table'
=>
'glpi_changes'
,
'itil_fkey'
=>
'changes_id'
,
'task_table'
=>
'glpi_changetasks'
,
],
'Problem'
=>
[
'itil_table'
=>
'glpi_problems'
,
'itil_fkey'
=>
'problems_id'
,
'task_table'
=>
'glpi_problemtasks'
,
],
'Ticket'
=>
[
'itil_table'
=>
'glpi_tickets'
,
'itil_fkey'
=>
'tickets_id'
,
'task_table'
=>
'glpi_tickettasks'
,
],
];
$fix_content_fct
=
function
(
$content
,
$itil_id
,
$itil_fkey
)
use
(
$missing_param_pattern
)
{
// Add itil object param between docid param ($1) and ending quote ($2)
return
preg_replace
(
'/'
.
$missing_param_pattern
.
'/'
,
'$1&'
.
http_build_query
([
$itil_fkey
=>
$itil_id
])
.
'$2'
,
$content
);
};
foreach
(
$itil_mappings
as
$itil_type
=>
$itil_specs
)
{
$itil_fkey
=
$itil_specs
[
'itil_fkey'
];
$task_table
=
$itil_specs
[
'task_table'
];
// Fix followups and solutions
foreach
([
'glpi_itilfollowups'
,
'glpi_itilsolutions'
]
as
$itil_element_table
)
{
$elements_to_fix
=
$DB
->
request
(
[
'SELECT'
=>
[
'id'
,
'items_id'
,
'content'
],
'FROM'
=>
$itil_element_table
,
'WHERE'
=>
[
'itemtype'
=>
$itil_type
,
'content'
=>
[
'REGEXP'
,
$DB
->
escape
(
$missing_param_pattern
)],
]
]
);
foreach
(
$elements_to_fix
as
$data
)
{
$data
[
'content'
]
=
$DB
->
escape
(
$fix_content_fct
(
$data
[
'content'
],
$data
[
'items_id'
],
$itil_fkey
));
$DB
->
update
(
$itil_element_table
,
$data
,
[
'id'
=>
$data
[
'id'
]]);
}
}
// Fix tasks
$tasks_to_fix
=
$DB
->
request
(
[
'SELECT'
=>
[
'id'
,
$itil_fkey
,
'content'
],
'FROM'
=>
$task_table
,
'WHERE'
=>
[
'content'
=>
[
'REGEXP'
,
$DB
->
escape
(
$missing_param_pattern
)],
]
]
);
foreach
(
$tasks_to_fix
as
$data
)
{
$data
[
'content'
]
=
$DB
->
escape
(
$fix_content_fct
(
$data
[
'content'
],
$data
[
$itil_fkey
],
$itil_fkey
));
$DB
->
update
(
$task_table
,
$data
,
[
'id'
=>
$data
[
'id'
]]);
}
}
/** /Fix URL of images inside ITIL objects contents */
// ************ Keep it at the end **************
$migration
->
executeMigration
();
return
$updateresult
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment