Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
osticket
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
docker
osticket
Commits
679b6d91
Commit
679b6d91
authored
12 years ago
by
Peter Rotich
Browse files
Options
Downloads
Patches
Plain Diff
Add error logging to upgrader
parent
b97e2b88
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
setup/inc/class.setup.php
+12
-13
12 additions, 13 deletions
setup/inc/class.setup.php
setup/inc/class.upgrader.php
+12
-5
12 additions, 5 deletions
setup/inc/class.upgrader.php
with
24 additions
and
18 deletions
setup/inc/class.setup.php
+
12
−
13
View file @
679b6d91
...
...
@@ -34,7 +34,7 @@ Class SetupWizard {
function
load_sql_file
(
$file
,
$prefix
,
$abort
=
true
,
$debug
=
false
)
{
if
(
!
file_exists
(
$file
)
||
!
(
$schema
=
file_get_contents
(
$file
)))
return
$this
->
abort
(
'Error accessing SQL file '
.
basename
(
$file
));
return
$this
->
abort
(
'Error accessing SQL file '
.
basename
(
$file
)
,
$debug
);
return
$this
->
load_sql
(
$schema
,
$prefix
,
$abort
,
$debug
);
}
...
...
@@ -45,21 +45,20 @@ Class SetupWizard {
function
load_sql
(
$schema
,
$prefix
,
$abort
=
true
,
$debug
=
false
)
{
# Strip comments and remarks
$schema
=
preg_replace
(
'%^\s*(#|--).*$%m'
,
''
,
$schema
);
$schema
=
preg_replace
(
'%^\s*(#|--).*$%m'
,
''
,
$schema
);
# Replace table prefis
$schema
=
str_replace
(
'%TABLE_PREFIX%'
,
$prefix
,
$schema
);
$schema
=
str_replace
(
'%TABLE_PREFIX%'
,
$prefix
,
$schema
);
# Split by semicolons - and cleanup
if
(
!
(
$statements
=
array_filter
(
array_map
(
'trim'
,
@
explode
(
';'
,
$schema
)))))
return
$this
->
abort
(
'Error parsing SQL schema'
);
return
$this
->
abort
(
'Error parsing SQL schema'
,
$debug
);
@
mysql_query
(
'SET SESSION SQL_MODE =""'
);
foreach
(
$statements
as
$k
=>
$sql
)
{
if
(
!
mysql_query
(
$sql
))
{
if
(
$debug
)
echo
"[
$sql
]=>"
.
mysql_error
();
if
(
$abort
)
return
$this
->
abort
(
"[
$sql
] - "
.
mysql_error
());
}
if
(
mysql_query
(
$sql
))
continue
;
$error
=
"[
$sql
] "
.
mysql_error
();
if
(
$abort
)
return
$this
->
abort
(
$error
,
$debug
);
}
return
true
;
...
...
@@ -82,7 +81,7 @@ Class SetupWizard {
}
function
check_php
()
{
return
(
version_compare
(
PHP_VERSION
,
$this
->
getPHPVersion
())
>=
0
);
return
(
version_compare
(
PHP_VERSION
,
$this
->
getPHPVersion
())
>=
0
);
}
function
check_mysql
()
{
...
...
@@ -96,8 +95,9 @@ Class SetupWizard {
/*
@error is a mixed var.
*/
function
abort
(
$error
)
{
function
abort
(
$error
,
$debug
=
false
)
{
if
(
$debug
)
echo
$error
;
$this
->
onError
(
$error
);
return
false
;
// Always false... It's an abort.
...
...
@@ -106,13 +106,12 @@ Class SetupWizard {
function
setError
(
$error
)
{
if
(
$error
&&
is_array
(
$error
))
$this
->
errors
=
array_merge
(
$this
->
errors
,
$error
);
$this
->
errors
=
array_merge
(
$this
->
errors
,
$error
);
elseif
(
$error
)
$this
->
errors
[]
=
$error
;
}
function
getErrors
(){
return
$this
->
errors
;
}
...
...
This diff is collapsed.
Click to expand it.
setup/inc/class.upgrader.php
+
12
−
5
View file @
679b6d91
...
...
@@ -50,6 +50,8 @@ class Upgrader extends SetupWizard {
}
function
onError
(
$error
)
{
Sys
::
log
(
LOG_ERR
,
'Upgrader Error'
,
$error
);
$this
->
setError
(
$error
);
$this
->
setState
(
'aborted'
);
}
...
...
@@ -197,18 +199,23 @@ class Upgrader extends SetupWizard {
if
(
!
$this
->
load_sql_file
(
$patch
,
$this
->
getTablePrefix
()))
return
false
;
//TODO: Log the upgrade
//clear previous patch info -
unset
(
$_SESSION
[
'ost_upgrader'
][
$this
->
getShash
()]);
//Load up post-upgrade tasks.... if any.
$phash
=
substr
(
basename
(
$patch
),
0
,
17
);
//Log the patch info
$logMsg
=
"Patch
$phash
applied "
;
if
((
$info
=
$this
->
readPatchInfo
(
$patch
))
&&
$info
[
'version'
])
$logMsg
.
=
' ('
.
$info
[
'version'
]
.
') '
;
Sys
::
log
(
LOG_DEBUG
,
'Upgrader - Patch applied'
,
$logMsg
);
//Check if the said patch has scripted tasks
if
(
!
(
$tasks
=
$this
->
getTasksForPatch
(
$phash
)))
continue
;
//We have
tasks to perform -
set the tasks and break.
//We have
work to do...
set the tasks and break.
$shash
=
substr
(
$phash
,
9
,
8
);
$_SESSION
[
'ost_upgrader'
][
$shash
][
'tasks'
]
=
$tasks
;
$_SESSION
[
'ost_upgrader'
][
$shash
][
'state'
]
=
'upgrade'
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment