The function apl_load_apache2_lmodule, which is meant to load the apache2 library is flawed in that it loads the library into the package.loaded table and sets this as the global "apache2". It should load it into a new table, and set this as the global "apache2" and package.loaded.apache2. What follows is a small test script which shows this (all tests _should_ pass, but most of the apache2 ones do not). Also attached is a patch which fixes this.
---- begin code sample ----
function handle(req)
local function assert(test)
local status = loadstring('return '.. test)()
req:write(test ..': '.. (status and "pass" or "FAIL") ..'\n')
end
-- control tests
assert [[string == require "string"]]
assert "package.loaded.math == math"
-- apache2 tests
assert [[apache2 == require "apache2"]]
assert "package.loaded.apache2 == apache2"
assert "package.loaded ~= apache2"
assert "apache2.apache2 == nil"
assert "apache2.OK ~= nil"
assert "package.loaded.apache2.OK ~= nil"
end
---- end code sample ----
package_loaded_apache2.patch
Description: Binary data
