Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New User Registration Error #545

Closed
baberuth22 opened this issue May 18, 2016 · 12 comments
Closed

New User Registration Error #545

baberuth22 opened this issue May 18, 2016 · 12 comments
Labels
troubleshooting Support with current features

Comments

@baberuth22
Copy link

baberuth22 commented May 18, 2016

I can create the master user with no problem, but when I try to create another user, I get the following error.

Slim Application Error
The application could not run because of the following error:

Details
Type: ErrorException
Code: 8
Message: Trying to get property of non-object
File: /Users/bryansaltzman/Sites/api.direct/userfrosting/models/notify/Notification.php
Line: 71
Trace
#0 /Users/bryansaltzman/Sites/api.direct/userfrosting/models/notify/Notification.php(71): Slim\Slim::handleErrors(8, 'Trying to get p...', '/Users/bryansal...', 71, Array)
#1 /Users/bryansaltzman/Sites/api.direct/userfrosting/controllers/AccountController.php(434): UserFrosting\Notification->fromWebsite()
#2 /Users/bryansaltzman/Sites/api.direct/public/index.php(112): UserFrosting\AccountController->register()
#3 [internal function]: {closure}('register')
#4 /Users/bryansaltzman/Sites/api.direct/userfrosting/vendor/slim/slim/Slim/Route.php(468): call_user_func_array(Object(Closure), Array)
#5 /Users/bryansaltzman/Sites/api.direct/userfrosting/vendor/slim/slim/Slim/Slim.php(1357): Slim\Route->dispatch()
#6 /Users/bryansaltzman/Sites/api.direct/userfrosting/vendor/slim/slim/Slim/Middleware/Flash.php(85): Slim\Slim->call()
#7 /Users/bryansaltzman/Sites/api.direct/userfrosting/vendor/slim/slim/Slim/Middleware/MethodOverride.php(92): Slim\Middleware\Flash->call()
#8 /Users/bryansaltzman/Sites/api.direct/userfrosting/middleware/CsrfGuard.php(51): Slim\Middleware\MethodOverride->call()
#9 /Users/bryansaltzman/Sites/api.direct/userfrosting/middleware/usersession/UserSession.php(27): Slim\Extras\Middleware\CsrfGuard->call()
#10 /Users/bryansaltzman/Sites/api.direct/userfrosting/vendor/slim/slim/Slim/Middleware/PrettyExceptions.php(67): UserFrosting\UserSession->call()
#11 /Users/bryansaltzman/Sites/api.direct/userfrosting/vendor/slim/slim/Slim/Slim.php(1302): Slim\Middleware\PrettyExceptions->call()
#12 /Users/bryansaltzman/Sites/api.direct/public/index.php(424): Slim\Slim->run()
#13 {main}

I've tried two fresh installs running PHP7 MAMP. Any insights?

The error indicates static::$app is undefined on the line:
$this->from_email = static::$app->site->admin_email;

@baberuth22
Copy link
Author

screen shot 2016-05-18 at 1 00 15 am

@alexweissman alexweissman added the troubleshooting Support with current features label May 19, 2016
@alexweissman
Copy link
Member

Is it that $app is undefined, or $app->site? I haven't actually played with PHP7 yet, so it is possible that this is some compatibility issue.

@ghost
Copy link

ghost commented May 20, 2016

I run PHP Version 7.0.4 (XAMPP) on my local machine and haven't experienced any issues registering or creating users as root. I'm certainly not an expert but I would comment out these lines: https://github.com/userfrosting/UserFrosting/blob/master/userfrosting/controllers/AccountController.php#L425-L451 and try again... Just to narrow down the issue.

@baberuth22
Copy link
Author

@thomasspe I commented out those lines registered without error so the issue is right there.

@alexweissman I downgraded to PHP5 and still see the error.

@ghost
Copy link

ghost commented May 20, 2016

Ok full disclaimer: I'm not an expert and if you follow my advice it's basically trial and error until something works without necessarily knowing why it works. If pretty much any other person gives you advice, prefer their advice over mine.

Next thing I would check would be in my database in the uf_configuration table that I have set the admin_email and site_title to something meaningful (check for leading and trailing white spaces). If so I would comment out this line and uncomment the things I commented out before: https://github.com/userfrosting/UserFrosting/blob/master/userfrosting/models/notify/Notification.php#L71 and insert this:

$this->from_email = 'test@test.com';

and then see if I get an error because of static::$app->site->site_title; or a mailer error.

@cmy82
Copy link

cmy82 commented May 21, 2016

I agree with @thomasspe about changing line 71. You also want to make sure that the email account listed for the from/admin email actually exists as it must be a real account when using PHPMailer.

@alexweissman
Copy link
Member

But this should give an SMTP error message, no?

@cmy82
Copy link

cmy82 commented May 21, 2016

It throws an error, but from my memory from using in a script it failed silently unless debugging was turned on, and I don't know how errors are handled in UF, so it might display it or not. But I know with PHPMailer the account has to exist to be used.

@baberuth22
Copy link
Author

baberuth22 commented May 21, 2016

    public function fromWebsite($reply_to_email = null, $reply_to_name = null){
        //$this->from_email = static::$app->site->admin_email;
        //$this->from_name = static::$app->site->site_title;
        //$this->reply_to_email = $reply_to_email ? $reply_to_email : static::$app->site->admin_email;
        //$this->reply_to_name = $reply_to_name ? $reply_to_name : static::$app->site->site_title;
        $this->from_email = 'admin@domain.com';
        $this->from_name = 'Admin';
        $this->reply_to_email = 'noreply@domain.com';
        $this->reply_to_name = 'Admin';
    }

After commenting out lines that reference the non existent static::$app the code reaches a new error.

The "./templates" directory does not exist.


Details
Type: Twig_Error_Loader
Message: The "./templates" directory does not exist.
File: /Users/bryansaltzman/Sites/api.direct/userfrosting/vendor/twig/twig/lib/Twig/Loader/Filesystem.php
Line: 94
Trace
#0 /Users/bryansaltzman/Sites/api.direct/userfrosting/vendor/twig/twig/lib/Twig/Loader/Filesystem.php(76): Twig_Loader_Filesystem->addPath('./templates', '__main__')
#1 /Users/bryansaltzman/Sites/api.direct/userfrosting/vendor/twig/twig/lib/Twig/Loader/Filesystem.php(34): Twig_Loader_Filesystem->setPaths(Array)
#2 /Users/bryansaltzman/Sites/api.direct/userfrosting/vendor/slim/views/Twig.php(121): Twig_Loader_Filesystem->__construct(Array)
#3 /Users/bryansaltzman/Sites/api.direct/userfrosting/vendor/slim/views/Twig.php(101): Slim\Views\Twig->getInstance()
#4 /Users/bryansaltzman/Sites/api.direct/userfrosting/models/notify/Notification.php(137): Slim\Views\Twig->getEnvironment()
#5 /Users/bryansaltzman/Sites/api.direct/userfrosting/controllers/AccountController.php(442): UserFrosting\Notification->send()
#6 /Users/bryansaltzman/Sites/api.direct/public/index.php(112): UserFrosting\AccountController->register()
#7 [internal function]: {closure}('register')
#8 /Users/bryansaltzman/Sites/api.direct/userfrosting/vendor/slim/slim/Slim/Route.php(468): call_user_func_array(Object(Closure), Array)
#9 /Users/bryansaltzman/Sites/api.direct/userfrosting/vendor/slim/slim/Slim/Slim.php(1357): Slim\Route->dispatch()
#10 /Users/bryansaltzman/Sites/api.direct/userfrosting/vendor/slim/slim/Slim/Middleware/Flash.php(85): Slim\Slim->call()
#11 /Users/bryansaltzman/Sites/api.direct/userfrosting/vendor/slim/slim/Slim/Middleware/MethodOverride.php(92): Slim\Middleware\Flash->call()
#12 /Users/bryansaltzman/Sites/api.direct/userfrosting/middleware/CsrfGuard.php(51): Slim\Middleware\MethodOverride->call()
#13 /Users/bryansaltzman/Sites/api.direct/userfrosting/middleware/usersession/UserSession.php(27): Slim\Extras\Middleware\CsrfGuard->call()
#14 /Users/bryansaltzman/Sites/api.direct/userfrosting/vendor/slim/slim/Slim/Middleware/PrettyExceptions.php(67): UserFrosting\UserSession->call()
#15 /Users/bryansaltzman/Sites/api.direct/userfrosting/vendor/slim/slim/Slim/Slim.php(1302): Slim\Middleware\PrettyExceptions->call()
#16 /Users/bryansaltzman/Sites/api.direct/public/index.php(424): Slim\Slim->run()
#17 {main}
![screen shot 2016-05-21 at 10 20 47 am](https://cloud.githubusercontent.com/assets/2997424/15449848/0a37c86a-1f3e-11e6-8379-37e74c689a75.png)

@alexweissman
Copy link
Member

alexweissman commented May 21, 2016

Yeah, I have the feeling that there is a bigger problem here. It seems to me like the entire setupTwig function isn't getting called at all: https://github.com/userfrosting/UserFrosting/blob/master/userfrosting/models/UserFrosting.php#L129-L195

This is both where $app->site is created, and where the template paths are added.

@alexweissman
Copy link
Member

Btw, setupTwig is supposed to get called in initialize.php:

$app->setupTwig();

@alexweissman
Copy link
Member

Please let us know if you still need help with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
troubleshooting Support with current features
Projects
None yet
Development

No branches or pull requests

3 participants