Closed cdekok closed 9 years ago
@Mech7 Thank you Chris, this is an excellent addition!
However, I get errors when testing this. The authenticate() call to Application fails because the error logger already put out some warnings:
Installing dependencies (including require-dev)
...
WARNING: JRequest is deprecated. [deprecated]
WARNING: JDatabase::getErrorNum() is deprecated, use exception handling instead. [deprecated]
DEBUG: SELECT `data`
FROM `j_session`
WHERE `session_id` = '36bb1818427e4973dc89a2d8e2c34b0c' [databasequery]
[ErrorException]
session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/joomla25/libraries/joomla/log/loggers/echo.php:48)
We'll have to find a way to fix this first.
Hi @stevenrombauts on which joomla version did you get this error? I tried it with 3.4 and it worked for me, i did get 2 warning notices about deprecated methods for getFile and another method, but i believe they came from the joomla cms installer code wanted to look at that a later time.
This is on 2.5 actually, have not tested on 3.2 and up yet.
Ah it will probably be an error in 2.5 joomla code, not sure if there is workaround except by fixing the joomla code :(
@stevenrombauts I have raised the log level and limited the category, it looks like Jinstaller only logs to a jerror category so there shouldn't be any output now with deprecated methods which log to a deprecated category and caused the session to fail.
Thanks again. I don't think we can solve this by picking another log level, as it only masks the issue.
We were thinking about moving this into a separate config flag maybe? That would mean no logging by default. If you want to debug, you can enable it by adding a debug: loglevel setting to your composer.json file.
Same way we do with setting a different user as explained here. That config is always available through $composer->getConfig().
I'll make the changes so we can try it out. Love to hear your thoughts on this.
Yeah i guess we can try that, but one thing the deprecated warnings all come from the joomla core do we really care about that when installing a component? Also if we don't hide it should we really care about joomla 2.5 it's already end of life and not officially supported by joomla itself.
You're right about joomla 2.5 being phased out, it might not be worth the trouble. However, if you've enabled debugging you would expect to see everything. If you only raise the log level for the installation method you might be withholding important clues.
I played around with it a bit more and the solution is actually very obvious. Echo outputs to php://output but we want to output to STDOUT since we're just talking to the console.
If we output everything to php://stdout it won't end up in the output buffers, and session_start() has no more reason to complain. So I just added a custom logger that streams to STDOUT instead of using echo. (see this commit and this commit)
I've also removed the need for an extra configuration setting by adapting Composer's verbosity setting. (look in the output of composer list
for verbosity) There are three available flags: -v
for verbosity, -vv
for extra verbosity or -vvv
for debug. Based on that I'm setting the Joomla logger priorities too, see this code
Let me know if that works for you too! I've tested this on 2.5, 3.3 and 3.4. Thanks again :-)
That looks pretty nice :+1: perhaps will be even better if it logs everything except info level to STDERR and info to STDOUT
@Mech7 Good point, stderr makes more sense. I've merged these changes and tagged a new version. You should get v1.0.4 of the installer via Composer and that will include your changes.
Thanks a lot for your contribution and advice! Greatly appreciated.
When there is an error in the installer joomla simply logs it, by adding the echo logger you see the output in the terminal example: