Comments (5)
Can you propose a code change that would work for you?
Bear in mind that you can always set up a test connection - which you should for dev env.
And for prod it should auto use the connection defined.
maybe you forgot that:
'DatabaseLog' => [
'datasource' => 'default',
This way it uses the default connection for sure and will not try to open an alternative one.
If you want to bypass database log for local dev, you can also do this in bootstap_cli file:
if (Configure::read('debug') || Configure::read('App.isLocal')) {
$logTypes = array_keys(Configure::read('Log'));
foreach ($logTypes as $logType) {
Configure::write('Log.' . $logType . '.className', 'File');
}
}
But you said your problem is specific to prod.
from cakephp-databaselog.
Hi Mark! Thanks for answering!
'DatabaseLog' => [
'datasource' => 'default',
exists in my app.php.
The error itself is thrown inside CakePHP class: vendor/cakephp/cakephp/src/TestSuite/Fixture/TestFixture.php
Stack Trace:
#0 /var/www/weba_konfigurator/vendor/cakephp/cakephp/src/TestSuite/Fixture/TestFixture.php(182): Cake\Datasource\ConnectionManager::get('test')
#1 /var/www/weba_konfigurator/vendor/cakephp/cakephp/src/TestSuite/Fixture/TestFixture.php(145): Cake\TestSuite\Fixture\TestFixture->_schemaFromFields()
#2 /var/www/weba_konfigurator/vendor/dereuromark/cakephp-databaselog/tests/Fixture/DatabaseLogsFixture.php(71): Cake\TestSuite\Fixture\TestFixture->init()
#3 /var/www/weba_konfigurator/vendor/cakephp/cakephp/src/TestSuite/Fixture/TestFixture.php(113): DatabaseLog\Test\Fixture\DatabaseLogsFixture->init()
#4 /var/www/weba_konfigurator/vendor/dereuromark/cakephp-databaselog/src/Model/Table/LazyTableTrait.php(63): Cake\TestSuite\Fixture\TestFixture->__construct('default')
#5 /var/www/weba_konfigurator/vendor/dereuromark/cakephp-databaselog/src/Model/Table/DatabaseLogsTable.php(55): DatabaseLog\Model\Table\DatabaseLogsTable->ensureTables(Array)
For now I've solved the problem by creating test connection on prod. To be honest it's the first time I see testing related stuff injected into the code at the app level (and during initialization of class!). It's a bit strange for me ;)
The solution that comes to my head first is to add option in config file to omit all the test suite related stuff (and even make it default). In ma case I had to run plugin migrations manually anyway, but I didn't have time to explore why.
If I don't get something, you can close this topic. If I have some spare time I will try to make a pull request with my proposition.
from cakephp-databaselog.
Why using fixtures in prod?
from cakephp-databaselog.
Hi there! Sorry for a late reply, but honestly I forgot about that topic. I came here to report another issue, so I will reply to this one too.
Why using fixtures in prod?
I'm not using fixtures in prod, but I have them as a part of the repository, so the test-related files do exist in production environment. The error stacktrace is:
- DatabaseLogsTable calls
$this->ensureTables(['DatabaseLog.DatabaseLogs'])
during initialization. (line 55) - ensureTables() creates classname using
App::className($name, 'Test/Fixture', 'Fixture');
(LazyTableTrait.php, line 58) - I don't get why plugin is expecting that those classes exist, but ok, I have those fixtures - ensureTables() tries to instantiate fixture class using
$fixture = new $class($this->getConnection()->configName());
(LazyTableTrait.php, line 63) - during initialization the framework's
Cake\TestSuite\Fixture\TestFixture::init()
is called, and it calls it's_schemaFromFields()
method _schemaFromFields()
gets it's own connection. which is obviously "test", because fixtures system is designed for dev only.
So once again my problem is: you are using test-related parts of the framework inside the test-unrelated plugin, which is bad solution IMO.
But don't worry - it's a small plugin, thanks for doing it. I hope I'll manage to make PR ;)
from cakephp-databaselog.
All right, looking forward to your PR.
Maybe the docs should be more clear that if you are using
https://github.com/dereuromark/CakePHP-DatabaseLog/blob/master/src/Model/Table/LazyTableTrait.php#L45 and SqLite auto build feature, that this app must not be designed for prod.
This is only meant to get started quickly for local test projects or POC apps, never for real live prod apps.
from cakephp-databaselog.
Related Issues (18)
- Add monitor shell command HOT 1
- Fix postgres compatability
- Building a dashboard HOT 1
- Missing route HOT 2
- Duplicate errors being written to the DB table HOT 8
- Unit-Testing doesn't seem to work HOT 2
- Some fatal/syntax errors do not log HOT 9
- use datetime instead of timestamp HOT 1
- Deprecated errors HOT 2
- Fatal error on logging with uploads HOT 7
- Add summary field for paginated filter backend
- Missing Controller Error HOT 4
- Cake 4.3 Routing deprecation HOT 1
- New release HOT 2
- Three debug messages are produced by the plugin tests HOT 1
- Bad Gateway HOT 2
- working with AuthComponent HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cakephp-databaselog.