Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Inlay
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Extensions
Inlay
Commits
8d4d0b1b
Commit
8d4d0b1b
authored
1 year ago
by
Rich Lott / Artful Robot
Browse files
Options
Downloads
Patches
Plain Diff
Delete old inlay bundles that have no instance configured
parent
2ef69298
Branches
master
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Civi/Api4/Action/Inlay/CreateBundle.php
+22
-0
22 additions, 0 deletions
Civi/Api4/Action/Inlay/CreateBundle.php
docs/reference/changes.md
+4
-0
4 additions, 0 deletions
docs/reference/changes.md
with
26 additions
and
0 deletions
Civi/Api4/Action/Inlay/CreateBundle.php
+
22
−
0
View file @
8d4d0b1b
...
...
@@ -26,6 +26,7 @@ class CreateBundle extends \Civi\Api4\Generic\AbstractQueryAction {
* @inheritDoc
*/
public
function
_run
(
Result
$result
)
{
$recs
=
$this
->
getBatchRecords
();
$inlayConfig
=
InlayConfig
::
singleton
();
$settings
=
$inlayConfig
->
getSettings
();
...
...
@@ -39,6 +40,7 @@ class CreateBundle extends \Civi\Api4\Generic\AbstractQueryAction {
$common
=
[
'inlayEndpoint'
=>
$inlayConfig
->
getApiEndPoint
()];
foreach
(
$recs
as
$rec
)
{
if
(
empty
(
$rec
[
'error'
]))
{
...
...
@@ -108,6 +110,26 @@ class CreateBundle extends \Civi\Api4\Generic\AbstractQueryAction {
$url
=
$inlay
->
getBundleUrl
();
$result
[]
=
[
'id'
=>
$inlay
->
getID
(),
'public_id'
=>
$inlay
->
getPublicID
(),
'type'
=>
$inlay
->
getTypeName
(),
'name'
=>
$inlay
->
getName
(),
'javascript'
=>
$url
];
}
if
(
empty
(
$this
->
where
)
&&
empty
(
$this
->
limit
)
&&
empty
(
$this
->
offset
))
{
// We know of every inlay.
$valid
=
$result
->
column
(
'public_id'
);
$filenameStub
=
Civi
::
paths
()
->
getPath
(
"[civicrm.files]/inlay-"
);
$foundFiles
=
glob
(
$filenameStub
.
'*.js'
);
foreach
(
$foundFiles
as
$file
)
{
$foundPublidID
=
substr
(
substr
(
$file
,
strlen
(
$filenameStub
)),
0
,
-
3
);
if
(
!
in_array
(
$foundPublidID
,
$valid
))
{
$mtime
=
date
(
'H:i j M Y'
,
filemtime
(
$file
));
if
(
preg_match
(
'/^[0-9a-FA-F]{12}$/'
,
$foundPublidID
))
{
unlink
(
$file
);
\Civi
::
log
()
->
warning
(
"Deleted old inlay bundle for
$foundPublidID
\n
at
$file
updated
$mtime
as it has no definition."
);
}
else
{
\Civi
::
log
()
->
warning
(
"Found unrecognised inlay file at
$file
(updated
$mtime
). Consider deleting this."
);
}
}
}
}
}
/**
...
...
This diff is collapsed.
Click to expand it.
docs/reference/changes.md
+
4
−
0
View file @
8d4d0b1b
...
...
@@ -10,6 +10,10 @@
saving to update the bundle. This can be useful in an upgrader step.
-
Adds Inlay.get API parameter to get the config array without validating
(useful for upgrader scripts).
-
Fixed a bug that meant certain API updates might give inlays a new public
ID (meaning anyone using the original code would always get the out of date one!)
-
Inlay .js bundles without config are now deleted when found, after
bundle updates by cron.
## 1.3.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