wp-studio 1.7.8-beta2 → 1.7.8-beta3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -0
- package/assets/demo.gif +0 -0
- package/dist/cli/{_events-BRGCap7g.mjs → _events-C60cNJ1W.mjs} +1 -1
- package/dist/cli/{index-9Oz-0bqF.mjs → index-D9syEMMz.mjs} +4 -4
- package/dist/cli/{index-CT4S2538.mjs → index-Ru6CUP6w.mjs} +24 -12
- package/dist/cli/{login-D4E3GoXe.mjs → login-C3QlGVbr.mjs} +1 -1
- package/dist/cli/{logout-DE-RoshK.mjs → logout-B63eZwJZ.mjs} +1 -1
- package/dist/cli/main.mjs +2 -1
- package/dist/cli/{resume-DLoXmzNG.mjs → resume-DQT_MK6A.mjs} +1 -1
- package/dist/cli/{set-B0L-QiXT.mjs → set-C805heQS.mjs} +1 -1
- package/dist/cli/{set-B8YYUENH.mjs → set-CjTbueyB.mjs} +1 -1
- package/dist/cli/{status-DEOAA0yx.mjs → status-SnKm1rRP.mjs} +1 -1
- package/dist/cli/{wp-CobSX6C6.mjs → wp-D0HZdudM.mjs} +1 -1
- package/dist/cli/wp-files/sqlite-command/composer.json +4 -3
- package/dist/cli/wp-files/sqlite-command/composer.lock +132 -80
- package/dist/cli/wp-files/sqlite-command/vendor/autoload.php +1 -1
- package/dist/cli/wp-files/sqlite-command/vendor/composer/autoload_classmap.php +58 -70
- package/dist/cli/wp-files/sqlite-command/vendor/composer/autoload_namespaces.php +1 -0
- package/dist/cli/wp-files/sqlite-command/vendor/composer/autoload_psr4.php +1 -1
- package/dist/cli/wp-files/sqlite-command/vendor/composer/autoload_real.php +5 -5
- package/dist/cli/wp-files/sqlite-command/vendor/composer/autoload_static.php +78 -80
- package/dist/cli/wp-files/sqlite-command/vendor/composer/installed.json +104 -49
- package/dist/cli/wp-files/sqlite-command/vendor/composer/installed.php +29 -16
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/CHANGELOG.md +103 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/Comparator/Comparator.php +62 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/Comparator/DateComparator.php +50 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/Comparator/NumberComparator.php +78 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/Exception/AccessDeniedException.php +19 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/Exception/DirectoryNotFoundException.php +19 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/Finder.php +851 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/Gitignore.php +91 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/Glob.php +116 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/Iterator/CustomFilterIterator.php +61 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/Iterator/DateRangeFilterIterator.php +58 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/Iterator/DepthRangeFilterIterator.php +48 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php +110 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/Iterator/FileTypeFilterIterator.php +51 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/Iterator/FilecontentFilterIterator.php +58 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/Iterator/FilenameFilterIterator.php +45 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/Iterator/LazyIterator.php +32 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/Iterator/MultiplePcreFilterIterator.php +107 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/Iterator/PathFilterIterator.php +56 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php +134 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/Iterator/SizeRangeFilterIterator.php +57 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/Iterator/SortableIterator.php +115 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/Iterator/VcsIgnoredFilterIterator.php +173 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/LICENSE +19 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/README.md +14 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/SplFileInfo.php +80 -0
- package/dist/cli/wp-files/sqlite-command/vendor/symfony/finder/composer.json +31 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/mustache/.gitattributes +8 -0
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache → wp-cli}/mustache/LICENSE +1 -1
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/mustache/README.md +76 -0
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache → wp-cli}/mustache/composer.json +6 -16
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/mustache/src/Mustache/Autoloader.php +88 -0
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Cache/AbstractCache.php +7 -15
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Cache/FilesystemCache.php +15 -20
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Cache/NoopCache.php +4 -8
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Cache.php +7 -10
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Compiler.php +87 -144
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Context.php +19 -23
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Engine.php +134 -251
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Exception/InvalidArgumentException.php +2 -6
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Exception/LogicException.php +2 -6
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Exception/RuntimeException.php +2 -6
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Exception/SyntaxException.php +8 -7
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Exception/UnknownFilterException.php +7 -7
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Exception/UnknownHelperException.php +7 -7
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Exception/UnknownTemplateException.php +7 -7
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Exception.php +5 -4
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/HelperCollection.php +17 -22
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/LambdaHelper.php +8 -28
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Loader/ArrayLoader.php +9 -12
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Loader/CascadingLoader.php +15 -18
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Loader/FilesystemLoader.php +18 -24
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Loader/InlineLoader.php +13 -19
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Loader/MutableLoader.php +7 -4
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Loader/ProductionFilesystemLoader.php +16 -23
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Loader/StringLoader.php +4 -8
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Loader.php +7 -8
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Logger/AbstractLogger.php +26 -22
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Logger/StreamLogger.php +20 -25
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Logger.php +37 -13
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Parser.php +93 -100
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Source/FilesystemSource.php +7 -11
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Source.php +5 -4
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Template.php +32 -39
- package/dist/cli/wp-files/sqlite-command/vendor/{mustache/mustache/src → wp-cli/mustache/src/Mustache}/Tokenizer.php +29 -33
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/.actrc +3 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/.gitattributes +6 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/.mailmap +234 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/README.md +4 -4
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/VERSION +1 -1
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/bundle/rmccue/requests/CHANGELOG.md +0 -65
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/bundle/rmccue/requests/README.md +1 -2
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/bundle/rmccue/requests/certificates/cacert.pem +372 -315
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/bundle/rmccue/requests/certificates/cacert.pem.sha256 +1 -1
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/bundle/rmccue/requests/composer.json +5 -7
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/bundle/rmccue/requests/src/Iri.php +18 -20
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/bundle/rmccue/requests/src/Requests.php +1 -1
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/bundle/rmccue/requests/src/Response/Headers.php +1 -1
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/bundle/rmccue/requests/src/Transport/Curl.php +1 -5
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/bundle/rmccue/requests/src/Transport/Fsockopen.php +0 -2
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/bundle/rmccue/requests/src/Utility/CaseInsensitiveDictionary.php +0 -12
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/bundle/rmccue/requests/src/Utility/FilteredIterator.php +2 -2
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/composer.json +13 -30
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/dependencies.yml +6 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/manifest.json +1 -1
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Autoloader.php +2 -4
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/AutoloaderStep.php +1 -10
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/CheckRoot.php +2 -20
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/DefineProtectedCommands.php +3 -3
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/IncludeFrameworkAutoloader.php +4 -3
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/IncludeRequestsAutoloader.php +3 -4
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/InitializeContexts.php +0 -3
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/InitializeLogger.php +1 -1
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php +3 -6
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/{RegisterShutdownHandler.php → LoadDispatcher.php} +4 -6
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LoadRequiredCommand.php +5 -9
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LoadUtilityFunctions.php +0 -1
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Completions.php +6 -149
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Configurator.php +49 -202
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Context/Admin.php +21 -113
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Context/Auto.php +1 -1
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Context/Cli.php +1 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Context/Frontend.php +1 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php +26 -63
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CompositeCommand.php +9 -19
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php +19 -284
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/DocParser.php +5 -17
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Exception/NonExistentKeyException.php +3 -6
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Extractor.php +54 -30
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Fetchers/Base.php +3 -7
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Fetchers/Comment.php +2 -4
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Fetchers/Post.php +3 -8
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Fetchers/Signup.php +1 -3
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Fetchers/Site.php +4 -12
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Fetchers/User.php +1 -3
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/FileCache.php +33 -135
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Formatter.php +57 -221
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Inflector.php +4 -4
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Iterators/CSV.php +1 -6
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Iterators/Query.php +1 -3
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Iterators/Table.php +1 -7
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Iterators/Transform.php +0 -2
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Loggers/Base.php +0 -15
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Loggers/Quiet.php +3 -2
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Loggers/Regular.php +3 -4
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/NoOp.php +0 -4
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Process.php +7 -40
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/RequestsLibrary.php +1 -4
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php +234 -795
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/SynopsisParser.php +26 -116
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/SynopsisValidator.php +1 -1
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Traverser/RecursiveDataStructureTraverser.php +26 -69
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/UpgraderSkin.php +1 -1
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/WpHttpCacheManager.php +5 -67
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/WpOrgApi.php +3 -3
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/boot-fs.php +2 -2
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/bootstrap.php +2 -5
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/class-wp-cli.php +62 -311
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/commands/src/CLI_Alias_Command.php +60 -292
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/commands/src/CLI_Cache_Command.php +1 -1
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/commands/src/CLI_Command.php +31 -191
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/commands/src/Help_Command.php +35 -177
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/config-spec.php +4 -28
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/utils-wp.php +47 -81
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/utils.php +200 -512
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/wp-cli.php +2 -2
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/wp-settings-cli.php +465 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/templates/man-params.mustache +4 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/templates/man.mustache +0 -8
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/ArgValidationTest.php +74 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/CommandFactoryTest.php +420 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/ConfiguratorTest.php +87 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/DocParserTest.php +213 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/ExtractorTest.php +293 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/FileCacheTest.php +207 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/HelpTest.php +119 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/InflectorTest.php +37 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/LoggingTest.php +124 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/ProcessTest.php +30 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/SynopsisParserTest.php +194 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/UtilsTest.php +1092 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/WPCLITest.php +16 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/WP_CLI/Iterators/CSVTest.php +109 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/WP_CLI/Traversers/RecursiveDataStructureTraverserTest.php +151 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/WP_CLI/WpOrgApiTest.php +166 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/WpVersionCompareTest.php +78 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/bootstrap.php +17 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/data/commandfactory-doc_comment-class-win.php +70 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/data/commandfactory-doc_comment-class.php +70 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/data/commandfactory-doc_comment-function-win.php +19 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/data/commandfactory-doc_comment-function.php +19 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/data/expand_globs/bar.ab2 +0 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/data/expand_globs/baz.ab1 +0 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/data/expand_globs/baz.ac1 +0 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/data/expand_globs/baz.efg2 +0 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/data/expand_globs/foo.ab1 +0 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/data/expand_globs/foo.ab2 +0 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/data/expand_globs/foo.efg1 +0 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/data/expand_globs/foo.efg2 +0 -0
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/tests/mock-requests-transport.php +34 -0
- package/dist/cli/wp-files/sqlite-command/version +1 -1
- package/package.json +4 -3
- package/dist/cli/wp-files/sqlite-command/vendor/mustache/mustache/.php-cs-fixer.php +0 -20
- package/dist/cli/wp-files/sqlite-command/vendor/mustache/mustache/README.md +0 -94
- package/dist/cli/wp-files/sqlite-command/vendor/mustache/mustache/src/RenderedString.php +0 -51
- package/dist/cli/wp-files/sqlite-command/vendor/mustache/mustache/src/compat.php +0 -282
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/.typos.toml +0 -14
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/AGENTS.md +0 -121
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/bundle/rmccue/requests/scripts/proxy/proxy.py +0 -5
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/bundle/rmccue/requests/scripts/proxy/start.sh +0 -19
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/bundle/rmccue/requests/scripts/proxy/stop.sh +0 -10
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/Path.php +0 -260
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/php/WP_CLI/ShutdownHandler.php +0 -329
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/schemas/wp-cli-config.json +0 -218
- package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/schemas/wp-cli.example.yml +0 -55
- /package/dist/cli/wp-files/sqlite-command/vendor/wp-cli/wp-cli/{codecov.yml → tests/data/expand_globs/bar.ab1} +0 -0
|
@@ -3,14 +3,18 @@
|
|
|
3
3
|
namespace WP_CLI;
|
|
4
4
|
|
|
5
5
|
use WP_CLI;
|
|
6
|
+
use WP_CLI\Dispatcher;
|
|
6
7
|
use WP_CLI\Dispatcher\CompositeCommand;
|
|
7
8
|
use WP_CLI\Dispatcher\Subcommand;
|
|
9
|
+
use WP_CLI\Fetchers;
|
|
10
|
+
use WP_CLI\Iterators\Exception;
|
|
11
|
+
use WP_CLI\Loggers;
|
|
12
|
+
use WP_CLI\Utils;
|
|
8
13
|
use WP_Error;
|
|
9
14
|
|
|
10
15
|
/**
|
|
11
16
|
* Performs the execution of a command.
|
|
12
17
|
*
|
|
13
|
-
* @property-read string $system_config_path
|
|
14
18
|
* @property-read string $global_config_path
|
|
15
19
|
* @property-read string $project_config_path
|
|
16
20
|
* @property-read array $config
|
|
@@ -18,13 +22,11 @@ use WP_Error;
|
|
|
18
22
|
* @property-read ContextManager $context_manager
|
|
19
23
|
* @property-read string $alias
|
|
20
24
|
* @property-read array $aliases
|
|
21
|
-
* @property-read array $raw_aliases
|
|
22
25
|
* @property-read array $arguments
|
|
23
26
|
* @property-read array $assoc_args
|
|
24
27
|
* @property-read array $runtime_config
|
|
25
28
|
* @property-read bool $colorize
|
|
26
29
|
* @property-read array $early_invoke
|
|
27
|
-
* @property-read string $system_config_path_debug
|
|
28
30
|
* @property-read string $global_config_path_debug
|
|
29
31
|
* @property-read string $project_config_path_debug
|
|
30
32
|
* @property-read array $required_files
|
|
@@ -44,41 +46,26 @@ class Runner {
|
|
|
44
46
|
'UTF-16 (LE)' => "\xFF\xFE",
|
|
45
47
|
];
|
|
46
48
|
|
|
47
|
-
private $system_config_path;
|
|
48
49
|
private $global_config_path;
|
|
49
50
|
private $project_config_path;
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
private $config = [
|
|
53
|
-
'disabled_commands' => [],
|
|
54
|
-
];
|
|
55
|
-
/** @var array<string, mixed> */
|
|
52
|
+
private $config;
|
|
56
53
|
private $extra_config;
|
|
57
54
|
|
|
58
55
|
private $context_manager;
|
|
59
56
|
|
|
60
|
-
/** @var string|null */
|
|
61
57
|
private $alias;
|
|
62
58
|
|
|
63
|
-
|
|
64
|
-
private $aliases = [];
|
|
65
|
-
|
|
66
|
-
private $raw_aliases;
|
|
59
|
+
private $aliases;
|
|
67
60
|
|
|
68
|
-
|
|
69
|
-
private $
|
|
70
|
-
/** @var array<string, array<int, string>|int|string|true> */
|
|
71
|
-
private $assoc_args = [];
|
|
72
|
-
/** @var array<string, mixed> */
|
|
61
|
+
private $arguments;
|
|
62
|
+
private $assoc_args;
|
|
73
63
|
private $runtime_config;
|
|
74
64
|
|
|
75
65
|
private $colorize = false;
|
|
76
66
|
|
|
77
|
-
/** @var array<string, array<int, array<string>>> */
|
|
78
67
|
private $early_invoke = [];
|
|
79
68
|
|
|
80
|
-
private $system_config_path_debug;
|
|
81
|
-
|
|
82
69
|
private $global_config_path_debug;
|
|
83
70
|
|
|
84
71
|
private $project_config_path_debug;
|
|
@@ -121,20 +108,16 @@ class Runner {
|
|
|
121
108
|
* Perform the early invocation of a command.
|
|
122
109
|
*
|
|
123
110
|
* @param string $when Named execution hook
|
|
124
|
-
*
|
|
125
|
-
* @phpstan-impure
|
|
126
111
|
*/
|
|
127
|
-
private function do_early_invoke( $when )
|
|
112
|
+
private function do_early_invoke( $when ) {
|
|
128
113
|
WP_CLI::debug( "Executing hook: {$when}", 'hooks' );
|
|
129
114
|
if ( ! isset( $this->early_invoke[ $when ] ) ) {
|
|
130
115
|
return;
|
|
131
116
|
}
|
|
132
117
|
|
|
133
118
|
// Search the value of @when from the command method.
|
|
134
|
-
// Use 'none' for autocorrect to avoid suggesting wrong alternatives
|
|
135
|
-
// for commands that may be registered later (e.g., via after_wp_load).
|
|
136
119
|
$real_when = '';
|
|
137
|
-
$r = $this->find_command_to_run( $this->arguments
|
|
120
|
+
$r = $this->find_command_to_run( $this->arguments );
|
|
138
121
|
if ( is_array( $r ) ) {
|
|
139
122
|
list( $command, $final_args, $cmd_path ) = $r;
|
|
140
123
|
|
|
@@ -147,11 +130,9 @@ class Runner {
|
|
|
147
130
|
}
|
|
148
131
|
}
|
|
149
132
|
|
|
150
|
-
|
|
151
|
-
$invoke_cmds = (array) $this->early_invoke[ $when ];
|
|
152
|
-
foreach ( (array) $invoke_cmds as $path ) {
|
|
133
|
+
foreach ( $this->early_invoke[ $when ] as $path ) {
|
|
153
134
|
if ( $this->cmd_starts_with( $path ) ) {
|
|
154
|
-
if ( empty( $real_when ) || $real_when === $when ) {
|
|
135
|
+
if ( empty( $real_when ) || ( $real_when && $real_when === $when ) ) {
|
|
155
136
|
$this->run_command_and_exit();
|
|
156
137
|
}
|
|
157
138
|
}
|
|
@@ -167,13 +148,12 @@ class Runner {
|
|
|
167
148
|
* @return string|false
|
|
168
149
|
*/
|
|
169
150
|
public function get_global_config_path( $create_config_file = false ) {
|
|
170
|
-
$wp_cli_config_path = (string) getenv( 'WP_CLI_CONFIG_PATH' );
|
|
171
151
|
|
|
172
|
-
if (
|
|
173
|
-
$config_path =
|
|
152
|
+
if ( getenv( 'WP_CLI_CONFIG_PATH' ) ) {
|
|
153
|
+
$config_path = getenv( 'WP_CLI_CONFIG_PATH' );
|
|
174
154
|
$this->global_config_path_debug = 'Using global config from WP_CLI_CONFIG_PATH env var: ' . $config_path;
|
|
175
155
|
} else {
|
|
176
|
-
$config_path =
|
|
156
|
+
$config_path = Utils\get_home_dir() . '/.wp-cli/config.yml';
|
|
177
157
|
$this->global_config_path_debug = 'Using default global config: ' . $config_path;
|
|
178
158
|
}
|
|
179
159
|
|
|
@@ -203,50 +183,6 @@ class Runner {
|
|
|
203
183
|
return false;
|
|
204
184
|
}
|
|
205
185
|
|
|
206
|
-
/**
|
|
207
|
-
* Get the path to the system-wide configuration YAML file.
|
|
208
|
-
*
|
|
209
|
-
* @return string|false
|
|
210
|
-
*/
|
|
211
|
-
public function get_system_config_path() {
|
|
212
|
-
// Allow override via environment variable
|
|
213
|
-
$env_path = getenv( 'WP_CLI_SYSTEM_SETTINGS_PATH' );
|
|
214
|
-
if ( $env_path ) {
|
|
215
|
-
$config_path = $env_path;
|
|
216
|
-
$this->system_config_path_debug = 'Using system config from WP_CLI_SYSTEM_SETTINGS_PATH env var: ' . $config_path;
|
|
217
|
-
if ( is_readable( $config_path ) ) {
|
|
218
|
-
return $config_path;
|
|
219
|
-
}
|
|
220
|
-
$this->system_config_path_debug = 'System config path from WP_CLI_SYSTEM_SETTINGS_PATH not readable: ' . $config_path;
|
|
221
|
-
return false;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// Determine default path based on OS
|
|
225
|
-
if ( Utils\is_windows() ) {
|
|
226
|
-
// Windows: C:\ProgramData\wp-cli\config.yml
|
|
227
|
-
$program_data = getenv( 'ProgramData' );
|
|
228
|
-
if ( ! $program_data ) {
|
|
229
|
-
$program_data = 'C:' . DIRECTORY_SEPARATOR . 'ProgramData';
|
|
230
|
-
}
|
|
231
|
-
$config_path = $program_data . DIRECTORY_SEPARATOR . 'wp-cli' . DIRECTORY_SEPARATOR . 'config.yml';
|
|
232
|
-
} elseif ( 'Darwin' === PHP_OS ) {
|
|
233
|
-
// macOS: /Library/Application Support/WP-CLI/config.yml
|
|
234
|
-
$config_path = '/Library/Application Support/WP-CLI/config.yml';
|
|
235
|
-
} else {
|
|
236
|
-
// Linux and others: /etc/wp-cli/config.yml
|
|
237
|
-
$config_path = '/etc/wp-cli/config.yml';
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
if ( is_readable( $config_path ) ) {
|
|
241
|
-
$this->system_config_path_debug = 'Using system config: ' . $config_path;
|
|
242
|
-
return $config_path;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
$this->system_config_path_debug = 'No readable system config found';
|
|
246
|
-
|
|
247
|
-
return false;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
186
|
/**
|
|
251
187
|
* Get the path to the project-specific configuration
|
|
252
188
|
* YAML file.
|
|
@@ -264,7 +200,7 @@ class Runner {
|
|
|
264
200
|
// installation into a parent installation
|
|
265
201
|
$project_config_path = Utils\find_file_upward(
|
|
266
202
|
$config_files,
|
|
267
|
-
|
|
203
|
+
getcwd(),
|
|
268
204
|
static function ( $dir ) {
|
|
269
205
|
static $wp_load_count = 0;
|
|
270
206
|
$wp_load_path = $dir . DIRECTORY_SEPARATOR . 'wp-load.php';
|
|
@@ -290,21 +226,12 @@ class Runner {
|
|
|
290
226
|
* @return string
|
|
291
227
|
*/
|
|
292
228
|
public function get_packages_dir_path() {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
$packages_dir = Path::expand_tilde( $packages_dir );
|
|
296
|
-
if ( ! Path::is_absolute( $packages_dir ) ) {
|
|
297
|
-
$cwd = getcwd();
|
|
298
|
-
if ( $cwd ) {
|
|
299
|
-
$packages_dir = $cwd . '/' . $packages_dir;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
$packages_dir = Path::trailingslashit( $packages_dir );
|
|
229
|
+
if ( getenv( 'WP_CLI_PACKAGES_DIR' ) ) {
|
|
230
|
+
$packages_dir = Utils\trailingslashit( getenv( 'WP_CLI_PACKAGES_DIR' ) );
|
|
303
231
|
} else {
|
|
304
|
-
$packages_dir =
|
|
232
|
+
$packages_dir = Utils\get_home_dir() . '/.wp-cli/packages/';
|
|
305
233
|
}
|
|
306
|
-
|
|
307
|
-
return Path::normalize( $packages_dir );
|
|
234
|
+
return $packages_dir;
|
|
308
235
|
}
|
|
309
236
|
|
|
310
237
|
/**
|
|
@@ -314,18 +241,18 @@ class Runner {
|
|
|
314
241
|
* @return string|false
|
|
315
242
|
*/
|
|
316
243
|
private static function extract_subdir_path( $index_path ) {
|
|
317
|
-
$index_code =
|
|
244
|
+
$index_code = file_get_contents( $index_path );
|
|
318
245
|
|
|
319
246
|
if ( ! preg_match( '|^\s*require\s*\(?\s*(.+?)/wp-blog-header\.php([\'"])|m', $index_code, $matches ) ) {
|
|
320
247
|
return false;
|
|
321
248
|
}
|
|
322
249
|
|
|
323
250
|
$wp_path_src = $matches[1] . $matches[2];
|
|
324
|
-
$wp_path_src =
|
|
251
|
+
$wp_path_src = Utils\replace_path_consts( $wp_path_src, $index_path );
|
|
325
252
|
|
|
326
253
|
$wp_path = eval( "return $wp_path_src;" ); // phpcs:ignore Squiz.PHP.Eval.Discouraged
|
|
327
254
|
|
|
328
|
-
if ( !
|
|
255
|
+
if ( ! Utils\is_path_absolute( $wp_path ) ) {
|
|
329
256
|
$wp_path = dirname( $index_path ) . "/$wp_path";
|
|
330
257
|
}
|
|
331
258
|
|
|
@@ -346,25 +273,19 @@ class Runner {
|
|
|
346
273
|
}
|
|
347
274
|
|
|
348
275
|
if ( ! empty( $this->config['path'] ) ) {
|
|
349
|
-
/**
|
|
350
|
-
* @var string $path
|
|
351
|
-
*/
|
|
352
276
|
$path = $this->config['path'];
|
|
353
|
-
|
|
354
|
-
$path = Path::expand_tilde( $path );
|
|
355
|
-
|
|
356
|
-
if ( ! Path::is_absolute( $path ) ) {
|
|
277
|
+
if ( ! Utils\is_path_absolute( $path ) ) {
|
|
357
278
|
$path = getcwd() . '/' . $path;
|
|
358
279
|
}
|
|
359
280
|
|
|
360
|
-
return
|
|
281
|
+
return $path;
|
|
361
282
|
}
|
|
362
283
|
|
|
363
284
|
if ( $this->cmd_starts_with( [ 'core', 'download' ] ) ) {
|
|
364
|
-
return
|
|
285
|
+
return getcwd();
|
|
365
286
|
}
|
|
366
287
|
|
|
367
|
-
$dir =
|
|
288
|
+
$dir = getcwd();
|
|
368
289
|
|
|
369
290
|
while ( is_readable( $dir ) ) {
|
|
370
291
|
if ( file_exists( "$dir/wp-load.php" ) ) {
|
|
@@ -385,7 +306,7 @@ class Runner {
|
|
|
385
306
|
$dir = $parent_dir;
|
|
386
307
|
}
|
|
387
308
|
|
|
388
|
-
return
|
|
309
|
+
return getcwd();
|
|
389
310
|
}
|
|
390
311
|
|
|
391
312
|
/**
|
|
@@ -395,14 +316,8 @@ class Runner {
|
|
|
395
316
|
*/
|
|
396
317
|
private static function set_wp_root( $path ) {
|
|
397
318
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
398
|
-
$normalized = Path::normalize( Path::trailingslashit( $path ) );
|
|
399
|
-
// Adjust Windows-style paths starting with drive letter + forward slash (C:/) so that
|
|
400
|
-
// WordPress core's path_is_absolute() recognizes them as absolute on Windows.
|
|
401
|
-
if ( preg_match( '#^[A-Z]:/#i', $normalized ) ) {
|
|
402
|
-
$normalized = preg_replace( '#^([A-Z]):/#i', '$1:\\\\', $normalized );
|
|
403
|
-
}
|
|
404
319
|
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- Declaring a WP native constant.
|
|
405
|
-
define( 'ABSPATH', $
|
|
320
|
+
define( 'ABSPATH', Utils\normalize_path( Utils\trailingslashit( $path ) ) );
|
|
406
321
|
} elseif ( ! is_null( $path ) ) {
|
|
407
322
|
WP_CLI::error_multi_line(
|
|
408
323
|
[
|
|
@@ -432,10 +347,6 @@ class Runner {
|
|
|
432
347
|
|
|
433
348
|
if ( true === $url ) {
|
|
434
349
|
WP_CLI::warning( 'The --url parameter expects a value.' );
|
|
435
|
-
return false;
|
|
436
|
-
} elseif ( is_string( $url ) && ! Utils\parse_url( $url, PHP_URL_HOST ) ) {
|
|
437
|
-
WP_CLI::warning( "The --url parameter value '{$url}' is not valid. Check for typos in the protocol, e.g. 'http://' not 'http:/'." );
|
|
438
|
-
return false;
|
|
439
350
|
}
|
|
440
351
|
|
|
441
352
|
return $url;
|
|
@@ -452,20 +363,17 @@ class Runner {
|
|
|
452
363
|
*
|
|
453
364
|
* @return bool `true` if the arguments passed to the WP-CLI binary start with the specified prefix, `false` otherwise.
|
|
454
365
|
*/
|
|
455
|
-
private function cmd_starts_with( $prefix )
|
|
456
|
-
return array_slice(
|
|
366
|
+
private function cmd_starts_with( $prefix ) {
|
|
367
|
+
return array_slice( $this->arguments, 0, count( $prefix ) ) === $prefix;
|
|
457
368
|
}
|
|
458
369
|
|
|
459
370
|
/**
|
|
460
371
|
* Given positional arguments, find the command to execute.
|
|
461
372
|
*
|
|
462
373
|
* @param array $args
|
|
463
|
-
* @
|
|
464
|
-
* @return array{0: CompositeCommand, 1: array, 2: array}|string Command, args, and path on success; error message on failure
|
|
465
|
-
*
|
|
466
|
-
* @phpstan-param 'none'|'confirm'|'auto' $autocorrect
|
|
374
|
+
* @return array|string Command, args, and path on success; error message on failure
|
|
467
375
|
*/
|
|
468
|
-
public function find_command_to_run( $args
|
|
376
|
+
public function find_command_to_run( $args ) {
|
|
469
377
|
$command = WP_CLI::get_root_command();
|
|
470
378
|
|
|
471
379
|
WP_CLI::do_hook( 'find_command_to_run_pre' );
|
|
@@ -488,37 +396,13 @@ class Runner {
|
|
|
488
396
|
$suggestion = 'meta';
|
|
489
397
|
}
|
|
490
398
|
|
|
491
|
-
|
|
492
|
-
"'%s' is not a registered subcommand of '%s'. See 'wp help %s' for available subcommands
|
|
399
|
+
return sprintf(
|
|
400
|
+
"'%s' is not a registered subcommand of '%s'. See 'wp help %s' for available subcommands.%s",
|
|
493
401
|
$child,
|
|
494
402
|
$parent_name,
|
|
495
|
-
$parent_name
|
|
403
|
+
$parent_name,
|
|
404
|
+
! empty( $suggestion ) ? PHP_EOL . "Did you mean '{$suggestion}'?" : ''
|
|
496
405
|
);
|
|
497
|
-
|
|
498
|
-
if ( ! empty( $suggestion ) ) {
|
|
499
|
-
$suggestion_text = "Did you mean '{$suggestion}'?";
|
|
500
|
-
|
|
501
|
-
if ( 'none' !== $autocorrect ) {
|
|
502
|
-
$suggested_command_to_run = $this->find_command_to_run( explode( ' ', "$parent_name $suggestion" ) );
|
|
503
|
-
|
|
504
|
-
if ( is_array( $suggested_command_to_run ) ) {
|
|
505
|
-
// Override potentially misspelled cmd with the corrected one.
|
|
506
|
-
$this->arguments = $suggested_command_to_run[2];
|
|
507
|
-
|
|
508
|
-
if ( 'auto' === $autocorrect ) {
|
|
509
|
-
return $suggested_command_to_run;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
WP_CLI::warning( $error );
|
|
513
|
-
WP_CLI::confirm( $suggestion_text );
|
|
514
|
-
return $suggested_command_to_run;
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
return $error . PHP_EOL . $suggestion_text;
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
return $error;
|
|
522
406
|
}
|
|
523
407
|
|
|
524
408
|
$suggestion = $this->get_subcommand_suggestion( $full_name, $command );
|
|
@@ -533,57 +417,11 @@ class Runner {
|
|
|
533
417
|
}
|
|
534
418
|
}
|
|
535
419
|
|
|
536
|
-
|
|
537
|
-
"'%s' is not a registered wp command. See 'wp help' for available commands
|
|
538
|
-
$full_name
|
|
420
|
+
return sprintf(
|
|
421
|
+
"'%s' is not a registered wp command. See 'wp help' for available commands.%s",
|
|
422
|
+
$full_name,
|
|
423
|
+
! empty( $suggestion ) ? PHP_EOL . "Did you mean '{$suggestion}'?" : ''
|
|
539
424
|
);
|
|
540
|
-
|
|
541
|
-
if ( ! empty( $suggestion ) ) {
|
|
542
|
-
$suggestion_text = "Did you mean '{$suggestion}'?";
|
|
543
|
-
|
|
544
|
-
if ( 'none' !== $autocorrect ) {
|
|
545
|
-
if ( 'help' === $suggestion ) {
|
|
546
|
-
// This was a typo suggestion for a help command, so find command without 'help'
|
|
547
|
-
// and then prepend 'help' again for the corrected command.
|
|
548
|
-
$suggested_command_to_run = $this->find_command_to_run( $args, 'auto' );
|
|
549
|
-
if ( is_array( $suggested_command_to_run ) ) {
|
|
550
|
-
$this->arguments = array_merge( [ $suggestion ], $args );
|
|
551
|
-
|
|
552
|
-
$suggested_command_to_run = $this->find_command_to_run( $this->arguments, 'auto' );
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
if ( ! isset( $suggested_command_to_run ) || ! is_array( $suggested_command_to_run ) ) {
|
|
557
|
-
$suggested_command_to_run = $this->find_command_to_run( array_merge( [ $suggestion ], $args ), 'auto' );
|
|
558
|
-
|
|
559
|
-
if ( is_array( $suggested_command_to_run ) ) {
|
|
560
|
-
$this->arguments = $suggested_command_to_run[2];
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
if ( ! is_array( $suggested_command_to_run ) ) {
|
|
565
|
-
$suggested_command_to_run = $this->find_command_to_run( [ $suggestion ], 'auto' );
|
|
566
|
-
|
|
567
|
-
if ( is_array( $suggested_command_to_run ) ) {
|
|
568
|
-
$this->arguments = $suggested_command_to_run[2];
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
if ( is_array( $suggested_command_to_run ) ) {
|
|
573
|
-
if ( 'auto' === $autocorrect ) {
|
|
574
|
-
return $suggested_command_to_run;
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
WP_CLI::warning( $error );
|
|
578
|
-
WP_CLI::confirm( $suggestion_text );
|
|
579
|
-
return $suggested_command_to_run;
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
return $error . PHP_EOL . $suggestion_text;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
return $error;
|
|
587
425
|
}
|
|
588
426
|
|
|
589
427
|
if ( $this->is_command_disabled( $subcommand ) ) {
|
|
@@ -612,7 +450,7 @@ class Runner {
|
|
|
612
450
|
if ( ! empty( $options['back_compat_conversions'] ) ) {
|
|
613
451
|
list( $args, $assoc_args ) = self::back_compat_conversions( $args, $assoc_args );
|
|
614
452
|
}
|
|
615
|
-
$r = $this->find_command_to_run( $args
|
|
453
|
+
$r = $this->find_command_to_run( $args );
|
|
616
454
|
if ( is_string( $r ) ) {
|
|
617
455
|
WP_CLI::error( $r );
|
|
618
456
|
}
|
|
@@ -629,15 +467,9 @@ class Runner {
|
|
|
629
467
|
|
|
630
468
|
WP_CLI::debug( 'Running command: ' . $name, 'bootstrap' );
|
|
631
469
|
try {
|
|
632
|
-
$command->invoke( $final_args, $assoc_args,
|
|
633
|
-
} catch (
|
|
634
|
-
|
|
635
|
-
throw $e;
|
|
636
|
-
} catch ( \Exception $e ) {
|
|
637
|
-
// Catch exceptions but not Error types, as Error types represent
|
|
638
|
-
// fatal errors that should be handled by ShutdownHandler for
|
|
639
|
-
// helpful plugin/theme skip suggestions.
|
|
640
|
-
WP_CLI::error( $e );
|
|
470
|
+
$command->invoke( $final_args, $assoc_args, $extra_args );
|
|
471
|
+
} catch ( Exception $e ) {
|
|
472
|
+
WP_CLI::error( $e->getMessage() );
|
|
641
473
|
}
|
|
642
474
|
}
|
|
643
475
|
|
|
@@ -656,7 +488,7 @@ class Runner {
|
|
|
656
488
|
}
|
|
657
489
|
}
|
|
658
490
|
|
|
659
|
-
private function run_command_and_exit( $help_exit_warning = '' )
|
|
491
|
+
private function run_command_and_exit( $help_exit_warning = '' ) {
|
|
660
492
|
$this->show_synopsis_if_composite_command();
|
|
661
493
|
$this->run_command( $this->arguments, $this->assoc_args );
|
|
662
494
|
if ( $this->cmd_starts_with( [ 'help' ] ) ) {
|
|
@@ -678,14 +510,15 @@ class Runner {
|
|
|
678
510
|
* scheme of "docker", "docker-compose", or "docker-compose-run").
|
|
679
511
|
*
|
|
680
512
|
* @param string $connection_string Passed connection string.
|
|
513
|
+
* @return void
|
|
681
514
|
*/
|
|
682
|
-
private function run_ssh_command(
|
|
515
|
+
private function run_ssh_command( $connection_string ) {
|
|
683
516
|
|
|
684
517
|
WP_CLI::do_hook( 'before_ssh' );
|
|
685
518
|
|
|
686
519
|
$bits = Utils\parse_ssh_url( $connection_string );
|
|
687
520
|
|
|
688
|
-
$pre_cmd =
|
|
521
|
+
$pre_cmd = getenv( 'WP_CLI_SSH_PRE_CMD' );
|
|
689
522
|
if ( $pre_cmd ) {
|
|
690
523
|
WP_CLI::warning( "WP_CLI_SSH_PRE_CMD found, executing the following command(s) on the remote machine:\n $pre_cmd" );
|
|
691
524
|
|
|
@@ -697,66 +530,39 @@ class Runner {
|
|
|
697
530
|
$env_vars .= 'WP_CLI_STRICT_ARGS_MODE=1 ';
|
|
698
531
|
}
|
|
699
532
|
|
|
700
|
-
$wp_binary =
|
|
701
|
-
$wp_args = array_slice(
|
|
533
|
+
$wp_binary = getenv( 'WP_CLI_SSH_BINARY' ) ?: 'wp';
|
|
534
|
+
$wp_args = array_slice( $GLOBALS['argv'], 1 );
|
|
702
535
|
|
|
703
|
-
if ( $this->alias && ! empty( $wp_args[0] ) &&
|
|
536
|
+
if ( $this->alias && ! empty( $wp_args[0] ) && $this->alias === $wp_args[0] ) {
|
|
704
537
|
array_shift( $wp_args );
|
|
705
538
|
$runtime_alias = [];
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
// Skip connection-specific keys as they are not relevant to the remote WP-CLI instance.
|
|
710
|
-
if ( in_array( $key, [ 'ssh', 'http', 'proxyjump', 'key' ], true ) ) {
|
|
711
|
-
continue;
|
|
712
|
-
}
|
|
713
|
-
$runtime_alias[ $key ] = $value;
|
|
539
|
+
foreach ( $this->aliases[ $this->alias ] as $key => $value ) {
|
|
540
|
+
if ( 'ssh' === $key ) {
|
|
541
|
+
continue;
|
|
714
542
|
}
|
|
543
|
+
$runtime_alias[ $key ] = $value;
|
|
715
544
|
}
|
|
716
545
|
if ( ! empty( $runtime_alias ) ) {
|
|
717
546
|
$encoded_alias = json_encode(
|
|
718
547
|
[
|
|
719
|
-
|
|
548
|
+
$this->alias => $runtime_alias,
|
|
720
549
|
]
|
|
721
550
|
);
|
|
722
|
-
|
|
723
|
-
$wp_binary = "env WP_CLI_RUNTIME_ALIAS='" . str_replace( "'", "'\\''", $encoded_alias ) . "' {$wp_binary} @{$this->alias}";
|
|
724
|
-
}
|
|
551
|
+
$wp_binary = "WP_CLI_RUNTIME_ALIAS='{$encoded_alias}' {$wp_binary} {$this->alias}";
|
|
725
552
|
}
|
|
726
553
|
}
|
|
727
554
|
|
|
728
|
-
$alias_regex = '#' . Configurator::ALIAS_REGEX . '#';
|
|
729
|
-
/** @var string $v */
|
|
730
555
|
foreach ( $wp_args as $k => $v ) {
|
|
731
|
-
if ( preg_match( '
|
|
556
|
+
if ( preg_match( '#--ssh=#', $v ) ) {
|
|
732
557
|
unset( $wp_args[ $k ] );
|
|
733
558
|
}
|
|
734
559
|
}
|
|
735
560
|
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
// 2. generate_ssh_command(): Wrap entire command for local shell
|
|
741
|
-
//
|
|
742
|
-
// Safe characters: alphanumeric, hyphen, underscore, equals, dot, forward slash, colon
|
|
743
|
-
// - Hyphens (including at start like --debug) are safe because they're part of the
|
|
744
|
-
// wp-cli command string that's passed to the remote shell, not SSH options
|
|
745
|
-
// - Forward slash and colon are included because they're common in paths and URLs
|
|
746
|
-
// (e.g., --url=https://example.com/path) and are not shell metacharacters
|
|
747
|
-
// - All other characters (spaces, quotes, $, &, |, etc.) trigger quoting via escapeshellarg()
|
|
748
|
-
$escaped_args = [];
|
|
749
|
-
/** @var string $arg */
|
|
750
|
-
foreach ( $wp_args as $arg ) {
|
|
751
|
-
// Quote empty strings and arguments with any characters outside the safe set.
|
|
752
|
-
// The empty string check is explicit for clarity, though regex would also catch it.
|
|
753
|
-
if ( '' !== $arg && preg_match( '/^[a-zA-Z0-9_=.\/:-]+$/', $arg ) ) {
|
|
754
|
-
$escaped_args[] = $arg;
|
|
755
|
-
} else {
|
|
756
|
-
$escaped_args[] = escapeshellarg( $arg );
|
|
757
|
-
}
|
|
561
|
+
$wp_command = $pre_cmd . $env_vars . $wp_binary . ' ' . implode( ' ', array_map( 'escapeshellarg', $wp_args ) );
|
|
562
|
+
|
|
563
|
+
if ( isset( $bits['scheme'] ) && 'docker-compose-run' === $bits['scheme'] ) {
|
|
564
|
+
$wp_command = implode( ' ', $wp_args );
|
|
758
565
|
}
|
|
759
|
-
$wp_command = $pre_cmd . $env_vars . $wp_binary . ' ' . implode( ' ', $escaped_args );
|
|
760
566
|
|
|
761
567
|
$escaped_command = $this->generate_ssh_command( $bits, $wp_command );
|
|
762
568
|
|
|
@@ -771,19 +577,13 @@ class Runner {
|
|
|
771
577
|
/**
|
|
772
578
|
* Generate a shell command from the parsed connection string.
|
|
773
579
|
*
|
|
774
|
-
* @param array
|
|
580
|
+
* @param array $bits Parsed connection string.
|
|
775
581
|
* @param string $wp_command WP-CLI command to run.
|
|
776
582
|
* @return string
|
|
777
583
|
*/
|
|
778
584
|
private function generate_ssh_command( $bits, $wp_command ) {
|
|
779
585
|
$escaped_command = '';
|
|
780
586
|
|
|
781
|
-
// Get additional SSH arguments if provided.
|
|
782
|
-
$ssh_args_config = WP_CLI::get_config( 'ssh-args' );
|
|
783
|
-
$ssh_args = is_array( $ssh_args_config ) && ! empty( $ssh_args_config )
|
|
784
|
-
? implode( ' ', array_map( 'escapeshellarg', $ssh_args_config ) )
|
|
785
|
-
: '';
|
|
786
|
-
|
|
787
587
|
// Set default values.
|
|
788
588
|
foreach ( [ 'scheme', 'user', 'host', 'port', 'path', 'key', 'proxyjump' ] as $bit ) {
|
|
789
589
|
if ( ! isset( $bits[ $bit ] ) ) {
|
|
@@ -793,10 +593,6 @@ class Runner {
|
|
|
793
593
|
WP_CLI::debug( 'SSH ' . $bit . ': ' . $bits[ $bit ], 'bootstrap' );
|
|
794
594
|
}
|
|
795
595
|
|
|
796
|
-
/**
|
|
797
|
-
* @var array{scheme: string|null, user: string|null, host: string, port: string|null, path: string|null, key: string|null, proxyjump: string|null} $bits
|
|
798
|
-
*/
|
|
799
|
-
|
|
800
596
|
/*
|
|
801
597
|
* posix_isatty(STDIN) is generally true unless something was passed on stdin
|
|
802
598
|
* If autodetection leads to false (fd on stdin), then `-i` is passed to `docker` cmd
|
|
@@ -805,94 +601,87 @@ class Runner {
|
|
|
805
601
|
$is_stdout_tty = function_exists( 'posix_isatty' ) && posix_isatty( STDOUT );
|
|
806
602
|
$is_stdin_tty = function_exists( 'posix_isatty' ) ? posix_isatty( STDIN ) : true;
|
|
807
603
|
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
604
|
+
if ( in_array( $bits['scheme'], [ 'docker', 'docker-compose', 'docker-compose-run' ], true ) ) {
|
|
605
|
+
$docker_compose_v2_version_cmd = Utils\esc_cmd( Utils\force_env_on_nix_systems( 'docker' ) . ' compose %s', 'version' );
|
|
606
|
+
$docker_compose_cmd = ! empty( Process::create( $docker_compose_v2_version_cmd )->run()->stdout )
|
|
607
|
+
? 'docker compose'
|
|
608
|
+
: 'docker-compose';
|
|
609
|
+
}
|
|
812
610
|
|
|
813
611
|
if ( 'docker' === $bits['scheme'] ) {
|
|
814
|
-
$command = 'docker exec %s%s%s%s%s
|
|
612
|
+
$command = 'docker exec %s%s%s%s%s sh -c %s';
|
|
815
613
|
|
|
816
614
|
$escaped_command = sprintf(
|
|
817
615
|
$command,
|
|
818
|
-
$ssh_args ? $ssh_args . ' ' : '',
|
|
819
616
|
$bits['user'] ? '--user ' . escapeshellarg( $bits['user'] ) . ' ' : '',
|
|
820
617
|
$bits['path'] ? '--workdir ' . escapeshellarg( $bits['path'] ) . ' ' : '',
|
|
821
|
-
$is_stdout_tty && !
|
|
822
|
-
$is_stdin_tty ||
|
|
618
|
+
$is_stdout_tty && ! getenv( 'WP_CLI_DOCKER_NO_TTY' ) ? '-t ' : '',
|
|
619
|
+
$is_stdin_tty || getenv( 'WP_CLI_DOCKER_NO_INTERACTIVE' ) ? '' : '-i ',
|
|
823
620
|
escapeshellarg( $bits['host'] ),
|
|
824
621
|
escapeshellarg( $wp_command )
|
|
825
622
|
);
|
|
826
623
|
}
|
|
827
624
|
|
|
828
625
|
if ( 'docker-compose' === $bits['scheme'] ) {
|
|
829
|
-
$command = '%s exec %s%s%s%s
|
|
626
|
+
$command = '%s exec %s%s%s%s sh -c %s';
|
|
830
627
|
|
|
831
628
|
$escaped_command = sprintf(
|
|
832
629
|
$command,
|
|
833
630
|
$docker_compose_cmd,
|
|
834
|
-
$ssh_args ? $ssh_args . ' ' : '',
|
|
835
631
|
$bits['user'] ? '--user ' . escapeshellarg( $bits['user'] ) . ' ' : '',
|
|
836
632
|
$bits['path'] ? '--workdir ' . escapeshellarg( $bits['path'] ) . ' ' : '',
|
|
837
|
-
$is_stdout_tty ||
|
|
633
|
+
$is_stdout_tty || getenv( 'WP_CLI_DOCKER_NO_TTY' ) ? '' : '-T ',
|
|
838
634
|
escapeshellarg( $bits['host'] ),
|
|
839
635
|
escapeshellarg( $wp_command )
|
|
840
636
|
);
|
|
841
637
|
}
|
|
842
638
|
|
|
843
639
|
if ( 'docker-compose-run' === $bits['scheme'] ) {
|
|
844
|
-
$command = '%s run %s%s%s%s%s
|
|
640
|
+
$command = '%s run %s%s%s%s%s %s';
|
|
845
641
|
|
|
846
642
|
$escaped_command = sprintf(
|
|
847
643
|
$command,
|
|
848
644
|
$docker_compose_cmd,
|
|
849
|
-
$ssh_args ? $ssh_args . ' ' : '',
|
|
850
645
|
$bits['user'] ? '--user ' . escapeshellarg( $bits['user'] ) . ' ' : '',
|
|
851
646
|
$bits['path'] ? '--workdir ' . escapeshellarg( $bits['path'] ) . ' ' : '',
|
|
852
|
-
$is_stdout_tty ||
|
|
853
|
-
$is_stdin_tty ||
|
|
647
|
+
$is_stdout_tty || getenv( 'WP_CLI_DOCKER_NO_TTY' ) ? '' : '-T ',
|
|
648
|
+
$is_stdin_tty || getenv( 'WP_CLI_DOCKER_NO_INTERACTIVE' ) ? '' : '-i ',
|
|
854
649
|
escapeshellarg( $bits['host'] ),
|
|
855
650
|
$wp_command
|
|
856
651
|
);
|
|
857
652
|
}
|
|
858
653
|
|
|
859
654
|
// For "vagrant" & "ssh" schemes which don't provide a working-directory option, use `cd`
|
|
860
|
-
if ( $bits['path']
|
|
861
|
-
$wp_command = 'cd ' .
|
|
655
|
+
if ( $bits['path'] ) {
|
|
656
|
+
$wp_command = 'cd ' . escapeshellarg( $bits['path'] ) . '; ' . $wp_command;
|
|
862
657
|
}
|
|
863
658
|
|
|
864
659
|
// Vagrant ssh-config.
|
|
865
|
-
$is_vagrant_ssh = false;
|
|
866
660
|
if ( 'vagrant' === $bits['scheme'] ) {
|
|
867
661
|
$cache = WP_CLI::get_cache();
|
|
868
662
|
$cache_key = 'vagrant:' . $this->project_config_path;
|
|
869
663
|
if ( $cache->has( $cache_key ) ) {
|
|
870
|
-
$cached =
|
|
664
|
+
$cached = $cache->read( $cache_key );
|
|
871
665
|
$values = json_decode( $cached, true );
|
|
872
666
|
} else {
|
|
873
|
-
$ssh_config =
|
|
667
|
+
$ssh_config = shell_exec( 'vagrant ssh-config 2>/dev/null' );
|
|
874
668
|
if ( preg_match_all( '#\s*(?<NAME>[a-zA-Z]+)\s(?<VALUE>.+)\s*#', $ssh_config, $matches ) ) {
|
|
875
669
|
$values = array_combine( $matches['NAME'], $matches['VALUE'] );
|
|
876
|
-
$cache->write( $cache_key,
|
|
670
|
+
$cache->write( $cache_key, json_encode( $values ) );
|
|
877
671
|
}
|
|
878
672
|
}
|
|
879
673
|
|
|
880
|
-
/**
|
|
881
|
-
* @var array{HostName?: string, Port?: int, User?: string, IdentityFile?: string} $values
|
|
882
|
-
*/
|
|
883
|
-
|
|
884
674
|
if ( empty( $bits['host'] ) || ( isset( $values['Host'] ) && $bits['host'] === $values['Host'] ) ) {
|
|
885
675
|
$bits['scheme'] = 'ssh';
|
|
886
676
|
$bits['host'] = isset( $values['HostName'] ) ? $values['HostName'] : '';
|
|
887
677
|
$bits['port'] = isset( $values['Port'] ) ? $values['Port'] : '';
|
|
888
678
|
$bits['user'] = isset( $values['User'] ) ? $values['User'] : '';
|
|
889
679
|
$bits['key'] = isset( $values['IdentityFile'] ) ? $values['IdentityFile'] : '';
|
|
890
|
-
$is_vagrant_ssh = true;
|
|
891
680
|
}
|
|
892
681
|
|
|
893
682
|
// If we could not resolve the bits still, fallback to just `vagrant ssh`
|
|
894
683
|
if ( 'vagrant' === $bits['scheme'] ) {
|
|
895
|
-
$command = 'vagrant ssh
|
|
684
|
+
$command = 'vagrant ssh -c %s %s';
|
|
896
685
|
|
|
897
686
|
$escaped_command = sprintf(
|
|
898
687
|
$command,
|
|
@@ -904,7 +693,7 @@ class Runner {
|
|
|
904
693
|
|
|
905
694
|
// Default scheme is SSH.
|
|
906
695
|
if ( 'ssh' === $bits['scheme'] || null === $bits['scheme'] ) {
|
|
907
|
-
$command = 'ssh %s
|
|
696
|
+
$command = 'ssh %s %s %s';
|
|
908
697
|
|
|
909
698
|
if ( $bits['user'] ) {
|
|
910
699
|
$bits['host'] = $bits['user'] . '@' . $bits['host'];
|
|
@@ -920,21 +709,15 @@ class Runner {
|
|
|
920
709
|
}
|
|
921
710
|
|
|
922
711
|
$command_args = [
|
|
923
|
-
|
|
924
|
-
$bits['proxyjump'] ? sprintf( '-J %s', escapeshellarg( (string) $bits['proxyjump'] ) ) : '',
|
|
712
|
+
$bits['proxyjump'] ? sprintf( '-J %s', escapeshellarg( $bits['proxyjump'] ) ) : '',
|
|
925
713
|
$bits['port'] ? sprintf( '-p %d', (int) $bits['port'] ) : '',
|
|
926
|
-
|
|
927
|
-
$bits['key'] ? sprintf( '-i %s', escapeshellarg( (string) $bits['key'] ) ) : '',
|
|
928
|
-
$is_vagrant_ssh ? '-o StrictHostKeyChecking=no' : '',
|
|
929
|
-
$is_vagrant_ssh ? '-o UserKnownHostsFile=/dev/null' : '',
|
|
930
|
-
$is_vagrant_ssh ? '-o BatchMode=yes' : '',
|
|
714
|
+
$bits['key'] ? sprintf( '-i %s', escapeshellarg( $bits['key'] ) ) : '',
|
|
931
715
|
$is_stdout_tty ? '-t' : '-T',
|
|
932
716
|
WP_CLI::get_config( 'debug' ) ? '-vvv' : '-q',
|
|
933
717
|
];
|
|
934
718
|
|
|
935
719
|
$escaped_command = sprintf(
|
|
936
720
|
$command,
|
|
937
|
-
$ssh_args ? $ssh_args . ' ' : '',
|
|
938
721
|
implode( ' ', array_filter( $command_args ) ),
|
|
939
722
|
escapeshellarg( $bits['host'] ),
|
|
940
723
|
escapeshellarg( $wp_command )
|
|
@@ -953,11 +736,7 @@ class Runner {
|
|
|
953
736
|
*/
|
|
954
737
|
public function is_command_disabled( $command ) {
|
|
955
738
|
$path = implode( ' ', array_slice( Dispatcher\get_path( $command ), 1 ) );
|
|
956
|
-
|
|
957
|
-
* @var string[] $disabled_commands
|
|
958
|
-
*/
|
|
959
|
-
$disabled_commands = $this->config['disabled_commands'];
|
|
960
|
-
return in_array( $path, $disabled_commands, true );
|
|
739
|
+
return in_array( $path, $this->config['disabled_commands'], true );
|
|
961
740
|
}
|
|
962
741
|
|
|
963
742
|
/**
|
|
@@ -973,7 +752,7 @@ class Runner {
|
|
|
973
752
|
$wp_config_path = Utils\locate_wp_config();
|
|
974
753
|
}
|
|
975
754
|
|
|
976
|
-
$wp_config_code =
|
|
755
|
+
$wp_config_code = file_get_contents( $wp_config_path );
|
|
977
756
|
|
|
978
757
|
// Detect and strip byte-order marks (BOMs).
|
|
979
758
|
// This code assumes they can only be found on the first line.
|
|
@@ -993,14 +772,14 @@ class Runner {
|
|
|
993
772
|
|
|
994
773
|
$count = 0;
|
|
995
774
|
|
|
996
|
-
$wp_config_code =
|
|
775
|
+
$wp_config_code = preg_replace( '/\s*require(?:_once)?\s*.*wp-settings\.php.*\s*;/', '', $wp_config_code, -1, $count );
|
|
997
776
|
|
|
998
777
|
if ( 0 === $count ) {
|
|
999
778
|
WP_CLI::error( 'Strange wp-config.php file: wp-settings.php is not loaded directly.' );
|
|
1000
779
|
}
|
|
1001
780
|
|
|
1002
|
-
$source =
|
|
1003
|
-
return
|
|
781
|
+
$source = Utils\replace_path_consts( $wp_config_code, $wp_config_path );
|
|
782
|
+
return preg_replace( '|^\s*\<\?php\s*|', '', $source );
|
|
1004
783
|
}
|
|
1005
784
|
|
|
1006
785
|
/**
|
|
@@ -1011,27 +790,6 @@ class Runner {
|
|
|
1011
790
|
* @return array
|
|
1012
791
|
*/
|
|
1013
792
|
private static function back_compat_conversions( $args, $assoc_args ) {
|
|
1014
|
-
// On Windows (PowerShell), command substitution like $(wp post list --format=ids)
|
|
1015
|
-
// returns space-separated values as a single string argument instead of separate arguments.
|
|
1016
|
-
// Split such arguments to maintain compatibility with Unix-like behavior.
|
|
1017
|
-
if ( Utils\is_windows() ) {
|
|
1018
|
-
$split_args = [];
|
|
1019
|
-
foreach ( $args as $arg ) {
|
|
1020
|
-
// Check if the argument contains space-separated numeric IDs
|
|
1021
|
-
// We only split if the entire argument matches the pattern of space-separated numbers
|
|
1022
|
-
if ( is_string( $arg ) && preg_match( '/^\d+(\s+\d+)+$/', $arg ) ) {
|
|
1023
|
-
// Split on whitespace and add each ID as a separate argument
|
|
1024
|
-
$ids = preg_split( '/\s+/', $arg, -1, PREG_SPLIT_NO_EMPTY );
|
|
1025
|
-
if ( false !== $ids ) {
|
|
1026
|
-
array_push( $split_args, ...$ids );
|
|
1027
|
-
}
|
|
1028
|
-
} else {
|
|
1029
|
-
$split_args[] = $arg;
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
$args = $split_args;
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
793
|
$top_level_aliases = [
|
|
1036
794
|
'sql' => 'db',
|
|
1037
795
|
'blog' => 'site',
|
|
@@ -1046,7 +804,7 @@ class Runner {
|
|
|
1046
804
|
}
|
|
1047
805
|
|
|
1048
806
|
// *-meta -> * meta
|
|
1049
|
-
if ( ! empty( $args ) && preg_match( '/(post|comment|user|network)-meta/',
|
|
807
|
+
if ( ! empty( $args ) && preg_match( '/(post|comment|user|network)-meta/', $args[0], $matches ) ) {
|
|
1050
808
|
array_shift( $args );
|
|
1051
809
|
array_unshift( $args, 'meta' );
|
|
1052
810
|
array_unshift( $args, $matches[1] );
|
|
@@ -1243,26 +1001,30 @@ class Runner {
|
|
|
1243
1001
|
|
|
1244
1002
|
/**
|
|
1245
1003
|
* Do WordPress core files exist?
|
|
1004
|
+
*
|
|
1005
|
+
* @return bool
|
|
1246
1006
|
*/
|
|
1247
|
-
private function wp_exists()
|
|
1007
|
+
private function wp_exists() {
|
|
1248
1008
|
return file_exists( ABSPATH . 'wp-includes/version.php' );
|
|
1249
1009
|
}
|
|
1250
1010
|
|
|
1251
1011
|
/**
|
|
1252
1012
|
* Are WordPress core files readable?
|
|
1013
|
+
*
|
|
1014
|
+
* @return bool
|
|
1253
1015
|
*/
|
|
1254
|
-
private function wp_is_readable()
|
|
1016
|
+
private function wp_is_readable() {
|
|
1255
1017
|
return is_readable( ABSPATH . 'wp-includes/version.php' );
|
|
1256
1018
|
}
|
|
1257
1019
|
|
|
1258
|
-
private function check_wp_version()
|
|
1020
|
+
private function check_wp_version() {
|
|
1259
1021
|
$wp_exists = $this->wp_exists();
|
|
1260
1022
|
$wp_is_readable = $this->wp_is_readable();
|
|
1261
1023
|
if ( ! $wp_exists || ! $wp_is_readable ) {
|
|
1262
1024
|
$this->show_synopsis_if_composite_command();
|
|
1263
|
-
|
|
1264
|
-
$args = $
|
|
1265
|
-
$suggestion_or_disabled = $this->find_command_to_run( $args
|
|
1025
|
+
// If the command doesn't exist use as error.
|
|
1026
|
+
$args = $this->cmd_starts_with( [ 'help' ] ) ? array_slice( $this->arguments, 1 ) : $this->arguments;
|
|
1027
|
+
$suggestion_or_disabled = $this->find_command_to_run( $args );
|
|
1266
1028
|
if ( is_string( $suggestion_or_disabled ) ) {
|
|
1267
1029
|
if ( ! preg_match( '/disabled from the config file.$/', $suggestion_or_disabled ) ) {
|
|
1268
1030
|
WP_CLI::warning( "No WordPress installation found. If the command '" . implode( ' ', $args ) . "' is in a plugin or theme, pass --path=`path/to/wordpress`." );
|
|
@@ -1299,33 +1061,24 @@ class Runner {
|
|
|
1299
1061
|
public function init_config() {
|
|
1300
1062
|
$configurator = WP_CLI::get_configurator();
|
|
1301
1063
|
|
|
1302
|
-
|
|
1303
|
-
* @var string[] $argv
|
|
1304
|
-
*/
|
|
1305
|
-
$argv = array_slice( (array) $GLOBALS['argv'], 1 );
|
|
1064
|
+
$argv = array_slice( $GLOBALS['argv'], 1 );
|
|
1306
1065
|
|
|
1307
|
-
// Check if we use an alias with @foo syntax (must be done before parsing args)
|
|
1308
1066
|
$this->alias = null;
|
|
1309
1067
|
if ( ! empty( $argv[0] ) && preg_match( '#' . Configurator::ALIAS_REGEX . '#', $argv[0], $matches ) ) {
|
|
1310
|
-
$this->alias =
|
|
1068
|
+
$this->alias = array_shift( $argv );
|
|
1311
1069
|
}
|
|
1312
1070
|
|
|
1313
1071
|
// File config
|
|
1314
1072
|
{
|
|
1315
|
-
$this->system_config_path = $this->get_system_config_path();
|
|
1316
1073
|
$this->global_config_path = $this->get_global_config_path();
|
|
1317
1074
|
$this->project_config_path = $this->get_project_config_path();
|
|
1318
1075
|
|
|
1319
|
-
$configurator->merge_yml(
|
|
1320
|
-
$config = $configurator->to_array();
|
|
1321
|
-
$this->required_files['system'] = $config[0]['require'];
|
|
1322
|
-
$configurator->merge_yml( (string) $this->global_config_path, $this->alias );
|
|
1076
|
+
$configurator->merge_yml( $this->global_config_path, $this->alias );
|
|
1323
1077
|
$config = $configurator->to_array();
|
|
1324
|
-
$this->required_files['global'] =
|
|
1325
|
-
$configurator->merge_yml(
|
|
1078
|
+
$this->required_files['global'] = $config[0]['require'];
|
|
1079
|
+
$configurator->merge_yml( $this->project_config_path, $this->alias );
|
|
1326
1080
|
$config = $configurator->to_array();
|
|
1327
|
-
$this->required_files['project'] =
|
|
1328
|
-
$this->required_files['runtime'] = [];
|
|
1081
|
+
$this->required_files['project'] = $config[0]['require'];
|
|
1329
1082
|
}
|
|
1330
1083
|
|
|
1331
1084
|
// Runtime config and args
|
|
@@ -1337,181 +1090,52 @@ class Runner {
|
|
|
1337
1090
|
$assoc_args
|
|
1338
1091
|
);
|
|
1339
1092
|
|
|
1340
|
-
$configurator->merge_array(
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
// Check if --alias flag was used (takes precedence over @foo if both provided)
|
|
1344
|
-
if ( ! empty( $this->runtime_config['alias'] ) ) {
|
|
1345
|
-
/**
|
|
1346
|
-
* @var string $runtime_alias
|
|
1347
|
-
*/
|
|
1348
|
-
$runtime_alias = $this->runtime_config['alias'];
|
|
1349
|
-
$this->alias = $runtime_alias;
|
|
1093
|
+
$configurator->merge_array( $this->runtime_config );
|
|
1350
1094
|
}
|
|
1351
1095
|
|
|
1352
1096
|
list( $this->config, $this->extra_config ) = $configurator->to_array();
|
|
1353
1097
|
$this->aliases = $configurator->get_aliases();
|
|
1354
|
-
$this->
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
}
|
|
1359
|
-
|
|
1360
|
-
/**
|
|
1361
|
-
* Add the @all alias to an aliases array if it doesn't already exist.
|
|
1362
|
-
*
|
|
1363
|
-
* @param array $aliases Aliases array passed by reference.
|
|
1364
|
-
*/
|
|
1365
|
-
private function add_at_all_alias( &$aliases ) {
|
|
1366
|
-
if ( count( $aliases ) && ! isset( $aliases['all'] ) ) {
|
|
1367
|
-
$aliases = array_reverse( $aliases );
|
|
1368
|
-
$aliases['all'] = 'Run command against every registered alias.';
|
|
1369
|
-
$aliases = array_reverse( $aliases );
|
|
1098
|
+
if ( count( $this->aliases ) && ! isset( $this->aliases['@all'] ) ) {
|
|
1099
|
+
$this->aliases = array_reverse( $this->aliases );
|
|
1100
|
+
$this->aliases['@all'] = 'Run command against every registered alias.';
|
|
1101
|
+
$this->aliases = array_reverse( $this->aliases );
|
|
1370
1102
|
}
|
|
1103
|
+
$this->required_files['runtime'] = $this->config['require'];
|
|
1371
1104
|
}
|
|
1372
1105
|
|
|
1373
|
-
private function run_alias_group( $aliases )
|
|
1106
|
+
private function run_alias_group( $aliases ) {
|
|
1374
1107
|
Utils\check_proc_available( 'group alias' );
|
|
1375
1108
|
|
|
1376
1109
|
$php_bin = escapeshellarg( Utils\get_php_binary() );
|
|
1377
1110
|
|
|
1378
|
-
|
|
1379
|
-
* @var string[] $argv
|
|
1380
|
-
*/
|
|
1381
|
-
$argv = $GLOBALS['argv'];
|
|
1382
|
-
|
|
1383
|
-
$script_path = escapeshellarg( $argv[0] );
|
|
1111
|
+
$script_path = $GLOBALS['argv'][0];
|
|
1384
1112
|
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
if ( $wp_cli_config_path ) {
|
|
1388
|
-
$config_path = $wp_cli_config_path;
|
|
1113
|
+
if ( getenv( 'WP_CLI_CONFIG_PATH' ) ) {
|
|
1114
|
+
$config_path = getenv( 'WP_CLI_CONFIG_PATH' );
|
|
1389
1115
|
} else {
|
|
1390
|
-
$config_path =
|
|
1391
|
-
}
|
|
1392
|
-
|
|
1393
|
-
// Exclude 'quiet' from runtime config for subprocesses to allow command output.
|
|
1394
|
-
$subprocess_runtime_config = $this->runtime_config;
|
|
1395
|
-
unset( $subprocess_runtime_config['quiet'] );
|
|
1396
|
-
|
|
1397
|
-
// Precompute command components that are the same for all aliases.
|
|
1398
|
-
$alias_regex = '#' . Configurator::ALIAS_REGEX . '#';
|
|
1399
|
-
$args = implode(
|
|
1400
|
-
' ',
|
|
1401
|
-
array_map(
|
|
1402
|
-
'escapeshellarg',
|
|
1403
|
-
array_filter(
|
|
1404
|
-
(array) $this->arguments,
|
|
1405
|
-
function ( $value ) use ( $alias_regex ) {
|
|
1406
|
-
return ! preg_match( $alias_regex, $value );
|
|
1407
|
-
}
|
|
1408
|
-
)
|
|
1409
|
-
)
|
|
1410
|
-
);
|
|
1411
|
-
|
|
1412
|
-
// Filter out --ssh and --alias args from the subcommands.
|
|
1413
|
-
$filtered_assoc_args = (array) $this->assoc_args;
|
|
1414
|
-
unset( $filtered_assoc_args['ssh'], $filtered_assoc_args['alias'] );
|
|
1415
|
-
|
|
1416
|
-
$assoc_args = Utils\assoc_args_to_str( $filtered_assoc_args );
|
|
1417
|
-
|
|
1418
|
-
$filtered_runtime_config = (array) $subprocess_runtime_config;
|
|
1419
|
-
unset( $filtered_runtime_config['alias'] );
|
|
1420
|
-
$runtime_config = Utils\assoc_args_to_str( $filtered_runtime_config );
|
|
1421
|
-
|
|
1422
|
-
// Check if parallel execution is enabled via environment variable.
|
|
1423
|
-
$parallel = (bool) Utils\get_env_or_config( 'WP_CLI_ALIAS_GROUPS_PARALLEL' );
|
|
1424
|
-
|
|
1425
|
-
// Read STDIN once upfront so every subprocess in the group receives the
|
|
1426
|
-
// same input. When STDIN is a pipe (e.g. `cat file.php | wp @group eval-file -`)
|
|
1427
|
-
// only the first subprocess would otherwise consume the stream; subsequent
|
|
1428
|
-
// ones would see an immediate EOF.
|
|
1429
|
-
$stdin_stream = null;
|
|
1430
|
-
if ( Utils\has_stdin() ) {
|
|
1431
|
-
// Spool STDIN into a temporary, rewindable stream so it can be
|
|
1432
|
-
// replayed to each subprocess without holding it all in memory.
|
|
1433
|
-
$stdin_stream = fopen( 'php://temp/maxmemory:5242880', 'w+' ); // 5MB in-memory, then disk.
|
|
1434
|
-
if ( false === $stdin_stream ) {
|
|
1435
|
-
$stdin_stream = null;
|
|
1436
|
-
} else {
|
|
1437
|
-
$result = stream_copy_to_stream( STDIN, $stdin_stream );
|
|
1438
|
-
if ( false === $result ) {
|
|
1439
|
-
fclose( $stdin_stream );
|
|
1440
|
-
$stdin_stream = null;
|
|
1441
|
-
} else {
|
|
1442
|
-
rewind( $stdin_stream );
|
|
1443
|
-
}
|
|
1444
|
-
}
|
|
1116
|
+
$config_path = Utils\get_home_dir() . '/.wp-cli/config.yml';
|
|
1445
1117
|
}
|
|
1118
|
+
$config_path = escapeshellarg( $config_path );
|
|
1446
1119
|
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
$
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
$env = getenv();
|
|
1457
|
-
$env['WP_CLI_CONFIG_PATH'] = $config_path;
|
|
1458
|
-
|
|
1459
|
-
fflush( STDOUT );
|
|
1460
|
-
fflush( STDERR );
|
|
1461
|
-
|
|
1462
|
-
$proc = Utils\proc_open_compat( $full_command, [ $stdin_spec, STDOUT, STDERR ], $pipes, null, $env );
|
|
1463
|
-
|
|
1464
|
-
if ( $proc ) {
|
|
1465
|
-
if ( null !== $stdin_stream ) {
|
|
1466
|
-
rewind( $stdin_stream );
|
|
1467
|
-
stream_copy_to_stream( $stdin_stream, $pipes[0] );
|
|
1468
|
-
fclose( $pipes[0] );
|
|
1469
|
-
}
|
|
1470
|
-
$procs[] = $proc;
|
|
1471
|
-
}
|
|
1472
|
-
}
|
|
1473
|
-
|
|
1474
|
-
// Wait for all processes to complete.
|
|
1475
|
-
foreach ( $procs as $proc ) {
|
|
1476
|
-
proc_close( $proc );
|
|
1477
|
-
}
|
|
1478
|
-
} else {
|
|
1479
|
-
// Run aliases sequentially (original behavior).
|
|
1480
|
-
foreach ( $aliases as $alias ) {
|
|
1481
|
-
WP_CLI::log( '@' . $alias );
|
|
1482
|
-
$full_command = "{$php_bin} {$script_path} --alias=" . escapeshellarg( $alias ) . " {$args}{$assoc_args}{$runtime_config}";
|
|
1483
|
-
$pipes = [];
|
|
1484
|
-
$stdin_spec = null !== $stdin_stream ? [ 'pipe', 'r' ] : STDIN;
|
|
1485
|
-
$env = getenv();
|
|
1486
|
-
$env['WP_CLI_CONFIG_PATH'] = $config_path;
|
|
1487
|
-
|
|
1488
|
-
fflush( STDOUT );
|
|
1489
|
-
fflush( STDERR );
|
|
1490
|
-
|
|
1491
|
-
$proc = Utils\proc_open_compat( $full_command, [ $stdin_spec, STDOUT, STDERR ], $pipes, null, $env );
|
|
1492
|
-
|
|
1493
|
-
if ( $proc ) {
|
|
1494
|
-
if ( null !== $stdin_stream ) {
|
|
1495
|
-
rewind( $stdin_stream );
|
|
1496
|
-
stream_copy_to_stream( $stdin_stream, $pipes[0] );
|
|
1497
|
-
fclose( $pipes[0] );
|
|
1498
|
-
}
|
|
1499
|
-
proc_close( $proc );
|
|
1500
|
-
}
|
|
1501
|
-
}
|
|
1120
|
+
foreach ( $aliases as $alias ) {
|
|
1121
|
+
WP_CLI::log( $alias );
|
|
1122
|
+
$args = implode( ' ', array_map( 'escapeshellarg', $this->arguments ) );
|
|
1123
|
+
$assoc_args = Utils\assoc_args_to_str( $this->assoc_args );
|
|
1124
|
+
$runtime_config = Utils\assoc_args_to_str( $this->runtime_config );
|
|
1125
|
+
$full_command = "WP_CLI_CONFIG_PATH={$config_path} {$php_bin} {$script_path} {$alias} {$args}{$assoc_args}{$runtime_config}";
|
|
1126
|
+
$pipes = [];
|
|
1127
|
+
$proc = Utils\proc_open_compat( $full_command, [ STDIN, STDOUT, STDERR ], $pipes );
|
|
1128
|
+
proc_close( $proc );
|
|
1502
1129
|
}
|
|
1503
1130
|
}
|
|
1504
1131
|
|
|
1505
|
-
private function set_alias( $alias )
|
|
1506
|
-
$orig_config
|
|
1507
|
-
|
|
1508
|
-
// @phpstan-ignore varTag.type
|
|
1509
|
-
$alias_config = (array) $this->aliases[ $alias ];
|
|
1132
|
+
private function set_alias( $alias ) {
|
|
1133
|
+
$orig_config = $this->config;
|
|
1134
|
+
$alias_config = $this->aliases[ $alias ];
|
|
1510
1135
|
$this->config = array_merge( $orig_config, $alias_config );
|
|
1511
1136
|
foreach ( $alias_config as $key => $_ ) {
|
|
1512
|
-
if ( isset( $orig_config[
|
|
1513
|
-
|
|
1514
|
-
$this->assoc_args[ (string) $key ] = $orig_config[ (string) $key ];
|
|
1137
|
+
if ( isset( $orig_config[ $key ] ) && ! is_null( $orig_config[ $key ] ) ) {
|
|
1138
|
+
$this->assoc_args[ $key ] = $orig_config[ $key ];
|
|
1515
1139
|
}
|
|
1516
1140
|
}
|
|
1517
1141
|
}
|
|
@@ -1522,20 +1146,18 @@ class Runner {
|
|
|
1522
1146
|
$this->enable_error_reporting();
|
|
1523
1147
|
}
|
|
1524
1148
|
|
|
1525
|
-
WP_CLI::debug( $this->system_config_path_debug, 'bootstrap' );
|
|
1526
1149
|
WP_CLI::debug( $this->global_config_path_debug, 'bootstrap' );
|
|
1527
1150
|
WP_CLI::debug( $this->project_config_path_debug, 'bootstrap' );
|
|
1528
|
-
|
|
1529
|
-
WP_CLI::debug( 'argv: ' . implode( ' ', (array) $GLOBALS['argv'] ), 'bootstrap' );
|
|
1151
|
+
WP_CLI::debug( 'argv: ' . implode( ' ', $GLOBALS['argv'] ), 'bootstrap' );
|
|
1530
1152
|
|
|
1531
1153
|
if ( $this->alias ) {
|
|
1532
|
-
if ( 'all' === $this->alias && ! isset( $this->aliases['all'] ) ) {
|
|
1533
|
-
WP_CLI::error( "Cannot use 'all' when no aliases are registered." );
|
|
1154
|
+
if ( '@all' === $this->alias && ! isset( $this->aliases['@all'] ) ) {
|
|
1155
|
+
WP_CLI::error( "Cannot use '@all' when no aliases are registered." );
|
|
1534
1156
|
}
|
|
1535
1157
|
|
|
1536
|
-
if ( 'all' === $this->alias && is_string( $this->aliases['all'] ) ) {
|
|
1158
|
+
if ( '@all' === $this->alias && is_string( $this->aliases['@all'] ) ) {
|
|
1537
1159
|
$aliases = array_keys( $this->aliases );
|
|
1538
|
-
$k = array_search( 'all', $aliases, true );
|
|
1160
|
+
$k = array_search( '@all', $aliases, true );
|
|
1539
1161
|
unset( $aliases[ $k ] );
|
|
1540
1162
|
$this->run_alias_group( $aliases );
|
|
1541
1163
|
exit;
|
|
@@ -1543,7 +1165,7 @@ class Runner {
|
|
|
1543
1165
|
|
|
1544
1166
|
if ( ! array_key_exists( $this->alias, $this->aliases ) ) {
|
|
1545
1167
|
$error_msg = "Alias '{$this->alias}' not found.";
|
|
1546
|
-
$suggestion = Utils\get_suggestion(
|
|
1168
|
+
$suggestion = Utils\get_suggestion( $this->alias, array_keys( $this->aliases ), $threshold = 2 );
|
|
1547
1169
|
if ( $suggestion ) {
|
|
1548
1170
|
$error_msg .= PHP_EOL . "Did you mean '{$suggestion}'?";
|
|
1549
1171
|
}
|
|
@@ -1551,22 +1173,11 @@ class Runner {
|
|
|
1551
1173
|
}
|
|
1552
1174
|
// Numerically indexed means a group of aliases
|
|
1553
1175
|
if ( isset( $this->aliases[ $this->alias ][0] ) ) {
|
|
1554
|
-
|
|
1555
|
-
$group_aliases = (array) $this->aliases[ $this->alias ];
|
|
1176
|
+
$group_aliases = $this->aliases[ $this->alias ];
|
|
1556
1177
|
$all_aliases = array_keys( $this->aliases );
|
|
1557
1178
|
$diff = array_diff( $group_aliases, $all_aliases );
|
|
1558
1179
|
if ( ! empty( $diff ) ) {
|
|
1559
|
-
WP_CLI::error(
|
|
1560
|
-
"Group '@{$this->alias}' contains one or more invalid aliases: " . implode(
|
|
1561
|
-
', ',
|
|
1562
|
-
array_map(
|
|
1563
|
-
function ( $alias ) {
|
|
1564
|
-
return '@' . $alias;
|
|
1565
|
-
},
|
|
1566
|
-
$diff
|
|
1567
|
-
)
|
|
1568
|
-
)
|
|
1569
|
-
);
|
|
1180
|
+
WP_CLI::error( "Group '{$this->alias}' contains one or more invalid aliases: " . implode( ', ', $diff ) );
|
|
1570
1181
|
}
|
|
1571
1182
|
$this->run_alias_group( $group_aliases );
|
|
1572
1183
|
exit;
|
|
@@ -1590,20 +1201,10 @@ class Runner {
|
|
|
1590
1201
|
}
|
|
1591
1202
|
|
|
1592
1203
|
if ( $this->config['ssh'] ) {
|
|
1593
|
-
|
|
1594
|
-
$this->run_ssh_command( (string) $this->config['ssh'] );
|
|
1204
|
+
$this->run_ssh_command( $this->config['ssh'] );
|
|
1595
1205
|
return;
|
|
1596
1206
|
}
|
|
1597
1207
|
|
|
1598
|
-
// Log WP-CLI HTTP requests
|
|
1599
|
-
WP_CLI::add_hook(
|
|
1600
|
-
'http_request_options',
|
|
1601
|
-
static function ( $options, $method, $url ) {
|
|
1602
|
-
WP_CLI::debug( sprintf( 'HTTP %s request to %s', $method, $url ), 'http' );
|
|
1603
|
-
return $options;
|
|
1604
|
-
}
|
|
1605
|
-
);
|
|
1606
|
-
|
|
1607
1208
|
// Handle --path parameter
|
|
1608
1209
|
self::set_wp_root( $this->find_wp_root() );
|
|
1609
1210
|
|
|
@@ -1613,14 +1214,9 @@ class Runner {
|
|
|
1613
1214
|
|| ! Utils\locate_wp_config()
|
|
1614
1215
|
|| count( $this->arguments ) > 2
|
|
1615
1216
|
) ) {
|
|
1616
|
-
$
|
|
1617
|
-
$
|
|
1618
|
-
|
|
1619
|
-
if ( is_array( $r ) ) {
|
|
1620
|
-
$this->auto_check_update();
|
|
1621
|
-
$this->run_command( $this->arguments, $this->assoc_args );
|
|
1622
|
-
}
|
|
1623
|
-
// Help wasn't run or didn't exit, so the command wasn't resolved at this stage.
|
|
1217
|
+
$this->auto_check_update();
|
|
1218
|
+
$this->run_command( $this->arguments, $this->assoc_args );
|
|
1219
|
+
// Help didn't exit so failed to find the command at this stage.
|
|
1624
1220
|
}
|
|
1625
1221
|
|
|
1626
1222
|
// Handle --url parameter
|
|
@@ -1629,44 +1225,8 @@ class Runner {
|
|
|
1629
1225
|
WP_CLI::set_url( $url );
|
|
1630
1226
|
}
|
|
1631
1227
|
|
|
1632
|
-
// Handle --assume-https parameter
|
|
1633
|
-
if ( ! empty( $this->config['assume-https'] ) ) {
|
|
1634
|
-
/**
|
|
1635
|
-
* @var array{HTTPS: string|int} $_SERVER
|
|
1636
|
-
*/
|
|
1637
|
-
if ( ! isset( $_SERVER['HTTPS'] ) ) {
|
|
1638
|
-
$_SERVER['HTTPS'] = 'on';
|
|
1639
|
-
} else {
|
|
1640
|
-
$https_value = strtolower( (string) $_SERVER['HTTPS'] );
|
|
1641
|
-
if ( 'on' !== $https_value && '1' !== $https_value ) {
|
|
1642
|
-
$_SERVER['HTTPS'] = 'on';
|
|
1643
|
-
}
|
|
1644
|
-
}
|
|
1645
|
-
}
|
|
1646
|
-
|
|
1647
1228
|
$this->do_early_invoke( 'before_wp_load' );
|
|
1648
1229
|
|
|
1649
|
-
// Second try at showing man page for help commands.
|
|
1650
|
-
if ( $this->cmd_starts_with( [ 'help' ] )
|
|
1651
|
-
&& ( ! $this->wp_exists()
|
|
1652
|
-
|| ! Utils\locate_wp_config()
|
|
1653
|
-
|| count( $this->arguments ) > 2
|
|
1654
|
-
) ) {
|
|
1655
|
-
$cmd_args = array_slice( $this->arguments, 1 );
|
|
1656
|
-
$autocorrect = ( ! $this->wp_exists() || ! Utils\locate_wp_config() ) ? ( Utils\get_env_or_config( 'WP_CLI_AUTOCORRECT' ) ? 'auto' : 'confirm' ) : 'none';
|
|
1657
|
-
$r = $this->find_command_to_run( $cmd_args, $autocorrect );
|
|
1658
|
-
|
|
1659
|
-
if ( is_array( $r ) ) {
|
|
1660
|
-
// `::find_command_to_run()` modifies `$this->arguments`.
|
|
1661
|
-
// @phpstan-ignore booleanNot.alwaysFalse
|
|
1662
|
-
if ( ! $this->cmd_starts_with( [ 'help' ] ) ) {
|
|
1663
|
-
$this->arguments = array_merge( [ 'help' ], $this->arguments );
|
|
1664
|
-
}
|
|
1665
|
-
$this->auto_check_update();
|
|
1666
|
-
$this->run_command( $this->arguments, $this->assoc_args );
|
|
1667
|
-
}
|
|
1668
|
-
}
|
|
1669
|
-
|
|
1670
1230
|
$this->check_wp_version();
|
|
1671
1231
|
|
|
1672
1232
|
if ( $this->cmd_starts_with( [ 'config', 'create' ] ) ) {
|
|
@@ -1709,13 +1269,13 @@ class Runner {
|
|
|
1709
1269
|
WP_CLI::set_url( $url );
|
|
1710
1270
|
}
|
|
1711
1271
|
|
|
1712
|
-
if ( 'multisite-install' === $this->arguments[1]
|
|
1272
|
+
if ( 'multisite-install' === $this->arguments[1] ) {
|
|
1713
1273
|
// need to fake some globals to skip the checks in wp-includes/ms-settings.php
|
|
1714
1274
|
$url_parts = Utils\parse_url( $url );
|
|
1715
1275
|
self::fake_current_site_blog( $url_parts );
|
|
1716
1276
|
|
|
1717
1277
|
if ( ! defined( 'COOKIEHASH' ) ) {
|
|
1718
|
-
define( 'COOKIEHASH', md5(
|
|
1278
|
+
define( 'COOKIEHASH', md5( $url_parts['host'] ) );
|
|
1719
1279
|
}
|
|
1720
1280
|
}
|
|
1721
1281
|
}
|
|
@@ -1801,63 +1361,29 @@ class Runner {
|
|
|
1801
1361
|
$this->setup_bootstrap_hooks();
|
|
1802
1362
|
|
|
1803
1363
|
// Load Core, mu-plugins, plugins, themes etc.
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
}
|
|
1810
|
-
if ( ! defined( 'WP_DEBUG_DISPLAY' ) ) {
|
|
1811
|
-
define( 'WP_DEBUG_DISPLAY', true );
|
|
1812
|
-
}
|
|
1813
|
-
}
|
|
1814
|
-
|
|
1815
|
-
// For multisite, set a pseudo WP_Screen to make is_admin() return true.
|
|
1816
|
-
// This ensures ms_not_installed() shows detailed error messages instead of
|
|
1817
|
-
// the generic "Error establishing a database connection" message.
|
|
1818
|
-
if ( $this->is_multisite() ) {
|
|
1819
|
-
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Intentional temporary override for error messaging.
|
|
1820
|
-
$GLOBALS['current_screen'] = new class() {
|
|
1821
|
-
public function in_admin() {
|
|
1822
|
-
return true;
|
|
1364
|
+
if ( Utils\wp_version_compare( '4.6-alpha-37575', '>=' ) ) {
|
|
1365
|
+
if ( $this->cmd_starts_with( [ 'help' ] ) ) {
|
|
1366
|
+
// Hack: define `WP_DEBUG` and `WP_DEBUG_DISPLAY` to get `wpdb::bail()` to `wp_die()`.
|
|
1367
|
+
if ( ! defined( 'WP_DEBUG' ) ) {
|
|
1368
|
+
define( 'WP_DEBUG', true );
|
|
1823
1369
|
}
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
WP_CLI::add_wp_hook(
|
|
1827
|
-
'ms_loaded',
|
|
1828
|
-
static function () {
|
|
1829
|
-
// Clean up the pseudo screen object after the network has loaded
|
|
1830
|
-
if ( isset( $GLOBALS['current_screen'] ) && ! ( $GLOBALS['current_screen'] instanceof \WP_Screen ) ) {
|
|
1831
|
-
unset( $GLOBALS['current_screen'] );
|
|
1832
|
-
}
|
|
1370
|
+
if ( ! defined( 'WP_DEBUG_DISPLAY' ) ) {
|
|
1371
|
+
define( 'WP_DEBUG_DISPLAY', true );
|
|
1833
1372
|
}
|
|
1834
|
-
|
|
1373
|
+
}
|
|
1374
|
+
require ABSPATH . 'wp-settings.php';
|
|
1375
|
+
} else {
|
|
1376
|
+
require WP_CLI_ROOT . '/php/wp-settings-cli.php';
|
|
1835
1377
|
}
|
|
1836
1378
|
|
|
1837
|
-
//
|
|
1838
|
-
//
|
|
1839
|
-
|
|
1840
|
-
$wp_cli_autoloaders = spl_autoload_functions() ?: [];
|
|
1841
|
-
|
|
1842
|
-
require ABSPATH . 'wp-settings.php';
|
|
1379
|
+
// Fix memory limit. See https://core.trac.wordpress.org/ticket/14889
|
|
1380
|
+
// phpcs:ignore WordPress.PHP.IniSet.memory_limit_Disallowed -- This is perfectly fine for CLI usage.
|
|
1381
|
+
ini_set( 'memory_limit', -1 );
|
|
1843
1382
|
|
|
1844
1383
|
// Load all the admin APIs, for convenience
|
|
1845
1384
|
require ABSPATH . 'wp-admin/includes/admin.php';
|
|
1846
1385
|
|
|
1847
|
-
|
|
1848
|
-
// precedence over plugin autoloaders that may have been registered
|
|
1849
|
-
// during wp-settings.php loading.
|
|
1850
|
-
$current_autoloaders = spl_autoload_functions();
|
|
1851
|
-
foreach ( array_reverse( $wp_cli_autoloaders ) as $autoloader ) {
|
|
1852
|
-
// Can be false prior to PHP 8.0.
|
|
1853
|
-
// @phpstan-ignore function.alreadyNarrowedType
|
|
1854
|
-
if ( is_array( $current_autoloaders ) && in_array( $autoloader, $current_autoloaders, true ) ) {
|
|
1855
|
-
spl_autoload_unregister( $autoloader );
|
|
1856
|
-
}
|
|
1857
|
-
spl_autoload_register( $autoloader, true, true );
|
|
1858
|
-
}
|
|
1859
|
-
|
|
1860
|
-
WP_CLI::add_wp_hook(
|
|
1386
|
+
add_filter(
|
|
1861
1387
|
'filesystem_method',
|
|
1862
1388
|
static function () {
|
|
1863
1389
|
return 'direct';
|
|
@@ -1874,7 +1400,7 @@ class Runner {
|
|
|
1874
1400
|
WP_CLI::do_hook( 'after_wp_load' );
|
|
1875
1401
|
}
|
|
1876
1402
|
|
|
1877
|
-
private static function fake_current_site_blog( $url_parts )
|
|
1403
|
+
private static function fake_current_site_blog( $url_parts ) {
|
|
1878
1404
|
global $current_site, $current_blog;
|
|
1879
1405
|
|
|
1880
1406
|
if ( ! isset( $url_parts['path'] ) ) {
|
|
@@ -1909,7 +1435,7 @@ class Runner {
|
|
|
1909
1435
|
/**
|
|
1910
1436
|
* Called after wp-config.php is eval'd, to potentially reset `--url`
|
|
1911
1437
|
*/
|
|
1912
|
-
private function maybe_update_url_from_domain_constant()
|
|
1438
|
+
private function maybe_update_url_from_domain_constant() {
|
|
1913
1439
|
if ( ! empty( $this->config['url'] ) || ! empty( $this->config['blog'] ) ) {
|
|
1914
1440
|
return;
|
|
1915
1441
|
}
|
|
@@ -1926,7 +1452,7 @@ class Runner {
|
|
|
1926
1452
|
/**
|
|
1927
1453
|
* Set up hooks meant to run during the WordPress bootstrap process
|
|
1928
1454
|
*/
|
|
1929
|
-
private function setup_bootstrap_hooks()
|
|
1455
|
+
private function setup_bootstrap_hooks() {
|
|
1930
1456
|
|
|
1931
1457
|
if ( $this->config['skip-plugins'] ) {
|
|
1932
1458
|
$this->setup_skip_plugins_filters();
|
|
@@ -1936,18 +1462,6 @@ class Runner {
|
|
|
1936
1462
|
WP_CLI::add_wp_hook( 'setup_theme', [ $this, 'action_setup_theme_wp_cli_skip_themes' ], 999 );
|
|
1937
1463
|
}
|
|
1938
1464
|
|
|
1939
|
-
// Log WordPress HTTP API requests
|
|
1940
|
-
WP_CLI::add_wp_hook(
|
|
1941
|
-
'pre_http_request',
|
|
1942
|
-
static function ( $response, $args, $url ) {
|
|
1943
|
-
$method = isset( $args['method'] ) ? $args['method'] : 'GET';
|
|
1944
|
-
WP_CLI::debug( sprintf( 'HTTP %s request to %s', $method, $url ), 'http' );
|
|
1945
|
-
return $response;
|
|
1946
|
-
},
|
|
1947
|
-
10,
|
|
1948
|
-
3
|
|
1949
|
-
);
|
|
1950
|
-
|
|
1951
1465
|
if ( $this->cmd_starts_with( [ 'help' ] ) ) {
|
|
1952
1466
|
// Try to trap errors on help.
|
|
1953
1467
|
$help_handler = [ $this, 'help_wp_die_handler' ]; // Avoid any cross PHP version issues by not using $this in anon function.
|
|
@@ -1967,27 +1481,7 @@ class Runner {
|
|
|
1967
1481
|
}
|
|
1968
1482
|
|
|
1969
1483
|
// Prevent code from performing a redirect
|
|
1970
|
-
WP_CLI::add_wp_hook(
|
|
1971
|
-
'wp_redirect',
|
|
1972
|
-
function () {
|
|
1973
|
-
ob_start();
|
|
1974
|
-
debug_print_backtrace();
|
|
1975
|
-
$backtrace = (string) ob_get_clean();
|
|
1976
|
-
|
|
1977
|
-
$message = sprintf(
|
|
1978
|
-
'Some code is trying to do a URL redirect. Backtrace: %s',
|
|
1979
|
-
$backtrace
|
|
1980
|
-
);
|
|
1981
|
-
|
|
1982
|
-
if ( Context::ADMIN === $this->context_manager->get_context() ) {
|
|
1983
|
-
WP_CLI::debug( $message, 'bootstrap' );
|
|
1984
|
-
} else {
|
|
1985
|
-
WP_CLI::warning( $message );
|
|
1986
|
-
}
|
|
1987
|
-
|
|
1988
|
-
return false;
|
|
1989
|
-
}
|
|
1990
|
-
);
|
|
1484
|
+
WP_CLI::add_wp_hook( 'wp_redirect', 'WP_CLI\\Utils\\wp_redirect_handler' );
|
|
1991
1485
|
|
|
1992
1486
|
WP_CLI::add_wp_hook(
|
|
1993
1487
|
'nocache_headers',
|
|
@@ -2009,7 +1503,6 @@ class Runner {
|
|
|
2009
1503
|
// Polyfill is_customize_preview(), as it is needed by TwentyTwenty to
|
|
2010
1504
|
// check for starter content.
|
|
2011
1505
|
if ( ! function_exists( 'is_customize_preview' ) ) {
|
|
2012
|
-
// @phpstan-ignore function.inner
|
|
2013
1506
|
function is_customize_preview() {
|
|
2014
1507
|
return false;
|
|
2015
1508
|
}
|
|
@@ -2093,7 +1586,8 @@ class Runner {
|
|
|
2093
1586
|
$run_on_site_not_found = 'search-replace';
|
|
2094
1587
|
}
|
|
2095
1588
|
}
|
|
2096
|
-
if ( $run_on_site_not_found
|
|
1589
|
+
if ( $run_on_site_not_found
|
|
1590
|
+
&& Utils\wp_version_compare( '4.0', '>=' ) ) {
|
|
2097
1591
|
WP_CLI::add_wp_hook(
|
|
2098
1592
|
'ms_site_not_found',
|
|
2099
1593
|
static function () use ( $run_on_site_not_found ) {
|
|
@@ -2132,19 +1626,6 @@ class Runner {
|
|
|
2132
1626
|
10,
|
|
2133
1627
|
3
|
|
2134
1628
|
);
|
|
2135
|
-
|
|
2136
|
-
// Handle ms_network_not_found to provide better error messages
|
|
2137
|
-
WP_CLI::add_wp_hook(
|
|
2138
|
-
'ms_network_not_found',
|
|
2139
|
-
static function ( $domain, $path ) {
|
|
2140
|
-
$url = $domain . $path;
|
|
2141
|
-
$message = $url ? "Network '{$url}' not found." : 'Network not found.';
|
|
2142
|
-
$message .= ' Verify the network exists in the database or run `wp core multisite-install`.';
|
|
2143
|
-
WP_CLI::error( $message );
|
|
2144
|
-
},
|
|
2145
|
-
10,
|
|
2146
|
-
2
|
|
2147
|
-
);
|
|
2148
1629
|
}
|
|
2149
1630
|
|
|
2150
1631
|
// The APC cache is not available on the command-line, so bail, to prevent cache poisoning
|
|
@@ -2167,16 +1648,7 @@ class Runner {
|
|
|
2167
1648
|
static function () use ( $config ) {
|
|
2168
1649
|
if ( isset( $config['user'] ) ) {
|
|
2169
1650
|
$fetcher = new Fetchers\User();
|
|
2170
|
-
|
|
2171
|
-
/**
|
|
2172
|
-
* @var string $user
|
|
2173
|
-
*/
|
|
2174
|
-
$user = $config['user'];
|
|
2175
|
-
|
|
2176
|
-
/**
|
|
2177
|
-
* @var \WP_User $user
|
|
2178
|
-
*/
|
|
2179
|
-
$user = $fetcher->get_check( $user );
|
|
1651
|
+
$user = $fetcher->get_check( $config['user'] );
|
|
2180
1652
|
wp_set_current_user( $user->ID );
|
|
2181
1653
|
} else {
|
|
2182
1654
|
add_action( 'init', 'kses_remove_filters', 11 );
|
|
@@ -2191,7 +1663,7 @@ class Runner {
|
|
|
2191
1663
|
'wp_mail_from',
|
|
2192
1664
|
static function ( $from_email ) {
|
|
2193
1665
|
if ( 'wordpress@' === $from_email ) {
|
|
2194
|
-
$sitename = strtolower(
|
|
1666
|
+
$sitename = strtolower( Utils\parse_url( site_url(), PHP_URL_HOST ) );
|
|
2195
1667
|
if ( substr( $sitename, 0, 4 ) === 'www.' ) {
|
|
2196
1668
|
$sitename = substr( $sitename, 4 );
|
|
2197
1669
|
}
|
|
@@ -2201,6 +1673,48 @@ class Runner {
|
|
|
2201
1673
|
}
|
|
2202
1674
|
);
|
|
2203
1675
|
|
|
1676
|
+
// Don't apply set_url_scheme in get_home_url() or get_site_url().
|
|
1677
|
+
WP_CLI::add_wp_hook(
|
|
1678
|
+
'home_url',
|
|
1679
|
+
static function ( $url, $path, $scheme, $blog_id ) {
|
|
1680
|
+
if ( empty( $blog_id ) || ! is_multisite() ) {
|
|
1681
|
+
$url = get_option( 'home' );
|
|
1682
|
+
} else {
|
|
1683
|
+
switch_to_blog( $blog_id );
|
|
1684
|
+
$url = get_option( 'home' );
|
|
1685
|
+
restore_current_blog();
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
if ( $path && is_string( $path ) ) {
|
|
1689
|
+
$url .= '/' . ltrim( $path, '/' );
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
return $url;
|
|
1693
|
+
},
|
|
1694
|
+
0,
|
|
1695
|
+
4
|
|
1696
|
+
);
|
|
1697
|
+
WP_CLI::add_wp_hook(
|
|
1698
|
+
'site_url',
|
|
1699
|
+
static function ( $url, $path, $scheme, $blog_id ) {
|
|
1700
|
+
if ( empty( $blog_id ) || ! is_multisite() ) {
|
|
1701
|
+
$url = get_option( 'siteurl' );
|
|
1702
|
+
} else {
|
|
1703
|
+
switch_to_blog( $blog_id );
|
|
1704
|
+
$url = get_option( 'siteurl' );
|
|
1705
|
+
restore_current_blog();
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
if ( $path && is_string( $path ) ) {
|
|
1709
|
+
$url .= '/' . ltrim( $path, '/' );
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
return $url;
|
|
1713
|
+
},
|
|
1714
|
+
0,
|
|
1715
|
+
4
|
|
1716
|
+
);
|
|
1717
|
+
|
|
2204
1718
|
// Set up hook for plugins and themes to conditionally add WP-CLI commands.
|
|
2205
1719
|
WP_CLI::add_wp_hook(
|
|
2206
1720
|
'init',
|
|
@@ -2215,9 +1729,6 @@ class Runner {
|
|
|
2215
1729
|
*/
|
|
2216
1730
|
private function setup_skip_plugins_filters() {
|
|
2217
1731
|
$wp_cli_filter_active_plugins = static function ( $plugins ) {
|
|
2218
|
-
/**
|
|
2219
|
-
* @var array<int|string, string> $plugins
|
|
2220
|
-
*/
|
|
2221
1732
|
$skipped_plugins = WP_CLI::get_runner()->config['skip-plugins'];
|
|
2222
1733
|
if ( true === $skipped_plugins ) {
|
|
2223
1734
|
return [];
|
|
@@ -2227,15 +1738,15 @@ class Runner {
|
|
|
2227
1738
|
}
|
|
2228
1739
|
foreach ( $plugins as $a => $b ) {
|
|
2229
1740
|
// active_sitewide_plugins stores plugin name as the key.
|
|
2230
|
-
if ( false !== strpos(
|
|
1741
|
+
if ( false !== strpos( current_filter(), 'active_sitewide_plugins' ) && Utils\is_plugin_skipped( $a ) ) {
|
|
2231
1742
|
unset( $plugins[ $a ] );
|
|
2232
1743
|
// active_plugins stores plugin name as the value.
|
|
2233
|
-
} elseif ( false !== strpos(
|
|
1744
|
+
} elseif ( false !== strpos( current_filter(), 'active_plugins' ) && Utils\is_plugin_skipped( $b ) ) {
|
|
2234
1745
|
unset( $plugins[ $a ] );
|
|
2235
1746
|
}
|
|
2236
1747
|
}
|
|
2237
1748
|
// Reindex because active_plugins expects a numeric index.
|
|
2238
|
-
if ( false !== strpos(
|
|
1749
|
+
if ( false !== strpos( current_filter(), 'active_plugins' ) ) {
|
|
2239
1750
|
$plugins = array_values( $plugins );
|
|
2240
1751
|
}
|
|
2241
1752
|
return $plugins;
|
|
@@ -2277,7 +1788,7 @@ class Runner {
|
|
|
2277
1788
|
$checked_value = $value;
|
|
2278
1789
|
// Always check against the stylesheet value
|
|
2279
1790
|
// This ensures a child theme can be skipped when template differs
|
|
2280
|
-
if ( false !== stripos(
|
|
1791
|
+
if ( false !== stripos( current_filter(), 'option_template' ) ) {
|
|
2281
1792
|
$checked_value = get_option( 'stylesheet' );
|
|
2282
1793
|
}
|
|
2283
1794
|
|
|
@@ -2337,9 +1848,9 @@ class Runner {
|
|
|
2337
1848
|
* For use after wp-config.php has loaded, but before the rest of WordPress
|
|
2338
1849
|
* is loaded.
|
|
2339
1850
|
*/
|
|
2340
|
-
private function is_multisite()
|
|
1851
|
+
private function is_multisite() {
|
|
2341
1852
|
if ( defined( 'MULTISITE' ) ) {
|
|
2342
|
-
return MULTISITE;
|
|
1853
|
+
return MULTISITE;
|
|
2343
1854
|
}
|
|
2344
1855
|
|
|
2345
1856
|
if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) {
|
|
@@ -2365,19 +1876,14 @@ class Runner {
|
|
|
2365
1876
|
/**
|
|
2366
1877
|
* Check whether there's a WP-CLI update available, and suggest update if so.
|
|
2367
1878
|
*/
|
|
2368
|
-
private function auto_check_update()
|
|
1879
|
+
private function auto_check_update() {
|
|
2369
1880
|
|
|
2370
1881
|
// `wp cli update` only works with Phars at this time.
|
|
2371
|
-
if ( !
|
|
1882
|
+
if ( ! Utils\inside_phar() ) {
|
|
2372
1883
|
return;
|
|
2373
1884
|
}
|
|
2374
1885
|
|
|
2375
|
-
|
|
2376
|
-
* @var array<int, string> $argv
|
|
2377
|
-
*/
|
|
2378
|
-
$argv = $_SERVER['argv'];
|
|
2379
|
-
|
|
2380
|
-
$existing_phar = (string) realpath( (string) $argv[0] );
|
|
1886
|
+
$existing_phar = realpath( $_SERVER['argv'][0] );
|
|
2381
1887
|
// Phar needs to be writable to be easily updateable.
|
|
2382
1888
|
if ( ! is_writable( $existing_phar ) || ! is_writable( dirname( $existing_phar ) ) ) {
|
|
2383
1889
|
return;
|
|
@@ -2389,12 +1895,12 @@ class Runner {
|
|
|
2389
1895
|
}
|
|
2390
1896
|
|
|
2391
1897
|
// Allow hosts and other providers to disable automatic check update.
|
|
2392
|
-
if (
|
|
1898
|
+
if ( getenv( 'WP_CLI_DISABLE_AUTO_CHECK_UPDATE' ) ) {
|
|
2393
1899
|
return;
|
|
2394
1900
|
}
|
|
2395
1901
|
|
|
2396
1902
|
// Permit configuration of number of days between checks.
|
|
2397
|
-
$days_between_checks =
|
|
1903
|
+
$days_between_checks = getenv( 'WP_CLI_AUTO_CHECK_UPDATE_DAYS' );
|
|
2398
1904
|
if ( false === $days_between_checks ) {
|
|
2399
1905
|
$days_between_checks = 1;
|
|
2400
1906
|
}
|
|
@@ -2403,18 +1909,18 @@ class Runner {
|
|
|
2403
1909
|
$cache_key = 'wp-cli-update-check';
|
|
2404
1910
|
// Bail early on the first check, so we don't always check on an unwritable cache.
|
|
2405
1911
|
if ( ! $cache->has( $cache_key ) ) {
|
|
2406
|
-
$cache->write( $cache_key,
|
|
1912
|
+
$cache->write( $cache_key, time() );
|
|
2407
1913
|
return;
|
|
2408
1914
|
}
|
|
2409
1915
|
|
|
2410
1916
|
// Bail if last check is still within our update check time period.
|
|
2411
1917
|
$last_check = (int) $cache->read( $cache_key );
|
|
2412
|
-
if ( ( time() - ( 24 * 60 * 60 *
|
|
1918
|
+
if ( ( time() - ( 24 * 60 * 60 * $days_between_checks ) ) < $last_check ) {
|
|
2413
1919
|
return;
|
|
2414
1920
|
}
|
|
2415
1921
|
|
|
2416
1922
|
// In case the operation fails, ensure the timestamp has been updated.
|
|
2417
|
-
$cache->write( $cache_key,
|
|
1923
|
+
$cache->write( $cache_key, time() );
|
|
2418
1924
|
|
|
2419
1925
|
// Check whether any updates are available.
|
|
2420
1926
|
ob_start();
|
|
@@ -2430,76 +1936,9 @@ class Runner {
|
|
|
2430
1936
|
}
|
|
2431
1937
|
|
|
2432
1938
|
// Looks like an update is available, so let's prompt to update.
|
|
2433
|
-
|
|
2434
|
-
//
|
|
2435
|
-
|
|
2436
|
-
$update_args['yes'] = true;
|
|
2437
|
-
}
|
|
2438
|
-
|
|
2439
|
-
// Get the current Phar's modification time before the update.
|
|
2440
|
-
$phar_mtime_before = filemtime( $existing_phar );
|
|
2441
|
-
|
|
2442
|
-
WP_CLI::run_command( [ 'cli', 'update' ], $update_args );
|
|
2443
|
-
|
|
2444
|
-
// Check if the Phar was actually updated by comparing modification times.
|
|
2445
|
-
clearstatcache( true, $existing_phar );
|
|
2446
|
-
$phar_mtime_after = filemtime( $existing_phar );
|
|
2447
|
-
if ( $phar_mtime_after > $phar_mtime_before ) {
|
|
2448
|
-
// After update, re-execute the original command with the new Phar.
|
|
2449
|
-
$this->rerun_command_after_update();
|
|
2450
|
-
}
|
|
2451
|
-
}
|
|
2452
|
-
|
|
2453
|
-
/**
|
|
2454
|
-
* Re-execute the original command with the updated Phar.
|
|
2455
|
-
*
|
|
2456
|
-
* This method is called after a successful auto-update to transparently
|
|
2457
|
-
* continue with the user's original command using the new Phar version.
|
|
2458
|
-
*/
|
|
2459
|
-
private function rerun_command_after_update(): void {
|
|
2460
|
-
/**
|
|
2461
|
-
* @var string[] $original_args
|
|
2462
|
-
*/
|
|
2463
|
-
$original_args = array_slice( (array) $GLOBALS['argv'], 1 );
|
|
2464
|
-
|
|
2465
|
-
// Skip re-execution if the original command was a CLI command
|
|
2466
|
-
// to avoid infinite loops or redundant execution.
|
|
2467
|
-
// Use $this->arguments instead of $original_args to properly handle aliases.
|
|
2468
|
-
if ( ! empty( $this->arguments ) && 'cli' === $this->arguments[0] ) {
|
|
2469
|
-
exit( 0 );
|
|
2470
|
-
}
|
|
2471
|
-
|
|
2472
|
-
// Skip re-execution if there are no arguments (just running `wp` with no command).
|
|
2473
|
-
if ( empty( $original_args ) ) {
|
|
2474
|
-
exit( 0 );
|
|
2475
|
-
}
|
|
2476
|
-
|
|
2477
|
-
/**
|
|
2478
|
-
* @var string[] $argv
|
|
2479
|
-
*/
|
|
2480
|
-
$argv = $_SERVER['argv'];
|
|
2481
|
-
|
|
2482
|
-
// Get the path to the current (now updated) Phar.
|
|
2483
|
-
$phar_path = realpath( $argv[0] );
|
|
2484
|
-
if ( false === $phar_path ) {
|
|
2485
|
-
WP_CLI::error( 'Failed to determine the path to the WP-CLI Phar.' );
|
|
2486
|
-
}
|
|
2487
|
-
|
|
2488
|
-
// Build the command to re-execute.
|
|
2489
|
-
$php_binary = Utils\get_php_binary();
|
|
2490
|
-
$escaped_args = array_map( 'escapeshellarg', $original_args );
|
|
2491
|
-
$command = sprintf(
|
|
2492
|
-
'%s %s %s',
|
|
2493
|
-
escapeshellarg( $php_binary ),
|
|
2494
|
-
escapeshellarg( $phar_path ),
|
|
2495
|
-
implode( ' ', $escaped_args )
|
|
2496
|
-
);
|
|
2497
|
-
|
|
2498
|
-
WP_CLI::debug( 'Re-executing command after update.', 'bootstrap' );
|
|
2499
|
-
|
|
2500
|
-
// Execute the command and pass through the exit code.
|
|
2501
|
-
passthru( $command, $exit_code );
|
|
2502
|
-
exit( $exit_code );
|
|
1939
|
+
WP_CLI::run_command( [ 'cli', 'update' ] );
|
|
1940
|
+
// If the Phar was replaced, we can't proceed with the original process.
|
|
1941
|
+
exit;
|
|
2503
1942
|
}
|
|
2504
1943
|
|
|
2505
1944
|
/**
|
|
@@ -2530,7 +1969,7 @@ class Runner {
|
|
|
2530
1969
|
* @param array $list Reference to list accumulating results.
|
|
2531
1970
|
* @param string $parent Parent command to use as prefix.
|
|
2532
1971
|
*/
|
|
2533
|
-
private function enumerate_commands( CompositeCommand $command, array &$list, $parent = '' )
|
|
1972
|
+
private function enumerate_commands( CompositeCommand $command, array &$list, $parent = '' ) {
|
|
2534
1973
|
foreach ( $command->get_subcommands() as $subcommand ) {
|
|
2535
1974
|
/** @var CompositeCommand $subcommand */
|
|
2536
1975
|
$command_string = empty( $parent )
|
|
@@ -2546,7 +1985,7 @@ class Runner {
|
|
|
2546
1985
|
/**
|
|
2547
1986
|
* Enables (almost) full PHP error reporting to stderr.
|
|
2548
1987
|
*/
|
|
2549
|
-
private function enable_error_reporting()
|
|
1988
|
+
private function enable_error_reporting() {
|
|
2550
1989
|
if ( E_ALL !== error_reporting() ) {
|
|
2551
1990
|
// Don't enable E_DEPRECATED as old versions of WP use PHP 4 style constructors and the mysql extension.
|
|
2552
1991
|
error_reporting( E_ALL & ~E_DEPRECATED );
|