Quote:The biggest problem was that the 500 errors were not logged anywhereWell, this certainly is not a Zenphoto issue--if you get a 500 error Zenphoto never even gets loaded.
Quote:BUT YOU HAD AN @-SIGN IN FRONT OF THE mysqli_connect CALL, SO IT NEVER REPORTED THE ERROR ANYWHERE!!!And if we did not, you would not be able to run setup at all.
Quote:Because I don't have the mysqli extension installed on my system. I'm running on netbsd, using pkgsrc, and it isn't installed by default with php, and I'd never needed it before now.Since apparently you set thing up yourself, you should at least do it correctly.
Quote:I would suggest you get off your high horse and appologize to us for your tirade.Yes, you are right; I had no business yelling. You are providing software for free, and I'm complaining that it isn't what I wanted, and blaming you for that. I apologize.
Quote:Well, this certainly is not a Zenphoto issue--if you get a 500 error Zenphoto never even gets loaded.Not so. The 500 error basically just indicates "php crashed". That can happen because of a parse error - before Zenphoto is loaded - or because of an unchecked call to a function that doesn't exist (as in my case) well into Zenphoto's execution. It was exactly that thing that was happening to me, and that's why I was able to put "GOT HERE" messages in the code to figure out where it was breaking - as long as there was output, apache was still returning it to the browser, before the error. Once I moved the "GOT HERE" to after the offending line, the browser just saw the 500 error.
Quote:And if we did not, you would not be able to run setup at all.No so; php provides one or more ways to guard against any possible error; the @-sign is just a programmer convenience so that you don't have to write the code to guard against the error you were worried about. The problem is that it also guards against all other errors, even ones that prevent further script execution (like a function that isn't available), even if you weren't expecting that - and it does it in a way where the error is never logged. So basically, every bug you have, and every local configuration issue your users have, in a line of code with an @-sign, becomes a nightmare to debug in production.
Quote:If you did not have the MySQLi PHP module enabled Zenphoto would not use that library. If you have the PHP module but not the underlying support then you certainly cannot blame Zenphoto. If someone manually edited the configureation file to use that module it is again not Zenphoto's fault.Not so. Zenphoto does not check whether mysqli is available on the machine; it just blindly trusts the config file and tries to call mysqli_connect which doesn't exist so it throws an error. The @-sign makes php eat all error logging about that error, but the script dies at that point anyway.
Quote:Since apparently you set thing up yourself, you should at least do it correctly.I had a perfectly-reasonable configuration of php (without mysqli) - the PHP documentation is explicit that mysqli is optional, and even that it might have to be explicitly added if you want it. My reasonable configuration combined with your (unsafe) assumption that mysqli would be present to cause a script failure, and the @-sign caused the failure to be totally unlogged. If that @-sign hadn't been there, I would have had a perfectly-understandable log message that would have led me to configure mysqli, easily.
Quote:WarningOf course the configuration is possible and therefore we should properly run under it. That is now the case. We certainly could have got to this point sooner if your posting was constructive rather than distructive.
This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include:
? mysqli_connect()
? PDO:GDN__construct()
Quote:While Zenphoto may cause a crash, there is still no means for it to log the error as PHP is aborted on a 500 error.Not so; if you remove the @-sign from the example I gave above, the error will be logged in the php logs (if you have them configured). The user still sees a 500 error.
Quote:It is not the @ sign that is the issue anyway. That is a normal and accepted means to supress error messages that are expected. In the case of the database connection, that will occur if the credentials are not correct.That's exactly my point - you are using the @-sign to suppress the error you expect, but you are also suppressing all other errors from that line of code, which is why it's so dangerous. If there is an error that you weren't expecting (and you can't claim to never have those) then it won't be handled, reported, or logged. That's the worst possible way to handle an unexpected error.
Quote:Not supressing the error means that the user has no means to correct (or supply) the credentials.No so; there are multiple other ways to deal with the error - try/catch, set_exception_handler(), and set_error_handler(). (I believe try/catch is perfectly suited to this situation, but I haven't tested it.) All of them will allow you to deal with the issue and/or will log the issue.
Quote:There are similar reasons for the other uses of the @ sign. It may be that other expected modules get left out of PHP configurations. That is not normal and not done by the professional hosting sites. If someone wishes to configure his PHP in a custom way he is expected to be able to deal with the consequences. We certainly cannot test all the possible PHP configuration permutations and may well miss the fact that a particular function might be in a commonly included module but omitted in a particular case for some unknown reason.That's exactly why you shouldn't use the @-sign: you can't test all the possible configurations, and the @-sign makes it nearly-impossible to identify issues that result from those configuration differences. Is your argument that people should only use this software if they're running on one of the standard hosting sites?
Quote:As to your "perfectly reasonable PHP configuration" you should note what the PHP documents themselves say: [snip]I'm using PHP 5.3, which is described as supported by Zenphoto. (I tried upgrading to 5.4, but that cascades into other dependencies that I'm not ready to upgrade yet.) At the time of 5.3, it was perfectly reasonable to run without mysqli. (And note that 5.5 isn't officially released, yet!)
Quote:Of course the configuration is possible and therefore we should properly run under it. That is now the case.Great! Thank you very much.
Quote:We certainly could have got to this point sooner if your posting was constructive rather than distructive.Yes, probably, and I'm sincerely sorry about that. I do still think that the larger issue is important, though - the @-signs are dangerous, and they're going to cause major headaches for other people in the future. (And they were probably the source of many headaches in the past.) They make the software less debuggable in the field, and I suggest you stop using them, and make an effort to remove them where they already exist.
Quote:That's exactly my point - you are using the @-sign to suppress the error you expect, but you are also suppressing all other errors from that line of code, which is why it's so dangerous. If there is an error that you weren't expecting (and you can't claim to never have those) then it won't be handled, reported, or logged. That's the worst possible way to handle an unexpected error.So we are here between the devil and the deep blue sea. We must be able to supress "expected" errors or Zenphoto will not work. But if there are "unexpected" errors they should not be supressed. Unfortunately, there is only one option, supress all errors or not. Maybe that is a PHP weakness, but it is one we have to live with.
Quote:'m using PHP 5.3, which is described as supported by Zenphoto. (I tried upgrading to 5.4, but that cascades into other dependencies that I'm not ready to upgrade yet.) At the time of 5.3, it was perfectly reasonable to run without mysqli. (And note that 5.5 isn't officially released, yet!)Of course MySQL is still available in your PHP 5.3, but that is actually not the point. Since it will be removed (and is not recommended in the first place) all reasonable software will move off using MySQL to using MySQLi. But you will prevent those from running on your configuration since you CHOOSE to run an obsolete configuration.
Quote:For instance, instead of testing the existence of every function you call at every invocation (which I agree would be "Pudgy"), do it in standalone test code. Then you can instruct users to run the tests before installation and also later on, if the software ever starts misbehaving.Your are kidding, right. Either that or you are terribly naieve. Do you know what your entire vocabulary is? Do you "test" to see if everyone can understand these words before you speak? No, you do not. One makes reasonable assumptions about the world out there and goes on them. Anything else would result in paralysis by analysis.
Quote:I can think of some ways to automate that, and were it my code, that's a development cost I'd gladly pay in exchange for the "Zen" of quickly and reliably characterizing problems in the field. But it's your code and your tradeoff.I take it you are volunteering to do this? We would be happy to have your addition.