Skip to content

Commit e1a1156

Browse files
committed
transpile #769
Transpile fixes and updates from main branch.
1 parent 95ce98c commit e1a1156

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+215
-113
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
44

55
## [unreleased] Unreleased
66

7+
### Fixed
8+
9+
- Ensure plugin activation is respected indifferent of plugins that might deactivate others during activation.
10+
711
## [3.7.10] 2024-11-29;
812

913
## Fixed

config/typos.toml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ extend-exclude = [
33
".git/",
44
"includes/",
55
"vendor/",
6+
"tests/_data"
67
]
78
ignore-hidden = false
89

includes/opis/closure/src/ReflectionClosure.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ReflectionClosure extends ReflectionFunction
4040
*
4141
* @throws \ReflectionException
4242
*/
43-
public function __construct(Closure $closure, string $code = null)
43+
public function __construct(Closure $closure, ?string $code = null)
4444
{
4545
parent::__construct($closure);
4646
}

includes/opis/closure/src/SerializableClosure.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ public static function getSecurityProvider(): ?ISecurityProvider
321321
*
322322
* @internal
323323
*/
324-
public static function wrapClosures(&$data, SplObjectStorage $storage = null)
324+
public static function wrapClosures(&$data, ?SplObjectStorage $storage = null)
325325
{
326326
if ($storage === null) {
327327
$storage = static::$context->scope;
@@ -395,7 +395,7 @@ public static function wrapClosures(&$data, SplObjectStorage $storage = null)
395395
*
396396
* @internal
397397
*/
398-
public static function unwrapClosures(&$data, SplObjectStorage $storage = null)
398+
public static function unwrapClosures(&$data, ?SplObjectStorage $storage = null)
399399
{
400400
if ($storage === null) {
401401
$storage = static::$context->scope;

src/Adapters/Symfony/Component/Process/Process.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ class Process extends SymfonyProcess
2727
*/
2828
public function __construct(
2929
array $command,
30-
string $cwd = null,
31-
array $env = null,
30+
?string $cwd = null,
31+
?array $env = null,
3232
$input = null,
3333
?float $timeout = 60,
34-
array $options = null
34+
?array $options = null
3535
) {
3636
parent::__construct($command, $cwd, $env, $input, $timeout, $options); //@phpstan-ignore-line
3737

src/Events/Dispatcher.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Dispatcher
1717
*/
1818
private static $eventDispatcher;
1919

20-
public static function setEventDispatcher(EventDispatcherInterface $eventDispatcher = null): void
20+
public static function setEventDispatcher(?EventDispatcherInterface $eventDispatcher = null): void
2121
{
2222
$previousEventDispatcher = self::$eventDispatcher;
2323

src/ManagedProcess/MysqlServer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class MysqlServer implements ManagedProcessInterface
8585
/**
8686
* @throws RuntimeException
8787
*/
88-
public function __construct(string $directory = null, int $port = self::PORT_DEFAULT, string $database = 'wordpress', string $user = 'wordpress', string $password = 'wordpress', ?string $binary = null, ?string $shareDir = null)
88+
public function __construct(?string $directory = null, int $port = self::PORT_DEFAULT, string $database = 'wordpress', string $user = 'wordpress', string $password = 'wordpress', ?string $binary = null, ?string $shareDir = null)
8989
{
9090
$this->port = $port;
9191
$this->database = $database;
@@ -584,7 +584,7 @@ public function isUsingCustomBinary(): bool
584584
return $this->usingCustomBinary;
585585
}
586586

587-
public function setOutput(OutputInterface $output = null): void
587+
public function setOutput(?OutputInterface $output = null): void
588588
{
589589
$this->output = $output;
590590
}

src/Module/Support/DbDump.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public function getOriginalUrlFromSqlString(string $sql)
304304
* @param string|null $originalUrl The site URL that should be replaced in the dump, or `null` to unset the
305305
* property.
306306
*/
307-
public function setOriginalUrl(string $originalUrl = null): void
307+
public function setOriginalUrl(?string $originalUrl = null): void
308308
{
309309
if ($originalUrl === null) {
310310
$this->originalUrl = null;

src/Module/WPBrowserMethods.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function _initialize(): void
132132
*
133133
* @return FacebookWebdriverCookie|Cookie|null The WordPress authorization cookie or `null` if not found.
134134
*/
135-
protected function grabWordPressAuthCookie(string $pattern = null)
135+
protected function grabWordPressAuthCookie(?string $pattern = null)
136136
{
137137
$pattern = $pattern ?: '/^wordpress_[a-z0-9]{32}$/';
138138
$cookies = $this->grabCookiesWithPattern($pattern);
@@ -147,7 +147,7 @@ protected function grabWordPressAuthCookie(string $pattern = null)
147147
*
148148
* @return FacebookWebdriverCookie|Cookie|null The WordPress login cookie or `null` if not found.
149149
*/
150-
protected function grabWordPressLoginCookie(string $pattern = null)
150+
protected function grabWordPressLoginCookie(?string $pattern = null)
151151
{
152152
$pattern = $pattern ?: '/^wordpress_logged_in_[a-z0-9]{32}$/';
153153
$cookies = $this->grabCookiesWithPattern($pattern);
@@ -365,7 +365,7 @@ public function seeMessage($classes = ''): void
365365
*
366366
* @return Cookie|null Either a cookie object or `null`.
367367
*/
368-
public function grabWordPressTestCookie(string $name = null): ?Cookie
368+
public function grabWordPressTestCookie(?string $name = null): ?Cookie
369369
{
370370
$name = $name ?: 'wordpress_test_cookie';
371371

src/Module/WPCLI.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public function grabLastShellErrorOutput(): string
286286
*/
287287
public function cliToArray(
288288
array $command,
289-
callable $splitCallback = null,
289+
?callable $splitCallback = null,
290290
?array $env = null,
291291
$input = null
292292
): array {

src/Module/WPDb.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ class WPDb extends Db
216216
*
217217
* @return void
218218
*/
219-
public function __construct(ModuleContainer $moduleContainer, ?array $config = null, DbDump $dbDump = null)
219+
public function __construct(ModuleContainer $moduleContainer, ?array $config = null, ?DbDump $dbDump = null)
220220
{
221221
parent::__construct($moduleContainer, $config);
222222
$this->dbDump = $dbDump ?? new DbDump();
@@ -356,7 +356,7 @@ protected function validateConfig(): void
356356
*
357357
* @throws ModuleException It the database cannot be correctly initialized.
358358
*/
359-
public function _initialize(Tables $table = null): void
359+
public function _initialize(?Tables $table = null): void
360360
{
361361
/**
362362
* Dispatches an event before the WPDb module initializes.
@@ -396,7 +396,7 @@ public function _initialize(Tables $table = null): void
396396
*
397397
* @throws ModuleConfigException|ModuleException If there's an issue during the cleanup phase.
398398
*/
399-
public function importSqlDumpFile(string $dumpFile = null): void
399+
public function importSqlDumpFile(?string $dumpFile = null): void
400400
{
401401
if ($dumpFile !== null) {
402402
if (!is_file($dumpFile) || !is_readable($dumpFile)) {
@@ -611,8 +611,8 @@ public function dontSeePostMetaInDatabase(array $criteria): void
611611
public function seePostWithTermInDatabase(
612612
int $post_id,
613613
int $term_taxonomy_id,
614-
int $term_order = null,
615-
string $taxonomy = null
614+
?int $term_order = null,
615+
?string $taxonomy = null
616616
): void {
617617
if ($taxonomy !== null) {
618618
$match = $this->grabTermTaxonomyIdFromDatabase([
@@ -3574,7 +3574,7 @@ public function dontSeeBlogInDatabase(array $criteria): void
35743574
* @param string|null $themeName The theme name, e.g. `Acme`, defaults to the "title" version of
35753575
* `$stylesheet`.
35763576
*/
3577-
public function useTheme(string $stylesheet, string $template = null, string $themeName = null): void
3577+
public function useTheme(string $stylesheet, ?string $template = null, ?string $themeName = null): void
35783578
{
35793579
$template = $template ?: $stylesheet;
35803580
$themeName = $themeName ?: ucwords($stylesheet, ' _');
@@ -3654,7 +3654,7 @@ public function haveMenuInDatabase(string $slug, string $location, array $overri
36543654
public function haveMenuItemInDatabase(
36553655
string $menuSlug,
36563656
string $title,
3657-
int $menuOrder = null,
3657+
?int $menuOrder = null,
36583658
array $meta = []
36593659
): int {
36603660
if (empty($this->stylesheet)) {
@@ -3751,7 +3751,7 @@ public function haveAttachmentInDatabase(
37513751
string $file,
37523752
$date = 'now',
37533753
array $overrides = [],
3754-
array $imageSizes = null
3754+
?array $imageSizes = null
37553755
): int {
37563756
if (!class_exists(ImageResize::class)) {
37573757
$message = 'The "haveAttachmentInDatabase" method requires the "gumlet/php-image-resize:^1.6" package.' .
@@ -3902,7 +3902,7 @@ public function haveAttachmentInDatabase(
39023902
*
39033903
* @return string The current site URL
39043904
*/
3905-
public function grabSiteUrl(string $path = null): string
3905+
public function grabSiteUrl(?string $path = null): string
39063906
{
39073907
/** @var array{url: string} $config Validated module config. */
39083908
$config = $this->config;
@@ -4528,8 +4528,8 @@ public function _loadDump($databaseKey = null, $databaseConfig = null)
45284528
public function dontSeePostWithTermInDatabase(
45294529
int $post_id,
45304530
int $term_taxonomy_id,
4531-
int $term_order = null,
4532-
string $taxonomy = null
4531+
?int $term_order = null,
4532+
?string $taxonomy = null
45334533
): void {
45344534
if ($taxonomy !== null) {
45354535
$match = $this->grabTermTaxonomyIdFromDatabase([

src/Module/WPFilesystem.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ public function deleteUploadedFile(string $file, $date = null): void
501501
*
502502
* @param string|null $dir The path to the directory to delete, relative to the uploads folder.
503503
*/
504-
public function cleanUploadsDir(string $dir = null, $date = null): void
504+
public function cleanUploadsDir(?string $dir = null, $date = null): void
505505
{
506506
$dir = null === $dir ? $this->config['uploads'] : $this->getUploadsPath(
507507
$dir,

src/Module/WPLoader.php

+12-6
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ public function _initialize(): void
466466
if (empty($config['dbHost']) && strncmp($config['dbName'], codecept_root_dir(), strlen(codecept_root_dir())) === 0) {
467467
$dbFile = (array_reverse(explode(DIRECTORY_SEPARATOR, $config['dbName']))[0]);
468468
$dbDir = rtrim(str_replace($dbFile, '', $config['dbName']), DIRECTORY_SEPARATOR);
469-
$db = new SqliteDatabase($dbDir, $dbFile);
469+
$db = new SqliteDatabase($dbDir, $dbFile, $config['tablePrefix']);
470470
} else {
471471
$db = new MysqlDatabase(
472472
$config['dbName'],
@@ -590,7 +590,7 @@ public function _beforeSuite($settings = [])
590590
*
591591
* @return string The absolute path to the WordPress root folder or a path within it.
592592
*/
593-
public function getWpRootFolder(string $path = null): string
593+
public function getWpRootFolder(?string $path = null): string
594594
{
595595
return $this->installation->getWpRootDir($path);
596596
}
@@ -1171,20 +1171,26 @@ private function activatePluginsTheme(array $plugins): array
11711171
$database->updateOption('stylesheet', $database->getOption('stylesheet'));
11721172
}
11731173

1174-
// Flush the cache to force the refetch of the options' value.
1175-
wp_cache_delete('alloptions', 'options');
1176-
11771174
// Do not include external plugins, it would create issues at this stage.
11781175
$pluginsDir = $this->getPluginsFolder();
11791176

1180-
return array_values(
1177+
$activePlugins = array_values(
11811178
array_filter(
11821179
$plugins,
11831180
static function (string $plugin) use ($pluginsDir) {
11841181
return is_file($pluginsDir . "/$plugin");
11851182
}
11861183
)
11871184
);
1185+
1186+
// During activation some plugins could deactivate other plugins: protect from it.
1187+
$database->updateOption('active_plugins', $activePlugins);
1188+
1189+
// Flush the cache to force the refetch of the options' value.
1190+
wp_cache_delete('alloptions', 'options');
1191+
1192+
1193+
return $activePlugins;
11881194
}
11891195

11901196
/**

src/Module/WPLoader/FiltersGroup.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class FiltersGroup
4242
*/
4343
public function __construct(
4444
array $filters = [],
45-
callable $removeWith = null,
46-
callable $addWith = null
45+
?callable $removeWith = null,
46+
?callable $addWith = null
4747
) {
4848
/**
4949
* An array detailing each filter callback, priority and arguments.

src/Module/WPQueries.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ private function readQueries(): void
149149
*
150150
* @param wpdb|null $wpdb
151151
*/
152-
public function _getFilteredQueriesIterator(wpdb $wpdb = null): SetupTearDownQueriesFilter
152+
public function _getFilteredQueriesIterator(?wpdb $wpdb = null): SetupTearDownQueriesFilter
153153
{
154154
if (null === $wpdb) {
155155
$wpdb = $this->_getWpdb();
@@ -1029,7 +1029,7 @@ public function assertQueriesCountByStatementAndFilter(
10291029
*
10301030
* @return int The current count of performed queries.
10311031
*/
1032-
public function countQueries(wpdb $wpdb = null): int
1032+
public function countQueries(?wpdb $wpdb = null): int
10331033
{
10341034
return count($this->getQueries($wpdb));
10351035
}
@@ -1050,7 +1050,7 @@ public function countQueries(wpdb $wpdb = null): int
10501050
*
10511051
* @return array{0: string, 1: float, 2: string, 3: float, 4?: array<int|string,mixed>}[] An array of queries.
10521052
*/
1053-
public function getQueries(wpdb $wpdb = null): array
1053+
public function getQueries(?wpdb $wpdb = null): array
10541054
{
10551055
/** @var array{0: string, 1: float, 2: string, 3: float, 4?: array<int|string,mixed>}[] $logicQueries */
10561056
$logicQueries = iterator_to_array($this->_getFilteredQueriesIterator($wpdb), false);

src/MonkeyPatch/FileStreamWrapper.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static function setPatcherForFile(
3333
string $file,
3434
PatcherInterface $patcher,
3535
bool $redirectOpenedPath = true,
36-
string $context = null
36+
?string $context = null
3737
): void {
3838
$fromFilePath = FS::realpath($file) ?: $file;
3939
self::$fileToPatcherMap[$fromFilePath] = [$patcher, $redirectOpenedPath, $context ?? ''];
@@ -74,7 +74,7 @@ public function __destruct()
7474
/**
7575
* @throws MonkeyPatchingException
7676
*/
77-
public function stream_open(string $path, string $mode, int $options, string &$openedPath = null): bool
77+
public function stream_open(string $path, string $mode, int $options, ?string &$openedPath = null): bool
7878
{
7979
self::unregister();
8080

@@ -231,7 +231,7 @@ public function rename(string $from, string $to): bool
231231
return $result;
232232
}
233233

234-
public function rmdir(string $path, int $options = null): bool
234+
public function rmdir(string $path, ?int $options = null): bool
235235
{
236236
static::unregister();
237237

src/MonkeyPatch/Patchers/FileContentsReplacementPatcher.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function __construct(string $fileContents)
2020
/**
2121
* @throws MonkeyPatchingException
2222
*/
23-
public function patch(string $fileContents, string $pathname, string $context = null): array
23+
public function patch(string $fileContents, string $pathname, ?string $context = null): array
2424
{
2525
$replacementFile = MonkeyPatch::getReplacementFileName($pathname, $context ?? $this->fileContents);
2626

src/MonkeyPatch/Patchers/FileReplacementPatcher.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function __construct(string $replacementFile)
1818
/**
1919
* @throws MonkeyPatchingException
2020
*/
21-
public function patch(string $fileContents, string $pathname, string $context = null): array
21+
public function patch(string $fileContents, string $pathname, ?string $context = null): array
2222
{
2323
$replacementFileContents = file_get_contents($this->replacementFile);
2424

src/MonkeyPatch/Patchers/PatcherInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface PatcherInterface
77
/**
88
* @return array{string, string}
99
*/
10-
public function patch(string $fileContents, string $pathname, string $context = null): array;
10+
public function patch(string $fileContents, string $pathname, ?string $context = null): array;
1111

1212
/**
1313
* @return array{

0 commit comments

Comments
 (0)