private $timeout;
/** @var float Seconds */
private $lastWaitTime;
+ /** @var integer|null */
+ private $rusageMode;
const CONDITION_REACHED = 1;
const CONDITION_CONTINUE = 0; // evaluates as falsey
$this->condition = $condition;
$this->timeout = $timeout;
$this->busyCallbacks =& $busyCallbacks;
+
+ if ( defined( 'HHVM_VERSION' ) && PHP_OS === 'Linux' ) {
+ $this->rusageMode = 2; // RUSAGE_THREAD
+ } elseif ( function_exists( 'getrusage' ) ) {
+ $this->rusageMode = 0; // RUSAGE_SELF
+ }
}
/**
* @return float Returns 0.0 if not supported (Windows on PHP < 7)
*/
protected function getCpuTime() {
- $time = 0.0;
-
- if ( defined( 'HHVM_VERSION' ) && PHP_OS === 'Linux' ) {
- $ru = getrusage( 2 /* RUSAGE_THREAD */ );
- } else {
- $ru = getrusage( 0 /* RUSAGE_SELF */ );
- }
- if ( $ru ) {
- $time += $ru['ru_utime.tv_sec'] + $ru['ru_utime.tv_usec'] / 1e6;
- $time += $ru['ru_stime.tv_sec'] + $ru['ru_stime.tv_usec'] / 1e6;
+ if ( $this->rusageMode === null ) {
+ return microtime( true ); // assume worst case (all time is CPU)
}
+ $ru = getrusage( $this->rusageMode );
+ $time = $ru['ru_utime.tv_sec'] + $ru['ru_utime.tv_usec'] / 1e6;
+ $time += $ru['ru_stime.tv_sec'] + $ru['ru_stime.tv_usec'] / 1e6;
+
return $time;
}
* @ingroup SpecialPage
*/
class UserrightsPage extends SpecialPage {
- # The target of the local right-adjuster's interest. Can be gotten from
- # either a GET parameter or a subpage-style parameter, so have a member
- # variable for it.
+ /**
+ * The target of the local right-adjuster's interest. Can be gotten from
+ * either a GET parameter or a subpage-style parameter, so have a member
+ * variable for it.
+ * @var null|string $mTarget
+ */
protected $mTarget;
/*
* @var null|User $mFetchedUser The user object of the target username or null.
$this->mTarget = $request->getVal( 'user' );
}
+ if ( is_string( $this->mTarget ) ) {
+ $this->mTarget = trim( $this->mTarget );
+ }
+
$available = $this->changeableGroups();
if ( $this->mTarget === null ) {