wiki.techinc.nl/tests/phpunit/mocks/BrokenClass2.php
Reedy e4bee84a27 AutoLoader: Use require_once rather than require
This was seen in WMF production during a train deployment, where namespacing of classes,
which had been serialized (for example CacheTime), along with our PSR-4 definitions may result
in cases where PHP tries to load the same PHP file more than once. Combined with non obvious
error messages, require_once gives us better behaviour and error messages.

More explicitly:
In T378006, the autoloader is entered from class_exists(), and the class has a filename
resolvable with PSR-4 which is already loaded by a non-PSR-4 class name. Using require_once
would allow class_exists() to return false in that case.

In T372500, the autoloader is entered from unserialize(). It looks like require_once would
just give you a more informative error message.

Bug: T378006
Bug: T372500
Change-Id: I928f29198af9baf81a3cae604b3adf41595c2176
(cherry picked from commit 03dd4ae7ae0e2ce7e45f0bf2cb913642eef842a8)
2024-10-24 01:36:18 +00:00

14 lines
314 B
PHP

<?php
namespace MediaWiki\Tests;
/**
* A class that exists but cannot be instantiated because
* its base class does not exist. For testing logic related
* to class_exists and is_callable checks.
*/
class BrokenClass2 extends \Some\Thing\ThatDoesNotExist_8723465 {
public function aMethod() {
// noop
}
}