Closed ddrury closed 4 years ago
Do you have a stack-dump for the two calls to __construct()
?
From where are they being called?
They're both exactly the same
Trying to get property 'title' of non-object …/app/Module/MapProviderModule.php:50 #0 …/app/Module/MapProviderModule.php(50): Fisharebest\Webtrees\Webtrees::Fisharebest\Webtrees\{closure}(8, 'Trying to get p...', '/mnt/d/Server/h...', 50, Array) #1 [internal function]: Fisharebest\Webtrees\Module\MapProviderModule->__construct() #2 …/vendor/illuminate/container/Container.php(825): ReflectionClass->newInstanceArgs(Array) #3 …/vendor/illuminate/container/Container.php(667): Illuminate\Container\Container->build('Fisharebest\\Web...') #4 …/vendor/illuminate/container/Container.php(615): Illuminate\Container\Container->resolve('Fisharebest\\Web...', Array) #5 …/app/Helpers/functions.php(45): Illuminate\Container\Container->make('Fisharebest\\Web...') #6 …/app/Services/ModuleService.php(590): app('Fisharebest\\Web...') #7 [internal function]: Fisharebest\Webtrees\Services\ModuleService::Fisharebest\Webtrees\Services\{closure}('Fisharebest\\Web...', 'map-provider') #8 …/vendor/illuminate/support/Collection.php(1120): array_map(Object(Closure), Array, Array) #9 …/app/Services/ModuleService.php(595): Illuminate\Support\Collection->map(Object(Closure)) #10 …/app/Services/ModuleService.php(544): Fisharebest\Webtrees\Services\ModuleService->coreModules() #11 …/app/Cache.php(59): Fisharebest\Webtrees\Services\ModuleService->Fisharebest\Webtrees\Services\{closure}() #12 …/vendor/symfony/cache/Adapter/ArrayAdapter.php(62): Fisharebest\Webtrees\Cache::Fisharebest\Webtrees\{closure}(Object(Symfony\Component\Cache\CacheItem), true) #13 …/app/Cache.php(60): Symfony\Component\Cache\Adapter\ArrayAdapter->get('372b64b23390f9d...', Object(Closure)) #14 …/app/Services/ModuleService.php(578): Fisharebest\Webtrees\Cache->remember('all-modules', Object(Closure)) #15 …/app/Services/ModuleService.php(501): Fisharebest\Webtrees\Services\ModuleService->all(false) #16 …/app/Http/Middleware/UseLanguage.php(88): Fisharebest\Webtrees\Services\ModuleService->findByInterface('Fisharebest\\Web...') #17 …/app/Http/Middleware/UseLanguage.php(65): Fisharebest\Webtrees\Http\Middleware\UseLanguage->languages(Object(Nyholm\Psr7\ServerRequest)) #18 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseLanguage->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher)) #19 …/app/Http/Middleware/UseSession.php(73): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest)) #20 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseSession->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher)) #21 …/app/Http/Middleware/UseFilesystem.php(58): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest)) #22 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseFilesystem->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher)) #23 …/app/Http/Middleware/UpdateDatabaseSchema.php(58): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest)) #24 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UpdateDatabaseSchema->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher)) #25 …/app/Http/Middleware/UseDebugbar.php(67): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest)) #26 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseDebugbar->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher)) #27 …/app/Http/Middleware/UseDatabase.php(106): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest)) #28 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseDatabase->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher)) #29 …/app/Http/Middleware/BadBotBlocker.php(194): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest)) #30 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\BadBotBlocker->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher)) #31 …/app/Http/Middleware/UseCache.php(74): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest)) #32 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseCache->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher)) #33 …/vendor/middlewares/client-ip/src/ClientIp.php(81): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest)) #34 …/app/Http/Middleware/ClientIp.php(47): Middlewares\ClientIp->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher)) #35 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\ClientIp->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher)) #36 …/app/Http/Middleware/HandleExceptions.php(76): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest)) #37 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\HandleExceptions->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher)) #38 …/app/Http/Middleware/BaseUrl.php(77): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest)) #39 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\BaseUrl->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher)) #40 …/app/Http/Middleware/ReadConfigIni.php(65): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest)) #41 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\ReadConfigIni->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher)) #42 …/app/Http/Middleware/SecurityHeaders.php(47): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest)) #43 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\SecurityHeaders->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher)) #44 …/app/Http/Middleware/EmitResponse.php(57): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest)) #45 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\EmitResponse->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher)) #46 …/app/Http/Middleware/PhpEnvironment.php(49): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest)) #47 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\PhpEnvironment->process(Object(Nyholm\Psr7\ServerRequest), Object(Middleland\Dispatcher)) #48 …/vendor/oscarotero/middleland/src/Dispatcher.php(118): Middleland\Dispatcher->handle(Object(Nyholm\Psr7\ServerRequest)) #49 …/index.php(55): Middleland\Dispatcher->dispatch(Object(Nyholm\Psr7\ServerRequest)) #50 {main}
Are you sure it is being called twice in the same script?
e.g. if this is a chart, it will be called twice in two separate requests - once on the parent page, and once to generate the actual chart.
Are you sure it is being called twice in the same script?
Not sure! If I sit on the Website logs page, delete the errors and refresh the page, I get the same two errors back.
Can you post the source to the module so I can try to reproduce it?
Emailed
BTW, I changed __construct() to boot() as there was no point in initialising data if the module is disabled, but it made no change to the problem
A simple way to check this. Using the master branch I added a __construct function to the custom css & js module
public function __construct()
{
Log::addErrorLog('testing');
}
I see the same outcome with this
Not sure! If I sit on the Website logs page, delete the errors and refresh the page, I get the same two errors back.
The logs page makes 2 requests. One for the page, and one for the table contents. Thus refreshing the logs page would make two requests.
Try this code. You'll see that every log is for testing-1
.
If the constructor was called twice, you'd see testing-2
as well.
static $n = 0;
$n++;
Log::addErrorLog('testing-' . $n);
So, what's the best way to avoid repeated log entries in this situation
There are two logs because there are two separate HTTP requests - and each one loads the modules.
So, what's the best way to avoid repeated log entries in this situation
If two separate processes each create a log entry, you will have two log entries.
Not sure there is any alternative...
With a recently created module, I added a __contruct function to initialise some data; to test the format of the data I deliberately created some that was badly formatted, when I check the error log I see two entries each time.
It seems that __construct is being run twice. Is this deliberate?