mojolicious / mojo

:sparkles: Mojolicious - Perl real-time web framework
https://mojolicious.org
Artistic License 2.0
2.66k stars 576 forks source link

use do rather than require to load a mojo application #2097

Closed haarg closed 10 months ago

haarg commented 10 months ago

Summary

Use do rather than require to load a mojo application to fix compatibility with new module_true core feature.

Motivation

The return value of require is usually not a reasonable thing to rely on, aside from it being true. The first time requiring a file, it will return the value of the last statement in the file. The second time requiring a file, it will return a simple true value.

Mojo was bypassing this problem by deleting the %INC entry for the file, forcing it to always be loaded again. But the new module_true core feature will cause require to always return a simple true value rather than the last statement in the file. This does not apply to do though.

References

2094

kraih commented 9 months ago

There is a report that this might have caused a regression: #2109, #2110