persist(); } function store( $index, $info ) { SessionManager::getGlobalSession()->set( 'captcha' . $index, $info ); } function retrieve( $index ) { return SessionManager::getGlobalSession()->get( 'captcha' . $index, false ); } function clear( $index ) { SessionManager::getGlobalSession()->remove( 'captcha' . $index ); } function cookiesNeeded() { return true; } } class CaptchaCacheStore extends CaptchaStore { function store( $index, $info ) { global $wgCaptchaSessionExpiration; ObjectCache::getMainStashInstance()->set( wfMemcKey( 'captcha', $index ), $info, $wgCaptchaSessionExpiration ); } function retrieve( $index ) { $info = ObjectCache::getMainStashInstance()->get( wfMemcKey( 'captcha', $index ) ); if ( $info ) { return $info; } else { return false; } } function clear( $index ) { ObjectCache::getMainStashInstance()->delete( wfMemcKey( 'captcha', $index ) ); } function cookiesNeeded() { return false; } } class CaptchaHashStore extends CaptchaStore { protected $data = []; public function store( $index, $info ) { $this->data[$index] = $info; } public function retrieve( $index ) { if ( array_key_exists( $index, $this->data ) ) { return $this->data[$index]; } return false; } public function clear( $index ) { unset( $this->data[$index] ); } public function cookiesNeeded() { return false; } public function clearAll() { $this->data = []; } }