Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
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
Development
CiviCRM Core
Commits
d4fae014
Unverified
Commit
d4fae014
authored
1 month ago
by
DaveD
Committed by
GitHub
1 month ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #32332 from colemanw/upload_date
File - set default in sql for upload_date
parents
71268228
cb4958ec
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Upgrade/Incremental/php/SixTwo.php
+32
-0
32 additions, 0 deletions
CRM/Upgrade/Incremental/php/SixTwo.php
schema/Core/File.entityType.php
+3
-0
3 additions, 0 deletions
schema/Core/File.entityType.php
with
35 additions
and
0 deletions
CRM/Upgrade/Incremental/php/SixTwo.php
+
32
−
0
View file @
d4fae014
...
...
@@ -29,6 +29,38 @@ class CRM_Upgrade_Incremental_php_SixTwo extends CRM_Upgrade_Incremental_Base {
*/
public
function
upgrade_6_2_alpha1
(
$rev
):
void
{
$this
->
addTask
(
ts
(
'Upgrade DB to %1: SQL'
,
[
1
=>
$rev
]),
'runSql'
,
$rev
);
$this
->
addTask
(
'Set upload_date in file table'
,
'setFileUploadDate'
);
$this
->
addTask
(
'Set default for upload_date in file table'
,
'alterSchemaField'
,
'File'
,
'upload_date'
,
[
'title'
=>
ts
(
'File Upload Date'
),
'sql_type'
=>
'datetime'
,
'input_type'
=>
'Select Date'
,
'required'
=>
TRUE
,
'readonly'
=>
TRUE
,
'default'
=>
'CURRENT_TIMESTAMP'
,
'description'
=>
ts
(
'Date and time that this attachment was uploaded or written to server.'
),
]);
}
public
static
function
setFileUploadDate
():
bool
{
$sql
=
'SELECT id, uri FROM civicrm_file WHERE upload_date IS NULL'
;
$dao
=
CRM_Core_DAO
::
executeQuery
(
$sql
);
$dir
=
CRM_Core_Config
::
singleton
()
->
customFileUploadDir
;
while
(
$dao
->
fetch
())
{
$fileCreatedDate
=
time
();
if
(
$dao
->
uri
)
{
$filePath
=
$dir
.
$dao
->
uri
;
// Get created date from file if possible
if
(
is_file
(
$filePath
))
{
$fileCreatedDate
=
filectime
(
$filePath
);
}
}
CRM_Core_DAO
::
executeQuery
(
'UPDATE civicrm_file SET upload_date = %1 WHERE id = %2'
,
[
1
=>
[
date
(
'YmdHis'
,
$fileCreatedDate
),
'Date'
],
2
=>
[
$dao
->
id
,
'Integer'
],
]);
}
return
TRUE
;
}
}
This diff is collapsed.
Click to expand it.
schema/Core/File.entityType.php
+
3
−
0
View file @
d4fae014
...
...
@@ -64,6 +64,9 @@ return [
'title'
=>
ts
(
'File Upload Date'
),
'sql_type'
=>
'datetime'
,
'input_type'
=>
'Select Date'
,
'required'
=>
TRUE
,
'readonly'
=>
TRUE
,
'default'
=>
'CURRENT_TIMESTAMP'
,
'description'
=>
ts
(
'Date and time that this attachment was uploaded or written to server.'
),
'add'
=>
'1.5'
,
],
...
...
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