Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
digit-joinup-reference
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review 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
ec-europa
digit-joinup-reference
Commits
ac9c50f5
Commit
ac9c50f5
authored
7 months ago
by
Zoltan Horvath
Browse files
Options
Downloads
Patches
Plain Diff
ISAICP-9076: Add update hook.
parent
0b3ac231
No related branches found
No related tags found
1 merge request
!188
Patch release v1.112.3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
web/modules/custom/joinup_core/joinup_core.deploy.php
+47
-0
47 additions, 0 deletions
web/modules/custom/joinup_core/joinup_core.deploy.php
with
47 additions
and
0 deletions
web/modules/custom/joinup_core/joinup_core.deploy.php
+
47
−
0
View file @
ac9c50f5
...
...
@@ -13,3 +13,50 @@
*/
declare
(
strict_types
=
1
);
use
Drupal\joinup_release
\Entity\ReleaseInterface
;
use
Drupal\pathauto\PathautoState
;
/**
* Fix releases without version string and regenerate their path aliases.
*/
function
joinup_core_deploy_111300
():
string
{
$entityTypeManager
=
\Drupal
::
entityTypeManager
();
$nodeStorage
=
\Drupal
::
entityTypeManager
()
->
getStorage
(
'node'
);
$pathAliasStorage
=
$entityTypeManager
->
getStorage
(
'path_alias'
);
$releaseIdsWithoutVersion
=
$nodeStorage
->
getQuery
()
->
accessCheck
(
FALSE
)
->
condition
(
'type'
,
'release'
)
->
notExists
(
'release_number'
)
->
execute
();
$changedReleaseCount
=
0
;
foreach
(
$nodeStorage
->
loadMultiple
(
$releaseIdsWithoutVersion
)
as
$release
)
{
assert
(
$release
instanceof
ReleaseInterface
);
assert
(
$release
->
get
(
'release_number'
)
->
isEmpty
());
// Skip doing anything to releases whose alias does not end with /release -
// so we don't touch releases having aliases ending with /release-0,
// /release-1 etc.: these aliases are harmless.
$pathField
=
$release
->
get
(
'path'
);
if
(
!
is_string
(
$pathField
->
alias
)
||
!
str_ends_with
(
$pathField
->
alias
,
'/release'
))
{
continue
;
}
// Delete the preexisting alias so Redirect module won't create a redirect
// (which causes the same issue what we're solving here).
if
(
$aliasId
=
$pathField
->
pid
)
{
$pathAliasStorage
->
load
(
$aliasId
)
->
delete
();
}
$release
->
skip_notification
=
TRUE
;
$release
->
set
(
'release_number'
,
'no-version'
)
->
set
(
'path'
,
[
'pathauto'
=>
PathautoState
::
CREATE
])
->
save
();
$changedReleaseCount
++
;
}
return
sprintf
(
"Added 'no-version' to %s releases which lack version number with an alias ending with '/release'; and re-generated their aliases"
,
$changedReleaseCount
,
);
}
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