Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sg_mail
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
TYPO3
sg_mail
Commits
d479cf3f
Commit
d479cf3f
authored
7 years ago
by
Torsten Oppermann
Browse files
Options
Downloads
Patches
Plain Diff
[TASK] Staring work on new upgrade wizard
parent
2c0dd4e0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!3
New version 4 1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Classes/Updates/UpdatePidToSiteRoot.php
+63
-11
63 additions, 11 deletions
Classes/Updates/UpdatePidToSiteRoot.php
with
63 additions
and
11 deletions
Classes/Updates/UpdatePidToSiteRoot.php
+
63
−
11
View file @
d479cf3f
...
...
@@ -65,14 +65,7 @@ class UpdatePidToSiteRoot extends AbstractUpdate {
// check if site_root columns actually exist
$hasColumn
=
[];
foreach
(
$this
->
tables
as
$table
)
{
$hasColumn
[
$table
]
=
FALSE
;
$result
=
$databaseConnection
->
admin_get_fields
(
$table
);
foreach
(
$result
as
$column
)
{
if
(
$column
[
'Field'
]
===
'site_root_id'
)
{
$hasColumn
[
$table
]
=
TRUE
;
}
}
$hasColumn
[
$table
]
=
$this
->
siteRootColumnExists
(
$table
);
}
// are there site root columns differing from pids?
...
...
@@ -94,14 +87,12 @@ class UpdatePidToSiteRoot extends AbstractUpdate {
foreach
(
$result
as
$row
)
{
$siteRootId
=
BackendService
::
getSiteRoot
(
$row
[
0
]);
if
(
$siteRootId
!==
$row
[
0
])
{
return
TRUE
;
}
}
}
$this
->
isWizardDone
();
return
FALSE
;
return
!
(
!
FALSE
||
$this
->
isWizardDone
());
}
/**
...
...
@@ -112,7 +103,68 @@ class UpdatePidToSiteRoot extends AbstractUpdate {
* @return bool Whether everything went smoothly or not
*/
public
function
performUpdate
(
array
&
$dbQueries
,
&
$customMessages
)
{
/** @var DatabaseConnection $databaseConnection */
$databaseConnection
=
$GLOBALS
[
'TYPO3_DB'
];
$dbQueries
=
[];
// set pids to siteroot
foreach
(
$this
->
tables
as
$table
)
{
if
(
!
$this
->
siteRootColumnExists
(
$table
))
{
continue
;
}
$result
=
$databaseConnection
->
exec_SELECTquery
(
'uid, site_root_id'
,
$table
,
''
)
->
fetch_all
();
$dbQueries
[]
=
$databaseConnection
->
debug_lastBuiltQuery
;
/** @var array $result */
foreach
(
$result
as
$row
)
{
$where
=
'uid = '
.
$row
[
0
];
$databaseConnection
->
exec_UPDATEquery
(
$table
,
$where
,
[
'pid'
=>
$row
[
1
]]);
$dbQueries
[]
=
$databaseConnection
->
debug_lastBuiltQuery
;
}
}
// check if pid is a site root, if not update it to the nearest one
foreach
(
$this
->
tables
as
$table
)
{
$result
=
$databaseConnection
->
exec_SELECTquery
(
'uid, pid'
,
$table
,
''
)
->
fetch_all
();
$dbQueries
[]
=
$databaseConnection
->
debug_lastBuiltQuery
;
/** @var array $result */
foreach
(
$result
as
$row
)
{
$siteRootId
=
BackendService
::
getSiteRoot
(
$row
[
1
]);
if
(
$siteRootId
!==
(
int
)
$row
[
1
])
{
if
(
$siteRootId
===
0
)
{
$siteRootId
=
1
;
}
$where
=
'uid = '
.
$row
[
0
];
$databaseConnection
->
exec_UPDATEquery
(
$table
,
$where
,
[
'pid'
=>
$siteRootId
]);
$dbQueries
[]
=
$databaseConnection
->
debug_lastBuiltQuery
;
}
}
}
$this
->
markWizardAsDone
();
return
TRUE
;
}
/**
* check if site_root columns actually exist
*
* @param $table
* @return bool
*/
private
function
siteRootColumnExists
(
$table
)
{
/** @var DatabaseConnection $databaseConnection */
$databaseConnection
=
$GLOBALS
[
'TYPO3_DB'
];
$result
=
$databaseConnection
->
admin_get_fields
(
$table
);
foreach
(
$result
as
$column
)
{
if
(
$column
[
'Field'
]
===
'site_root_id'
)
{
return
TRUE
;
}
}
return
FALSE
;
}
}
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