Mwalker has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/78914


Change subject: Finalizing move to Symfony
......................................................................

Finalizing move to Symfony

* Fix an autoloader problem where we were requiring symfony classes
  before the configuration was loaded and the include paths registered

  The longer term fix will be to allow the configuration to be loaded
  with 'views' and for the view to be progressively modified as we
  determine what should be in the view (this will also help with accounts.)

* Fix leftover SymfonyRequest/SmashPigRequest confusion. We still had some
  old class names around which were throwing errors. Everything should now
  use the smashpig wrapper classes around the symfony ones.

Change-Id: Ia4d4159d012ecc12871a36ee99b02becc0a33ccd
---
M .gitignore
M Core/AutoLoader.php
M Core/Http/IHttpActionHandler.php
M Core/Http/RequestHandler.php
M config_defaults.php
5 files changed, 22 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/SmashPig 
refs/changes/14/78914/1

diff --git a/.gitignore b/.gitignore
index b13c9b9..eea3e05 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
 # Configuration
 composer.phar
 config.php
+PublicHttp/.htaccess
 
 # IDE Tools
 .idea
diff --git a/Core/AutoLoader.php b/Core/AutoLoader.php
index dc0df44..17d8388 100644
--- a/Core/AutoLoader.php
+++ b/Core/AutoLoader.php
@@ -56,6 +56,13 @@
                $this->addNamespacePath( 'SmashPig', $defaultPath );
 
                spl_autoload_register( array( $this, 'autoload' ) );
+
+               // For the moment this is here because we require Composer 
supplied libraries
+               // before we're fully initialized
+               /* TODO: Remove this and place back in 
addConfiguredIncludePaths() once we have
+                        something like configuration views that could 
partially load the
+                        configuration and thus allow multiple calls of 
includes */
+               require_once( __DIR__ . '/../vendor/autoload.php' );
        }
 
        public function addConfiguredNamespaces() {
diff --git a/Core/Http/IHttpActionHandler.php b/Core/Http/IHttpActionHandler.php
index 9db7de8..8188084 100644
--- a/Core/Http/IHttpActionHandler.php
+++ b/Core/Http/IHttpActionHandler.php
@@ -1,7 +1,5 @@
 <?php namespace SmashPig\Core\Http;
 
-use Symfony\Component\HttpFoundation\Request;
-
 /**
  * Declaration that a class is able to process an HTTP request.
  */
diff --git a/Core/Http/RequestHandler.php b/Core/Http/RequestHandler.php
index 7bc3c96..fff540f 100644
--- a/Core/Http/RequestHandler.php
+++ b/Core/Http/RequestHandler.php
@@ -29,20 +29,20 @@
         */
        public static function process( $configPath = null ) {
                // --- Get the request and response objects
-               $symfonyRequest = SymfonyRequest::createFromGlobals();
-               $symfonyResponse = new Response();
-               $symfonyResponse->setPrivate();
+               $request = Request::createFromGlobals();
+               $response = new Response();
+               $response->setPrivate();
 
                // --- Break the request into parts ---
-               $uri = $symfonyRequest->query->get( 'p', '' );
+               $uri = $request->query->get( 'p', '' );
                $parts = explode( '/', $uri );
 
                if ( count( $parts ) < 2 ) {
-                       $symfonyResponse->setStatusCode(
+                       $response->setStatusCode(
                                403,
                                'Cannot process this request: bad URI format. A 
configuration node and an action is required'
                        );
-                       return $symfonyResponse;
+                       return $response;
                }
 
                $view = array_shift( $parts );
@@ -68,8 +68,8 @@
                // Check to make sure there's even a point to continuing
                if ( !$config->nodeExists( "endpoints/$action" ) ) {
                        Logger::debug( '403 will be given for unknown action on 
inbound URL.', $uri );
-                       $symfonyResponse->setStatusCode( 403, "Action '$action' 
not configured. Cannot continue." );
-                       return $symfonyResponse;
+                       $response->setStatusCode( 403, "Action '$action' not 
configured. Cannot continue." );
+                       return $response;
                }
 
                // Register fun additional things
@@ -80,18 +80,18 @@
                // --- Actually get the endpoint object and start the request 
---
                $endpointObj = $config->obj( "endpoints/$action" );
                if ( $endpointObj instanceof IHttpActionHandler ) {
-                       $endpointObj->execute( $symfonyRequest, 
$symfonyResponse, $parts );
+                       $endpointObj->execute( $request, $response, $parts );
                } else {
                        $str = "Requested action '$action' does not implement a 
known handler. Cannot continue.";
                        Logger::debug( $str );
-                       $symfonyResponse->setStatusCode( 500, $str );
+                       $response->setStatusCode( 500, $str );
                }
 
-               $code = $symfonyResponse->getStatusCode();
+               $code = $response->getStatusCode();
                if ( ( $code !== 200 ) && ( $code !== 302 ) ) {
-                       $symfonyResponse->setContent( '' );
+                       $response->setContent( '' );
                }
-               return $symfonyResponse;
+               return $response;
        }
 
        public static function lastChanceErrorHandler( $errno, $errstr, 
$errfile = 'Unknown File',
diff --git a/config_defaults.php b/config_defaults.php
index 757cf0b..b3a2e08 100644
--- a/config_defaults.php
+++ b/config_defaults.php
@@ -71,9 +71,7 @@
 
         'namespaces' => array(),
 
-               'include-files' => array(
-                       'vendor/autoload.php',
-               ),
+               'include-files' => array(),
 
                'include-paths' => array(),
 

-- 
To view, visit https://gerrit.wikimedia.org/r/78914
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia4d4159d012ecc12871a36ee99b02becc0a33ccd
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/SmashPig
Gerrit-Branch: master
Gerrit-Owner: Mwalker <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to