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
570a8343
Commit
570a8343
authored
12 years ago
by
Peter Rotich
Browse files
Options
Downloads
Patches
Plain Diff
Add timer to upgrader
parent
b1867503
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/class.upgrader.php
+26
-7
26 additions, 7 deletions
include/class.upgrader.php
with
26 additions
and
7 deletions
include/class.upgrader.php
+
26
−
7
View file @
570a8343
...
...
@@ -31,6 +31,10 @@ class Upgrader extends SetupWizard {
$this
->
sqldir
=
$sqldir
;
$this
->
errors
=
array
();
//Disable time limit if - safe mode is set.
if
(
!
ini_get
(
'safe_mode'
))
set_time_limit
(
0
);
//Init persistent state of upgrade.
$this
->
state
=
&
$_SESSION
[
'ost_upgrader'
][
$this
->
getShash
()][
'state'
];
...
...
@@ -180,6 +184,7 @@ class Upgrader extends SetupWizard {
if
(
!
(
$tasks
=
$this
->
getPendingTasks
()))
return
true
;
//Nothing to do.
$start_time
=
Misc
::
micro_time
();
foreach
(
$tasks
as
$k
=>
$task
)
{
//TODO: check time used vs. max execution - break if need be
if
(
call_user_func
(
array
(
$this
,
$task
[
'func'
]),
$k
)
===
0
)
{
...
...
@@ -198,6 +203,10 @@ class Upgrader extends SetupWizard {
if
(
$this
->
getPendingTasks
()
||
!
(
$patches
=
$this
->
getPatches
()))
return
false
;
$start_time
=
Misc
::
micro_time
();
if
(
!
(
$max_time
=
ini_get
(
'max_execution_time'
)))
$max_time
=
300
;
//Apache/IIS defaults.
foreach
(
$patches
as
$patch
)
{
//TODO: check time used vs. max execution - break if need be
if
(
!
$this
->
load_sql_file
(
$patch
,
$this
->
getTablePrefix
()))
...
...
@@ -216,14 +225,21 @@ class Upgrader extends SetupWizard {
$ost
->
logDebug
(
'Upgrader - Patch applied'
,
$logMsg
);
//Check if the said patch has scripted tasks
if
(
!
(
$tasks
=
$this
->
getTasksForPatch
(
$phash
)))
if
(
!
(
$tasks
=
$this
->
getTasksForPatch
(
$phash
)))
{
//Break IF elapsed time is greater than 80% max time allowed.
if
((
$elapsedtime
=
(
Misc
::
micro_time
()
-
$start_time
))
&&
$max_time
&&
$elapsedtime
>
(
$max_time
*
0.80
))
break
;
continue
;
}
//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'
;
break
;
}
return
true
;
...
...
@@ -250,7 +266,7 @@ class Upgrader extends SetupWizard {
}
/************* TASKS **********************/
function
cleanup
(
$tId
=
0
)
{
function
cleanup
(
$t
ask
Id
)
{
$file
=
$this
->
getSQLDir
()
.
$this
->
getShash
()
.
'-cleanup.sql'
;
if
(
!
file_exists
(
$file
))
//No cleanup script.
...
...
@@ -264,13 +280,16 @@ class Upgrader extends SetupWizard {
return
false
;
}
function
migrateAttachments2DB
(
$tId
=
0
)
{
function
migrateAttachments2DB
(
$t
ask
Id
)
{
if
(
!
(
$max_time
=
ini_get
(
'max_execution_time'
)))
$max_time
=
30
;
//Default to 30 sec batches.
$att_migrater
=
new
AttachmentMigrater
();
$att_migrater
->
start_migration
();
# XXX: Loop here (with help of task manager)
$att_migrater
->
do_batch
();
return
0
;
if
(
$att_migrater
->
do_batch
((
$max_time
*
0.9
),
100
)
===
0
)
return
0
;
return
$att_migrater
->
getQueueLength
()
;
}
}
?>
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