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

error installing 4.0.0-beta1 #7124

Closed
christopherdarling opened this issue Jul 4, 2017 · 7 comments
Closed

error installing 4.0.0-beta1 #7124

christopherdarling opened this issue Jul 4, 2017 · 7 comments

Comments

@christopherdarling
Copy link
Contributor

I have installed 4.0.0-beta1 via composer create-project silverstripe/installer ./ 4.0.0-beta1

When I try and install SilverStripe using install.php I am receiving the following error after entering database details and admin credentials

Building database schema...
POST /54.5/constant-sd/www/install.php

Line 233 in G:\sites\54.5\constant-sd\www\framework\src\Dev\Install\Installer.php

Source

224             $dbAdmin = new DatabaseAdmin();
225             $dbAdmin->setRequest($request);
226             $dbAdmin->pushCurrent();
227             $dbAdmin->doInit();
228             $dbAdmin->doBuild(true);
229 
230             // Create default administrator user and group in database
231             // (not using Security::setDefaultAdmin())
232             $adminMember = DefaultAdminService::singleton()->findOrCreateDefaultAdmin();
233             $adminMember->Email = $config['admin']['username'];
234             $adminMember->Password = $config['admin']['password'];
235             $adminMember->PasswordEncryption = Security::config()->get('encryption_algorithm');
236 
237             try {
238                 $this->statusMessage('Creating default CMS admin account...');
239                 $adminMember->write();
Trace

Monolog\ErrorHandler->handleError(2,Creating default object from empty value,G:\sites\54.5\constant-sd\www\framework\src\Dev\Install\Installer.php,233,Array) 
Installer.php:233
SilverStripe\Dev\Install\Installer->SilverStripe\Dev\Install\{closure}(SilverStripe\Control\HTTPRequest) 
call_user_func(Closure,SilverStripe\Control\HTTPRequest) 
HTTPApplication.php:66
SilverStripe\Control\HTTPApplication->SilverStripe\Control\{closure}(SilverStripe\Control\HTTPRequest) 
HTTPMiddlewareAware.php:65
SilverStripe\Control\HTTPApplication->callMiddleware(SilverStripe\Control\HTTPRequest,Closure) 
HTTPApplication.php:67
SilverStripe\Control\HTTPApplication->execute(SilverStripe\Control\HTTPRequest,Closure,1) 
Installer.php:249
SilverStripe\Dev\Install\Installer->install(Array) 
install5.php:270
include(G:\sites\54.5\constant-sd\www\framework\src\Dev\Install\install5.php) 
install.php:27
include(...\www\framework\src\Dev\Install\install.php) 
install.php:15
Creating default CMS admin account...
[Alert] Call to undefined method stdClass::write()
POST /www/install.php

Line 239 in ...\www\framework\src\Dev\Install\Installer.php

Source

230             // Create default administrator user and group in database
231             // (not using Security::setDefaultAdmin())
232             $adminMember = DefaultAdminService::singleton()->findOrCreateDefaultAdmin();
233             $adminMember->Email = $config['admin']['username'];
234             $adminMember->Password = $config['admin']['password'];
235             $adminMember->PasswordEncryption = Security::config()->get('encryption_algorithm');
236 
237             try {
238                 $this->statusMessage('Creating default CMS admin account...');
239                 $adminMember->write();
240             } catch (Exception $e) {
241                 $this->statusMessage(
242                     sprintf('Warning: Default CMS admin account could not be created (error: %s)', $e->getMessage())
243                 );
244             }
245 
Trace
@tractorcow
Copy link
Contributor

This is caused by a regression in what was findOrCreateAnAdministrator (now findOrCreateDefaultAdmin).

Since this code actually creates the default admin (as it doesn't yet exist) it will fail.

I suggest to re-implement the prior logic in a separate api (one which explicitly creates a new admin and assigns it the necessary permissions) but isn't locked to a default admin. Essentially this method should be refactored out of

// If no admin is found, create one
if (!$admin) {
// 'Password' is not set to avoid creating
// persistent logins in the database. See Security::setDefaultAdmin().
// Set 'Email' to identify this as the default admin
$admin = Member::create();
$admin->FirstName = _t(__CLASS__ . '.DefaultAdminFirstname', 'Default Admin');
$admin->Email = static::getDefaultAdminUsername();
$admin->write();
}
// Ensure this user is in the admin group
if (!$admin->inGroup($adminGroup)) {
// Add member to group instead of adding group to member
// This bypasses the privilege escallation code in Member_GroupSet
$adminGroup
->DirectMembers()
->add($admin);
}
$this->extend('afterFindOrCreateDefaultAdmin', $admin);
return $admin;
in such a way that it ensures a new record is created.

@tractorcow
Copy link
Contributor

I think I can imagine how this slipped past testing; A test environment with a pre-existing default admin setup (via .env) would not raise this issue.

@tractorcow tractorcow added this to the Recipe 4.0.0-beta2 milestone Jul 4, 2017
@tractorcow tractorcow self-assigned this Jul 5, 2017
tractorcow pushed a commit to open-sausages/silverstripe-framework that referenced this issue Jul 6, 2017
@tractorcow
Copy link
Contributor

Fix at #7136

@tractorcow tractorcow removed their assignment Jul 6, 2017
@GustavoMarcante
Copy link

GustavoMarcante commented Aug 1, 2017

@flamerohr @tractorcow The issue still happening, probably because Composer repository keeps offering beta1.
Therefore, I also cannot install SilverStripe.

@tractorcow
Copy link
Contributor

@flamerohr @tractorcow The issue still happening, probably because Composer repository keeps offering beta1.
Therefore, I also cannot install SilverStripe.

You can change the @beta constraits to point to .x-dev, or you could checkout the 4.0.x-dev version of installer with all the new version constraints.

If you get stuck please post your composer.json here and I'll help you fix it.

It should look like the below: https://github.com/silverstripe/silverstripe-installer/blob/4/composer.json

@GustavoMarcante
Copy link

@tractorcow Thanks for your reply.
I could avoid this error running composer create-project silverstripe/installer silverstripe 4.0.x-dev as you oriented.
But another one came:
#7231

@tractorcow
Copy link
Contributor

Thanks for that bug report, I'll address this pretty soon. :)

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

No branches or pull requests

3 participants