Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
automatic_updates
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
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
project
automatic_updates
Merge requests
!339
Issue
#3285631
: Make it impossible to call CronUpdater::begin() directly
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3285631
: Make it impossible to call CronUpdater::begin() directly
issue/automatic_updates-3285631:3285631-make-it-impossible
into
8.x-2.x
Overview
11
Commits
12
Pipelines
0
Changes
4
All threads resolved!
Hide all comments
Merged
Theresa Grannum
requested to merge
issue/automatic_updates-3285631:3285631-make-it-impossible
into
8.x-2.x
2 years ago
Overview
11
Commits
12
Pipelines
0
Changes
24
All threads resolved!
Hide all comments
Expand
0
0
Merge request reports
Compare
version 3
version 9
2370b879
2 years ago
version 8
2590c429
2 years ago
version 7
74785510
2 years ago
version 6
fa273753
2 years ago
version 5
661648d9
2 years ago
version 4
dbb07e9d
2 years ago
version 3
ef677f05
2 years ago
version 2
b468744d
2 years ago
version 1
c9844ee4
2 years ago
8.x-2.x (base)
and
version 7
latest version
2370b879
12 commits,
2 years ago
version 9
2370b879
12 commits,
2 years ago
version 8
2590c429
11 commits,
2 years ago
version 7
74785510
9 commits,
2 years ago
version 6
fa273753
8 commits,
2 years ago
version 5
661648d9
7 commits,
2 years ago
version 4
dbb07e9d
6 commits,
2 years ago
version 3
ef677f05
4 commits,
2 years ago
version 2
b468744d
3 commits,
2 years ago
version 1
c9844ee4
2 commits,
2 years ago
Show latest version
24 files
+
457
−
209
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
24
Search (e.g. *.vue) (Ctrl+P)
package_manager/src/Validator/SymlinkValidator.php
0 → 100644
+
117
−
0
Options
<?php
namespace
Drupal\package_manager\Validator
;
use
Drupal\Core\StringTranslation\StringTranslationTrait
;
use
Drupal\package_manager
\Event\PreApplyEvent
;
use
Drupal\package_manager
\Event\PreCreateEvent
;
use
Drupal\package_manager
\Event\PreOperationStageEvent
;
use
Drupal\package_manager
\PathLocator
;
use
Symfony\Component\Finder\Finder
;
/**
* Flags errors if the project root or staging area contain symbolic links.
*
* @todo Remove this when Composer Stager's PHP file copier handles symlinks
* without issues.
*/
class
SymlinkValidator
implements
PreOperationStageValidatorInterface
{
use
StringTranslationTrait
;
/**
* The path locator service.
*
* @var \Drupal\package_manager\PathLocator
*/
protected
$pathLocator
;
/**
* Constructs a SymlinkValidator object.
*
* @param \Drupal\package_manager\PathLocator $path_locator
* The path locator service.
*/
public
function
__construct
(
PathLocator
$path_locator
)
{
$this
->
pathLocator
=
$path_locator
;
}
/**
* {@inheritdoc}
*/
public
function
validateStagePreOperation
(
PreOperationStageEvent
$event
):
void
{
$dir
=
$this
->
pathLocator
->
getProjectRoot
();
if
(
$this
->
hasLinks
(
$dir
))
{
$event
->
addError
([
$this
->
t
(
'Symbolic links were found in the active directory, which are not supported at this time.'
),
]);
}
}
/**
* Checks if the staging area has any symbolic links.
*
* @param \Drupal\package_manager\Event\PreApplyEvent $event
* The event object.
*/
public
function
preApply
(
PreApplyEvent
$event
):
void
{
$dir
=
$event
->
getStage
()
->
getStageDirectory
();
if
(
$this
->
hasLinks
(
$dir
))
{
$event
->
addError
([
$this
->
t
(
'Symbolic links were found in the staging area, which are not supported at this time.'
),
]);
}
}
/**
* Recursively checks if a directory has any symbolic links.
*
* @param string $dir
* The path of the directory to check.
*
* @return bool
* TRUE if the directory contains any symbolic links, FALSE otherwise.
*/
protected
function
hasLinks
(
string
$dir
):
bool
{
// Finder::filter() explicitly requires a closure, so create one from
// ::isLink() so that we can still override it for testing purposes.
$is_link
=
\Closure
::
fromCallable
([
$this
,
'isLink'
]);
// Finder::hasResults() is more efficient than count() because it will
// return early if there is a match.
return
Finder
::
create
()
->
in
(
$dir
)
->
filter
(
$is_link
)
->
ignoreUnreadableDirs
()
->
hasResults
();
}
/**
* Checks if a file or directory is a symbolic link.
*
* @param \SplFileInfo $file
* A value object for the file or directory.
*
* @return bool
* TRUE if the file or directory is a symbolic link, FALSE otherwise.
*/
protected
function
isLink
(
\SplFileInfo
$file
)
:
bool
{
return
$file
->
isLink
();
}
/**
* {@inheritdoc}
*/
public
static
function
getSubscribedEvents
()
{
return
[
PreCreateEvent
::
class
=>
'validateStagePreOperation'
,
PreApplyEvent
::
class
=>
[
[
'validateStagePreOperation'
],
[
'preApply'
],
],
];
}
}
Loading