Question Custom module errors with webtrees 2.2.0: Call to undefined function app/make
- Jefferson49
- Topic Author
- Offline
- Senior Member
- Call to undefined function Jefferson49\Webtrees\Module\ExtendedImportExport\app()
- Call to undefined method Fisharebest\Webtrees\Webtrees::make()
ExtendedImportExport, FancyResearchLinks, FancyTreeview, RepositoryHierarchy, webtrees-branch-statistics:
Fatal error in module: extended_import_export
Error: Call to undefined function Jefferson49\Webtrees\Module\ExtendedImportExport\app() in C:\wamp64\www\webtrees\modules_v4\extended_import_export\DownloadGedcomWithURL.php:221 Stack trace: #0 C:\wamp64\www\webtrees\modules_v4\extended_import_export\module.php(57): Jefferson49\Webtrees\Module\ExtendedImportExport\DownloadGedcomWithURL->__construct() #1 C:\wamp64\www\webtrees\app\Services\ModuleService.php(722): include('C:\\wamp64\\www\\w...') #2 C:\wamp64\www\webtrees\app\Services\ModuleService.php(702): Fisharebest\Webtrees\Services\ModuleService::load('C:\\wamp64\\www\\w...') #3 [internal function]: Fisharebest\Webtrees\Services\ModuleService::Fisharebest\Webtrees\Services\{closure}('C:\\wamp64\\www\\w...', 1)
GV Export:
Fatal error in module: GVExport
Error: Call to undefined method Fisharebest\Webtrees\Webtrees::make() in C:\wamp64\www\webtrees\modules_v4\GVExport\module.php:414 Stack trace: #0 C:\wamp64\www\webtrees\app\Services\ModuleService.php(722): include() #1 C:\wamp64\www\webtrees\app\Services\ModuleService.php(702): Fisharebest\Webtrees\Services\ModuleService::load('C:\\wamp64\\www\\w...') #2 [internal function]: Fisharebest\Webtrees\Services\ModuleService::Fisharebest\Webtrees\Services\{closure}('C:\\wamp64\\www\\w...', 2)
Does webtrees 2.2 include some changes in the custom module API, which need to be adopted? Or is it a bug?
Please Log in or Create an account to join the conversation.
- fisharebest
- Away
- Administrator
webtrees uses a number of libraries and conventions from the Laravel framework. One of these is that the function app() is used to access the dependency-injection container.
i.e. if you want to create an object of type Foo, you would previously have used app(Foo::class).
Firstly, this has issues with testing, and secondly it is considered bad practice to create functions in the global namespace.
So, in 2.2, the container is accessed via a "service-locator/registry" system.
In short,
app(Foo::class) becomes Registery::container()->get(Foo::class)
Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net
Please Log in or Create an account to join the conversation.
- Jefferson49
- Topic Author
- Offline
- Senior Member
Thank you Greg for the fast explanation. I agree that it is easy to change. It took only some minutes to fix it in my modules. However, it seems to work only in 2.2. To be still compatible with 2.1., it seems that the webtrees version needs to be checked.So, in 2.2, the container is accessed via a "service-locator/registry" system.
In short,
app(Foo::class) becomes Registery::container()->get(Foo::class)
Is this the right way to go?
Please Log in or Create an account to join the conversation.
- kiwi
- Offline
- Platinum Member
So perhaps better to create a “2.2 compatible “ version and leave the 2.1 version alone?
Nigel
www.our-families.info
Please Log in or Create an account to join the conversation.
- ric2015
- Offline
- Senior Member
2.2 also requires a minimum version of php (8.3).
So perhaps better to create a “2.2 compatible “ version and leave the 2.1 version alone?
When adjusting the Vesta modules for webtrees 2.2, I didn't encounter any backwards-incompatible php issues, so apart from the issue mentioned by Jefferson49 it's not too problematic to create a custom module release that works with both 2.1.21 and 2.2 (and php 8.2 - 8.4).
I ended up putting all calls to the container (including that version check) into separate helper methods (webtrees itself had those helper methods in 2.1.x: app/Webtrees::make() and app/Webtrees::set() - it would have been very helpful for custom modules if those had been kept at least in initial 2.2 releases as deprecated methods).
Richard
webtrees 2.2.0 at cissee.de/webtrees2
Vesta custom modules (Classic Look & Feel, Gov4webtrees, Shared Places, Extended Relationships) available at cissee.de
Please Log in or Create an account to join the conversation.
- RickM
- Offline
- Junior Member
Are you saying that Vesta Modules are compatible with WebTrees 2.2.0??
I get errors similar to attached image for all Vesta Modules and they DO NOT show up in the Control Panel >> Other or >> All Modules
Rick M
Tauranga
New Zealand - Nu Tirani
alineofmalkins.com/wt-malkins
Webtrees v2.2.1
Hosted by HostAmarada on litespeed Server, PHP v8.3
Please Log in or Create an account to join the conversation.
- ric2015
- Offline
- Senior Member
Richard
Are you saying that Vesta Modules are compatible with WebTrees 2.2.0??
I get errors similar to attached image for all Vesta Modules
Yes, the latest Vesta version (released yesterday) is compatible - In general, you can always determine this by checking the Readme files on github (or see the version number). As usual, the previous Vesta releases 2.1.20.x are not compatible with a higher webtrees version (normally the modules would just be made inactive internally in such a case, but this particular change in webtrees prevents this and causes the error message).
Richard
webtrees 2.2.0 at cissee.de/webtrees2
Vesta custom modules (Classic Look & Feel, Gov4webtrees, Shared Places, Extended Relationships) available at cissee.de
Please Log in or Create an account to join the conversation.
- Mperates
- Offline
- New Member
- Posts: 48
See the releases section on github to grab the latest releases.
Please Log in or Create an account to join the conversation.
- maalik
- Offline
- New Member
- Posts: 22
Is this something we can fix by ourself? Where does the Code need to be changed? Only a few files or a lot?
Please Log in or Create an account to join the conversation.
- maalik
- Offline
- New Member
- Posts: 22
Watch out for trailing semicolon, in very few cases there is none (e.g. jc-fancy-treeview/FancyTreeviewModule.php line 1872.)
You also have to add
Please Log in or Create an account to join the conversation.
- jcnventura
- Offline
- New Member
João Ventura - venturas.org/familytree
Please Log in or Create an account to join the conversation.
- Jefferson49
- Topic Author
- Offline
- Senior Member
- Extended Import/Export (Advanced GEDCOM import, export, and filter operations. Also supports remote downloads/uploads via URL requests)
- Repository Hierarchy (... to present the structure of a repository and its sources in a hierarchical manner; also including advanced features to improve the handling of source citations)
- Change Language with URL (... to change the webtrees language by URL requests with the language provided as an URL parameter)
- My Custom Tags (... to provide custom tags, custom types, custom relationship descriptors, and custom roles in events)
The latest versions of the custom modules can be used in both, webtrees 2.1 and 2.2
Please Log in or Create an account to join the conversation.
- miqrogroove
- Offline
- New Member
- Posts: 94
Please Log in or Create an account to join the conversation.
- UksusoFF
- Offline
- Junior Member
Please Log in or Create an account to join the conversation.
- Didier
- Offline
- New Member
Okay. but I can't find the file(s) in which app(Foo::class) would be.
Can you tell me their path? (forgive my lack of skills). Thanks in advance
Please Log in or Create an account to join the conversation.
- maalik
- Offline
- New Member
- Posts: 22
You have to replace "Foo" with the corresponding variable.
Please Log in or Create an account to join the conversation.
- Didier
- Offline
- New Member
Please Log in or Create an account to join the conversation.
- miqrogroove
- Offline
- New Member
- Posts: 94
Please Log in or Create an account to join the conversation.
- maalik
- Offline
- New Member
- Posts: 22
Please Log in or Create an account to join the conversation.
- maalik
- Offline
- New Member
- Posts: 22
So if there is e.g.
Please Log in or Create an account to join the conversation.