Make WordPress Core

Opened 4 weeks ago

Closed 2 weeks ago

#65888 closed enhancement (fixed)

Remove the unused wp-profiler.php from the PHPUnit test suite

Reported by: lancewillett Owned by: SergeyBiryukov
Priority: normal Milestone: 7.2
Component: Build/Test Tools Version:
Severity: normal Keywords: has-patch has-unit-tests
Cc: Focuses:

Description (last modified by lancewillett)

tests/phpunit/includes/wp-profiler.php defines WPProfiler and the wppf_start() / wppf_stop() helpers. Nothing uses it, and it cannot run.

No callers

  • No references to wp-profiler, wppf_start, or WPProfiler anywhere in src/ or tests/.
  • tests/phpunit/includes/bootstrap.php never loads it.

It cannot run

WPProfiler::start() reads four properties from the global object cache:

$wp_object_cache->cold_cache_hits
$wp_object_cache->warm_cache_hits
$wp_object_cache->cache_misses
$wp_object_cache->dirty_objects

None of the four exist in src/wp-includes/class-wp-object-cache.php, and none exist in the test drop-in at tests/phpunit/includes/object-cache.php. Calling it would raise undefined-property notices, which this suite treats as failures — phpunit.xml.dist sets both convertNoticesToExceptions="true" and failOnRisky="true".

History

The file arrived with the 2013 initial import of the unit-tests repository into develop.svn. It has had 16 commits since, all janitorial: coding standards, docblock formatting, spacing, access modifiers, PHP4 constructor removal. None changed its behaviour. The most recent touch was a docblock fix in 2024.

#46505 illustrates the cost — an enhancement milestoned for 5.2 that added access modifiers to this file.

So core has spent over a decade applying standards sweeps and review time to a file that is both unreferenced and non-functional.

Proposed

Delete tests/phpunit/includes/wp-profiler.php.

If per-block profiling of the test suite is wanted later, it is better written against the current object-cache API than revived from this one.

Change History (6)

#1 @lancewillett
4 weeks ago

  • Description modified (diff)

#2 @lancewillett
4 weeks ago

Followed this back into the old unit-tests SVN repository, which is still reachable at unit-tests.svn.wordpress.org (currently r1337). It answers the question the description left open.

All revision numbers below are from that repository, not core.

The file has never had a live caller

  • [56/tests] (2007-10-18, tellyworth) — "add wp-profiler". No references anywhere in the suite at that revision.
  • [79/tests] (2007-11-08, tellyworth) — wp-testcase/test_import_wp.php gains the only reference the file has ever had, and it is commented out from the start: #include_once(DIR_TESTROOT.'/wp-testlib/wp-profiler.php');. svn blame attributes that line to [79/tests], and it was never modified again.
  • [120/tests] (2007-12-04) — "profiler: record cache info", which added the object-cache instrumentation.
  • [407/tests] (2011-08-04, ryan) — "Pinking shears", whitespace only.
  • [751/tests] and [875/tests] (2012) — repository restructuring only.

I checked for callers at [120/tests], at [407/tests], and at the repository's final state. Zero in every case, apart from that one commented-out include.

The cache instrumentation broke in 2008

[120/tests] was correct when it was written. WordPress 2.3's wp-includes/cache.php did define cold_cache_hits, warm_cache_hits, cache_misses and dirty_objects. They were gone by WordPress 2.5 and have not existed since.

So the four properties WPProfiler::start() reads have been absent from core for roughly 18 years.

Effect on this ticket

The closing caveat in the description is no longer needed. The pre-2013 history is available and it shows the file was never wired up in the first place, rather than having fallen out of use later.

Last edited 2 weeks ago by SergeyBiryukov (previous) (diff)

This ticket was mentioned in PR #13092 on WordPress/wordpress-develop by @lancewillett.


4 weeks ago
#3

  • Keywords has-patch has-unit-tests added

## What this changes

Removes the unused tests/phpunit/includes/wp-profiler.php file.

The profiler has no callers and is never loaded by the PHPUnit bootstrap. Its object-cache instrumentation also depends on properties that are no longer available.

Removing it prevents future maintenance work on test tooling that cannot run. If profiling is needed later, it can be built against the current test suite and object-cache APIs.

## Testing

  • git diff --check passed.
  • Confirmed no references to wp-profiler, WPProfiler, or its wppf_*() helpers remain.
  • Confirmed the PHPUnit bootstrap does not load the profiler.

No runtime tests were added because this removes unreachable tooling.

#4 @lancewillett
4 weeks ago

Related: #65894 removes tests/phpunit/wp-mail-real-test.php on the same grounds.

#5 @SergeyBiryukov
2 weeks ago

  • Milestone Awaiting Review7.2

#6 @SergeyBiryukov
2 weeks ago

  • Owner set to SergeyBiryukov
  • Resolutionfixed
  • Status newclosed

In 63345:

Build/Test Tools: Remove unused PHPUnit profiler.

The tests/phpunit/includes/wp-profiler.php script has no callers and is never loaded by the PHPUnit bootstrap. Its object-cache instrumentation also depends on properties that are no longer available.

Removing it prevents future maintenance work on test tooling that cannot run. If profiling is needed later, it can be built against the current test suite and object-cache APIs.

Developed in https://github.com/WordPress/wordpress-develop/pull/13092.

Follow-up to [56/tests].

Props lancewillett.
Fixes #65888.

Note: See TracTickets for help on using tickets.