wielebenwir / commonsbooking

CommonsBooking is an open source Wordpress plugin for sharing items with users. This is the NEW CommonsBooking (starting at version v2.0.0). Please install plugin via Wordpress plugin directory.
https://commonsbooking.org
GNU General Public License v2.0
47 stars 15 forks source link

Fix the autoloader to enable local development #1656

Open datengraben opened 3 days ago

datengraben commented 3 days ago

This PR fixes #1200 (the composer autoloader issue) and enables the following:

Problem

The ed-itsolutions/cmb2-field-ajax-search dependency registers itself in the autoloader.files directive very early. See: https://github.com/Ed-ITSolutions/cmb2-field-ajax-search/blob/18f11794eef0ac638041192f25311580f68ef90a/composer.json#L16

But it has no own autoloader or bootstrapping files, so it won't load wordpress definitions on its own.

So the plugin file depends on wordpress definitions do_action etc., which are not loaded at this moment. https://github.com/Ed-ITSolutions/cmb2-field-ajax-search/blob/18f11794eef0ac638041192f25311580f68ef90a/cmb2-field-ajax-search.php#L24

Because of this, the autoloading process of commonsbooking fails, but the autoload of any other plugin, that depends on it will fail too.

Solution

Since it seems to be no good style and also breaking the autoloader of other wordpress plugins (I testet it), I forked the 4 years inactivate cmb2-ajax-search module and removed the autoloader from our composer json (https://github.com/datengraben/cmb2-field-ajax-search/commit/887470a5cb9363a51d573bb8d49259435f519511) , added a require_once to our plugin initialization file (https://github.com/wielebenwir/commonsbooking/pull/1656/commits/46dea14bd057ccc517f0b85f107d7c7b38a32f4f).

codecov[bot] commented 2 days ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 50.41%. Comparing base (665d7e9) to head (2dc6429).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1656 +/- ## ========================================= Coverage 50.41% 50.41% Complexity 2719 2719 ========================================= Files 99 99 Lines 11296 11296 ========================================= Hits 5695 5695 Misses 5601 5601 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

datengraben commented 2 days ago

@hansmorb ok jetzt habe ich doch eine Lösung gefunden. Ich habe es aber noch nicht bei uns im Staging getestet.