Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Should not depend on Input::hasSessionStore() #155

Open
pesterhazy opened this issue Jan 16, 2014 · 20 comments
Open

Should not depend on Input::hasSessionStore() #155

pesterhazy opened this issue Jan 16, 2014 · 20 comments

Comments

@pesterhazy
Copy link

I use Entrust, which depends on Ardent. I recently upgraded to Laravel 4.1. Now my tests fail with the following backtrace:

PHP Fatal error:  Call to undefined method Illuminate\Http\Input::hasSessionStore() in /vagrant/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 205
PHP Stack trace:
PHP   1. {main}() /vagrant/vendor/phpunit/phpunit/composer/bin/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() /vagrant/vendor/phpunit/phpunit/composer/bin/phpunit:63
PHP   3. PHPUnit_TextUI_Command->run() /vagrant/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:129
PHP   4. PHPUnit_TextUI_TestRunner->doRun() /vagrant/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:176
PHP   5. PHPUnit_Framework_TestSuite->run() /vagrant/vendor/phpunit/phpunit/PHPUnit/TextUI/TestRunner.php:349
PHP   6. PHPUnit_Framework_TestSuite->run() /vagrant/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:705
PHP   7. PHPUnit_Framework_TestSuite->runTest() /vagrant/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:745
PHP   8. PHPUnit_Framework_TestCase->run() /vagrant/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:775
PHP   9. PHPUnit_Framework_TestResult->run() /vagrant/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:783
PHP  10. PHPUnit_Framework_TestCase->runBare() /vagrant/vendor/phpunit/phpunit/PHPUnit/Framework/TestResult.php:648
PHP  11. PHPUnit_Framework_TestCase->runTest() /vagrant/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:838
PHP  12. ReflectionMethod->invokeArgs() /vagrant/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:983
PHP  13. ApiAgencyTest->testPermissions() /vagrant/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:983
PHP  14. PermissionTableSeeder->run() /vagrant/app/tests/controllers/api/ApiAgencyTest.php:145
PHP  15. LaravelBook\Ardent\Ardent->save() /vagrant/app/database/seeds/real_seeder/PermissionTableSeeder.php:120
PHP  16. LaravelBook\Ardent\Ardent->internalSave() /vagrant/vendor/laravelbook/ardent/src/LaravelBook/Ardent/Ardent.php:605
PHP  17. LaravelBook\Ardent\Ardent->validate() /vagrant/vendor/laravelbook/ardent/src/LaravelBook/Ardent/Ardent.php:578
PHP  18. Illuminate\Support\Facades\Input::hasSessionStore() /vagrant/vendor/laravelbook/ardent/src/LaravelBook/Ardent/Ardent.php:535
PHP  19. Illuminate\Support\Facades\Facade::__callStatic() /vagrant/vendor/laravelbook/ardent/src/LaravelBook/Ardent/Ardent.php:535

The reason seems to be that the method call Input::hasSessionStore() has been removed as of Laravel 4.1.

In my test no session store is available, I think.

@pesterhazy
Copy link
Author

This patch seems to fix the error message. I'm not entirely sure that calling Request::hasSession() is the right thing to do.

From 72c30075cc2753d774d57f1afe1008f258cf313e Mon Sep 17 00:00:00 2001
From: Paulus Esterhazy <[email protected]>
Date: Thu, 16 Jan 2014 12:36:35 +0100
Subject: [PATCH 1/1] remove reference to Input::hasSessionStorage(), which
 doesn't exist in Laravel 4.1 anymore

---
 src/LaravelBook/Ardent/Ardent.php | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/LaravelBook/Ardent/Ardent.php b/src/LaravelBook/Ardent/Ardent.php
index 271f543..6bd60de 100644
--- a/src/LaravelBook/Ardent/Ardent.php
+++ b/src/LaravelBook/Ardent/Ardent.php
@@ -16,6 +16,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
 use Illuminate\Events\Dispatcher;
 use Illuminate\Support\MessageBag;
 use Illuminate\Support\Facades\Input;
+use Illuminate\Support\Facades\Request;
 use Illuminate\Support\Facades\Hash;
 use Illuminate\Support\Facades\Validator;
 use Illuminate\Database\Eloquent\Model;
@@ -531,7 +532,7 @@ abstract class Ardent extends Model {
                $this->validationErrors = $validator->messages();

                // stash the input to the current session
-               if (!self::$externalValidator && Input::hasSessionStore()) {
+               if (!self::$externalValidator && Request::hasSession()) {
                    Input::flash();
                }
            }
-- 
1.8.3.2

@LimeBlast
Copy link

I'm getting the same problem when I run my tests.

@ghost
Copy link

ghost commented Jan 16, 2014

Same problem occurring here on a fresh install of Laravel 4.1 and just following the setup guide. The exception is reported as:
Symfony \ Component \ Debug \ Exception \ FatalErrorException

Call to undefined method Illuminate\Http\Request::hasSessionStore()

@globsecure
Copy link

+1

@IgnitedCoder
Copy link

Same error here... huge site so need a fix please. Also it produces the error when seeding the Users table which worked great before.

@LimeBlast
Copy link

If you update your composer.json to include the repositories chunk found here: #133 (comment) - it'll provide a temporary fix (at least it did for me)

@wemersonjanuario
Copy link

thanks for you temporary fix

@IgnitedCoder
Copy link

Tried the temp fix in my composer.json file and still no luck... none of the test users can register now at all. Call to undefined method Illuminate\Http\Request::hasSessionStore()

Please provide a fix.

@LimeBlast
Copy link

I'm in no way qualified to answer any of these questions, and so what I'm about to say could be totally backwards, but after you added in the repositories bit, did you do a composer update?

@IgnitedCoder
Copy link

Absolutely... composer update :) and no what you said is not totally backwards, its good to check... Its easy to forget to run composer commands.

Thanks

@IgnitedCoder
Copy link

Ok this fixed it... I went back a version on Laravel...
"laravel/framework": "4.1.16",

run composer update. I guess this will have to do until this issues is resolved.

@LimeBlast
Copy link

I have no idea how to actually go about doing this, but the only other thing I can think of is to drop back to an version of Laravel that still has the Input::hasSessionStore() method

I'd suggest starting by looking here: https://packagist.org/packages/laravel/framework

then modifying the "laravel/framework": "4.1.*", line in composer.json to "laravel/framework": "4.1.18", then running composer update. If you still get the issue, swap it out for 4.1.17 and try again.

Keep doing this until you find one that works (then report back here and let us all know which one works.

@LimeBlast
Copy link

Ha, you beat me to it, good job :)

@davidthingsaker
Copy link

I had the same error appearing when using a simple validation on an email field. I dropped down from 4.1.18 to 4.1.16 and works fine.

@IgnitedCoder
Copy link

@LimeBlast - No worries, your feedback is most appreciated.

@pesterhazy
Copy link
Author

Here's the Laravel commit that removed Request::hasSessionStore(): laravel/framework@328e6cf

@dalabarge
Copy link
Contributor

@LimeBlast thanks for digging. For those using Entrust, you'll need to manually set your Ardent tag to 2.4.1 as Entrust has switched to requiring 2.4.x which if you use Ardent's repo will be 2.4.0. You can use this composer.json block to fix that. It essentially forces a package version of 2.4.1 that points to my fork's (or yours if you change it) to the HEAD of master. It's a slight improvement over #133 block. It's been tested to be compatible with 4.1.18 so you don't have to be dropped back to 4.1.16.

"require": [
        "laravelbook/ardent": "2.4.1"
],
"repositories": [
        {
                "type": "package",
                "package": {
                        "name": "laravelbook/ardent",
                        "version": "2.4.2",
                        "source": {
                                "type": "git",
                                "url": "https://github.com/bexarcreativeinc/ardent.git",
                                "reference": "master"
                        },
                        "require": {
                                "php": ">=5.3.0",
                                "illuminate/support": "4.x",
                                "illuminate/database": "4.x",
                                "illuminate/validation": "4.x"
                        },
                        "autoload": {
                                "psr-0": {
                                        "LaravelBook\\Ardent": "src/"
                                }
                        }
                }
        }
]

@58bits
Copy link

58bits commented Feb 1, 2014

thanks @bexarcreative-daniel. Is there likely to be an official ardent 2.4.1 release soon?

@tbergeron
Copy link

I had this error has well, using an early version of Laravel fixed it. It'd be interesting to have a release to fix this issue though 👍

@dalabarge
Copy link
Contributor

@58bits I've released a similar MIT licensed package that uses traits and is unit tested and is compatible with Laravel 4.2. You might want to consider it if you need more frequent tag releases. https://github.com/esensi/model

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants