r40522 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40521‎ | r40522 | r40523 >
Date:08:58, 6 September 2008
Author:btongminh
Status:old
Tags:
Comment:
Add session accessor functions to WebRequest
Modified paths:
  • /trunk/phase3/includes/WebRequest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/WebRequest.php
@@ -637,6 +637,18 @@
638638 }
639639 }
640640 }
 641+
 642+ /*
 643+ * Get data from $_SESSION
 644+ */
 645+ function getSessionData( $key ) {
 646+ if( !isset( $_SESSION[$key] ) )
 647+ return null;
 648+ return $_SESSION[$key];
 649+ }
 650+ function setSessionData( $key, $data ) {
 651+ $_SESSION[$key] = $data;
 652+ }
641653 }
642654
643655 /**
@@ -652,7 +664,7 @@
653665 * fake GET/POST values
654666 * @param $wasPosted Bool: whether to treat the data as POST
655667 */
656 - function FauxRequest( $data, $wasPosted = false ) {
 668+ function FauxRequest( $data, $wasPosted = false, $session ) {
657669 if( is_array( $data ) ) {
658670 $this->data = $data;
659671 } else {
@@ -660,7 +672,12 @@
661673 }
662674 $this->wasPosted = $wasPosted;
663675 $this->headers = array();
 676+ $this->session = $session;
664677 }
 678+
 679+ function notImplemented( $method ) {
 680+ throw new MWException( "{$method}() not implemented" );
 681+ }
665682
666683 function getText( $name, $default = '' ) {
667684 # Override; don't recode since we're using internal data
@@ -680,15 +697,24 @@
681698 }
682699
683700 function getRequestURL() {
684 - throw new MWException( 'FauxRequest::getRequestURL() not implemented' );
 701+ $this->notImplemented( __METHOD__ );
685702 }
686703
687704 function appendQuery( $query ) {
688 - throw new MWException( 'FauxRequest::appendQuery() not implemented' );
 705+ $this->notImplemented( __METHOD__ );
689706 }
690707
691708 function getHeader( $name ) {
692709 return isset( $this->headers[$name] ) ? $this->headers[$name] : false;
693710 }
694711
 712+ function getSessionData( $key ) {
 713+ if( !isset( $this->session[$key] ) )
 714+ return null;
 715+ return $this->session[$key];
 716+ }
 717+ function setSessionData( $key, $data ) {
 718+ $this->notImplemented( __METHOD__ );
 719+ }
 720+
695721 }