You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because $modx->getVersionData() uses include_once() and returns that result, it will return true if called more than once. This doesn't happen in normal MODX operations because the include only executes if $modx->version === null.
In unit, integration, and acceptance tests, there are cases where MODX is instantiated, and the version is checked in more than one test. Because the tests are run in the same PHP scope, it appears that PHP knows the file was included, but $modx->version is null.
In those cases, the include returns true, so getVersionData()['version'] becomes 1['version'], and throws a PHP error (which goes unreported because of the @ sign). This causes problems that are very difficult to track down.
A workaround is to include the version file directly without calling the function, but I can't think of any reason include_once couldn't be replaced by just include. In normal MODX operation, the include will only happen once anyway, and including the version file a second time is completely harmless. It will return the same value each time, and the difference between the time to include the file and the time to check to see if it's already been included is probably trivial.
Bug report
Summary
Because
$modx->getVersionData()
usesinclude_once()
and returns that result, it will returntrue
if called more than once. This doesn't happen in normal MODX operations because the include only executes if$modx->version === null
.In unit, integration, and acceptance tests, there are cases where MODX is instantiated, and the version is checked in more than one test. Because the tests are run in the same PHP scope, it appears that PHP knows the file was included, but
$modx->version
isnull
.In those cases, the include returns
true
, sogetVersionData()['version']
becomes1['version']
, and throws a PHP error (which goes unreported because of the @ sign). This causes problems that are very difficult to track down.A workaround is to include the version file directly without calling the function, but I can't think of any reason
include_once
couldn't be replaced by justinclude
. In normal MODX operation, the include will only happen once anyway, and including the version file a second time is completely harmless. It will return the same value each time, and the difference between the time to include the file and the time to check to see if it's already been included is probably trivial.Step to reproduce
Observed behavior
Result:
Expected behavior
Return values should be the same
The text was updated successfully, but these errors were encountered: