Open BTrey opened 8 years ago
It appears the installation of Dancer2::Serializer::JSON updated Dancer2 from version .166001 to .200000 and the Database plugin from 2.15 to 2.16. I'm not sure exactly where it lies but there appears to be an incompatibility between this version of Dancer2, the Database plugin and YARBAC. YARBAC is attempting to access $self->db and that key doesn't appear to exist. I'm guessing YARBAC needs to be updated to work with the newer versions and am opening a bug on YARBAC.
Per here there is a known issue with YARBAC. YARBAC appears to be abandoned. There are three bugs filed against it on CPAN, one of which is a year old, and none of them have been so much as acknowledged. There was a pull request on the incompatibility with the new version of Dancer in January and it doesn't appear to have had any response either. So I switched to Auth::Extensible with the Database provider and I'm still having issues with the Database credentials. Getting a 500 error: Can't get a database connection without settings supplied! Please check you've supplied settings in config as per the Dancer::Plugin::Database documentation at /usr/local/share/perl/5.14.2/Dancer/Plugin/Database/Core.pm line 213.
Throwing a few debug Dumpers into the complaining function like so:
sub _get_connection {
my ($settings, $logger, $hook_exec) = @_;
$logger->(debug => "settings are " . Dumper($settings));
$logger->(debug => "dsn is " . Dumper($settings->{dsn}));
$logger->(debug => "driver is " . Dumper($settings->{driver}));
if (!$settings->{dsn} && !$settings->{driver}) {`
gets me:
[dexter:17741] debug @2016-06-12 19:14:37> settings are $VAR1 = {
'connection_check_threshold' => 30,
'connections' => {
'port' => 3306,
'username' => 'dexter',
'host' => 'localhost',
'database' => 'sonic',
'on_connect_do' => [
'SET CHARACTER SET \'utf8\'',
'SET SQL_MODE=\'TRADITIONAL\''
],
'password' => 'blah',
'log_queries' => 0,
'dbi_params' => {
'AutoCommit' => 1,
'RaiseError' => 1
},
'driver' => 'mysql'
},
'charset' => 'utf-8'
}; in /usr/local/share/perl/5.14.2/Dancer2/Core/App.pm l. 836
[dexter:17741] debug @2016-06-12 19:14:37> dsn is $VAR1 = undef; in /usr/local/share/perl/5.14.2/Dancer2/Core/App.pm l. 836
[dexter:17741] debug @2016-06-12 19:14:37> driver is $VAR1 = undef; in /usr/local/share/perl/5.14.2/Dancer2/Core/App.pm l. 836
So the DB settings are there under settings->connections (including settings->connections->driver) but not under either settings->dsn or settings->drvier. The user code works fine with an older version of Dancer2. I verified by copying the Dancer and Dancer2 pm's and all subdirectories from another machine which has not been updated to the new version of Dancer2.
In file Core.pm, sub _get_settings, making this change:
if (!defined $name) {
#$return_settings = { %$settings };
$return_settings = $settings->{connections};
gets past the error. Obviously, you'd need to make a similar change under the else clause if you have multiple connections. I'm not at all certain this is anything more than a band-aid for another issue, so I'm not submitting a pull request.
Using YARBAC with Dancer2 and Database. This has been working but abruptly stopped working yesterday. Immediately prior to it stopping working, I installed Dancer2::Serializer::JSON. Not sure that was the cause of the issue but I thought I'd mention it in case it's relevant. I used git to restore my app to a previous version which was working fine, and it continues to fail. The error I'm getting on the web page is a 500: Can't call method "quick_select" on an undefined value at /usr/local/share/perl/5.14.2/Dancer2/Plugin/Auth/YARBAC/Provider/Database.pm line 108.
The call stack is:
Checking the Apache log, however, I find:
[Dancer2::Plugin::Auth::YARBAC::Provider::Database:31005] error @2016-06-06 08:21:31> No DB settings for sonic in /usr/local/share/perl/5.14.2/Dancer2/Core/App.pm l. 836
That error actually appears to come from Dancer/Plugin/Database/Core.pm, sub database. In that sub, _get_settings($arg, $settings, $logger) is failing. I added a couple of quick logging lines to _get_settings and I'm seeing:
[Dancer2::Plugin::Auth::YARBAC::Provider::Database:31005] error @2016-06-06 08:21:31> $settings->{connections} connections does not exist in /usr/local/share/perl/5.14.2/Dancer2/Core/App.pm l. 836 [Dancer2::Plugin::Auth::YARBAC::Provider::Database:31005] error @2016-06-06 08:21:31> $settings is $VAR1 = { 'charset' => 'utf-8' }; in /usr/local/share/perl/5.14.2/Dancer2/Core/App.pm l. 836
However, from the 500 error web page, I see this:
So it appears as though the settings are being correctly read from my .yml file. I'm far from an expert Perl developer, so perhaps I just have something screwed up.