WordPress / WordPress/plugin-check

PHP fatal undefined constant

Open
#975 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
362
Forks
126
Avg merge
1d 23h
Merged PRs (30d)
22

Description

downloaded from https://wordpress.org/plugins/plugin-check/ v1.5.0

Doesn't work due to undefined constant

wp plugin check some-plugin --require=wp-content/plugins/plugin-check/cli.php

Undefined constant "WordPress\Plugin_Check\Checker\Checks\WP_PLUGIN_CHECK_PLUGIN_DIR_PATH"
in /path/to/test/wp-content/plugins/plugin-check/includes/Checker/Checks/Abstract_PHP_CodeSniffer_Check.php on line 72

#0 /path/to/test/wp-content/plugins/plugin-check/includes/Checker/Checks.php (80): WordPress/Plugin_Check/Checker/Checks/Abstract_PHP_CodeSniffer_Check->run( $result = WordPress/Plugin_Check/Checker/Check_Result Object )
#1 /path/to/test/wp-content/plugins/plugin-check/includes/Checker/Checks.php (45): WordPress/Plugin_Check/Checker/Checks->run_check_with_result( $check = WordPress/Plugin_Check/Checker/Checks/General/I18n_Usage_Check Object, $result = WordPress/Plugin_Check/Checker/Check_Result Object )
#2 [callback of next frame] (-1): WordPress/Plugin_Check/Checker/Checks->WordPress/Plugin_Check/Checker\{closure}( WordPress/Plugin_Check/Checker/Checks/General/I18n_Usage_Check Object, 'i18n_usage' )
#3 /path/to/test/wp-content/plugins/plugin-check/includes/Checker/Checks.php (42): array_walk( &$array = 
#4 /path/to/test/wp-content/plugins/plugin-check/includes/Checker/Abstract_Check_Runner.php (374): WordPress/Plugin_Check/Checker/Checks->run_checks( $context = WordPress/Plugin_Check/Checker/Check_Context Object, $checks = 
#5 /path/to/test/wp-content/plugins/plugin-check/includes/CLI/Plugin_Check_Command.php (221): WordPress/Plugin_Check/Checker/Abstract_Check_Runner->run()
#6 [callback of next frame] (-1): WordPress/Plugin_Check/CLI/Plugin_Check_Command->check( $args = Array( [0] => some-plugin), $assoc_args = Array( [format] => table) )
#7 phar:///usr/bin/wp-dev/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php (100): call_user_func( $callback = Array( [0] => WordPress/Plugin_Check/CLI/Plugin_Check_Command Object, [1] => check), ...$args = Array( [0] => some-plugin), Array( [format] => table) )
#8 [callback of next frame] (-1): WP_CLI/Dispatcher/CommandFactory::WP_CLI/Dispatcher\{closure}( Array( [0] => some-plugin), Array( [format] => table) )
#9 phar:///usr/bin/wp-dev/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php (497): call_user_func( $callback = Closure Object, ...$args = Array( [0] => some-plugin), Array( [format] => table) )
#10 phar:///usr/bin/wp-dev/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php (441): WP_CLI/Dispatcher/Subcommand->invoke( $args = Array( [0] => some-plugin), $assoc_args = Array( [format] => table), $extra_args = Array() )
#11 phar:///usr/bin/wp-dev/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php (464): WP_CLI/Runner->run_command( $args = Array( [0] => plugin, [1] => check, [2] => some-plugin), $assoc_args = Array() )
#12 phar:///usr/bin/wp-dev/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php (1296): WP_CLI/Runner->run_command_and_exit()
#13 phar:///usr/bin/wp-dev/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php (28): WP_CLI/Runner->start()
#14 phar:///usr/bin/wp-dev/vendor/wp-cli/wp-cli/php/bootstrap.php (83): WP_CLI/Bootstrap/LaunchRunner->process( $state = WP_CLI/Bootstrap/BootstrapState Object )
#15 phar:///usr/bin/wp-dev/vendor/wp-cli/wp-cli/php/wp-cli.php (32): WP_CLI/bootstrap()
#16 phar:///usr/bin/wp-dev/php/boot-phar.php (20): include( 'phar:///usr/bin/wp-dev/vendor/wp-cli/wp-cli/php/wp-cli.php' )
#17 /usr/bin/wp-dev (4): include( 'phar:///usr/bin/wp-dev/php/boot-phar.php' )

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the shown wp plugin check command, then inspect includes/Checker/Checks/Abstract_PHP_CodeSniffer_Check.php around line 72 and trace how WP_PLUGIN_CHECK_PLUGIN_DIR_PATH is defined or loaded. Done means the check runs without the reported undefined-constant fatal error.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.