Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Curriculum-Request
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tim Steiner
Curriculum-Request
Commits
f56abf7e
Commit
f56abf7e
authored
15 years ago
by
Tim Steiner
Browse files
Options
Downloads
Patches
Plain Diff
Reduce the number of calls to hash() and give it extra time to run.
parent
aa6ed868
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
application/modules/requests/models/RequestModel.php
+8
-19
8 additions, 19 deletions
application/modules/requests/models/RequestModel.php
with
8 additions
and
19 deletions
application/modules/requests/models/RequestModel.php
+
8
−
19
View file @
f56abf7e
...
...
@@ -513,13 +513,8 @@ class Requests_RequestModel extends Unl_Model
$sqlParts
=
array
();
foreach
(
$models
as
$model
)
{
$file
=
$model
[
'model'
]
->
_data
[
'files'
][
$model
[
'fileId'
]];
$file
[
'hash'
]
=
hash
(
'whirlpool'
,
$file
[
'data'
]);
if
(
strlen
(
$file
[
'data'
])
>=
0
)
{
self
::
_saveFileToDisk
(
$file
[
'data'
]);
$file
[
'data'
]
=
"''"
;
}
else
{
$file
[
'data'
]
=
'0x'
.
bin2hex
(
$file
[
'data'
]);
}
$file
[
'hash'
]
=
self
::
_saveFileToDisk
(
$file
[
'data'
]);
$file
[
'data'
]
=
"''"
;
$sqlParts
[]
=
$db
->
quoteInto
(
'(?, '
,
$file
[
'title'
])
.
$db
->
quoteInto
(
'?, '
,
$file
[
'mimeType'
])
.
$file
[
'data'
]
.
', '
...
...
@@ -570,13 +565,8 @@ class Requests_RequestModel extends Unl_Model
$sqlParts
=
array
();
foreach
(
$models
as
$model
)
{
$file
=
$model
[
'model'
]
->
_data
[
'files'
][
$model
[
'fileId'
]];
$file
[
'hash'
]
=
hash
(
'whirlpool'
,
$file
[
'data'
]);
if
(
strlen
(
$file
[
'data'
])
>=
0
)
{
self
::
_saveFileToDisk
(
$file
[
'data'
]);
$file
[
'data'
]
=
"''"
;
}
else
{
$file
[
'data'
]
=
'0x'
.
bin2hex
(
$file
[
'data'
]);
}
$file
[
'hash'
]
=
self
::
_saveFileToDisk
(
$file
[
'data'
]);
$file
[
'data'
]
=
"''"
;
$sqlParts
[]
=
$db
->
quoteInto
(
'(?, '
,
$file
[
'fileId'
])
.
$db
->
quoteInto
(
'?, '
,
$file
[
'title'
])
.
$db
->
quoteInto
(
'?, '
,
$file
[
'mimeType'
])
...
...
@@ -654,6 +644,7 @@ class Requests_RequestModel extends Unl_Model
static
protected
function
_saveFileToDisk
(
$data
)
{
set_time_limit
(
30
);
// hash function may take a while... give it time
$hash
=
hash
(
'whirlpool'
,
$data
);
$path
=
APPLICATION_DIR
.
DIRECTORY_SEPARATOR
...
...
@@ -667,6 +658,7 @@ class Requests_RequestModel extends Unl_Model
@
mkdir
(
$path
,
0755
,
true
);
}
file_put_contents
(
$path
.
DIRECTORY_SEPARATOR
.
$hash
,
$data
);
return
$hash
;
}
static
protected
function
_loadFileFromDisk
(
$hash
)
...
...
@@ -855,8 +847,7 @@ class Requests_RequestModel extends Unl_Model
'type'
=>
$type
,
'title'
=>
$title
,
'mimeType'
=>
$mimeType
,
'data'
=>
$data
,
'hash'
=>
hash
(
'whirlpool'
,
$data
)
'data'
=>
$data
);
$this
->
_data
[
'files'
][
$lowestId
]
=
$newFile
;
...
...
@@ -870,7 +861,6 @@ class Requests_RequestModel extends Unl_Model
$this
->
_data
[
'files'
][
$id
][
'title'
]
=
$title
;
$this
->
_data
[
'files'
][
$id
][
'mimeType'
]
=
$mimeType
;
$this
->
_data
[
'files'
][
$id
][
'data'
]
=
$data
;
$this
->
_data
[
'files'
][
$id
][
'hash'
]
=
hash
(
'whirlpool'
,
$data
);
$found
=
true
;
}
...
...
@@ -891,8 +881,7 @@ class Requests_RequestModel extends Unl_Model
'type'
=>
$type
,
'title'
=>
$title
,
'mimeType'
=>
$mimeType
,
'data'
=>
$data
,
'hash'
=>
hash
(
'whirlpool'
,
$data
)
'data'
=>
$data
);
$this
->
_data
[
'files'
][
$lowestId
]
=
$newFile
;
...
...
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