Raul Posted May 27, 2013 Share Posted May 27, 2013 Hi all, Today I would want to translate my admin area into other language and I have downloaded the last language pack. But I don't have the last version of PW and thereby I don't have all files of the pack. What is the result: a lot of warnings because the parser try to parse non-existent files. A simple solution could be made in the file "LanguageParser.php" to the function: /** * Begin parsing * */ protected function execute($file) { if (!file_exists( $file )) return; <== this line avoid parsing non-existent files. Regards, Thanks Raul Link to comment Share on other sites More sharing options...
ryan Posted June 1, 2013 Share Posted June 1, 2013 I'm just wondering if suppressing the warnings here is a good idea because this is an error condition that should probably be reported? The !is_file($file) return; is already in the parseFile() function that execute() calls, but that one isn't geared towards error suppression. I'm not sure I totally understand the conditions you ran into or why the errors should be suppressed here, but maybe a screenshot (or even pasting in the warnings) would clarify? Link to comment Share on other sites More sharing options...
Raul Posted June 1, 2013 Author Share Posted June 1, 2013 Hi Ryan, The message was: Warning: file_get_contents(/var/www/radeberger/wire/core/Password.php) [function.file-get-contents]: failed to open stream: File or directory doesn't exists in /var/www/radeberger/wire/modules/LanguageSupport/LanguageParser.php on line 125 I'm sorry. I have wrote this before the update to PW2.3. Now it's fixed. However I think always that the best is to stop the execution as soon as possible. Thereby: 1.- If a file doesn't exists, it is not necessary to call the parse function. It is not necessary to return an empty array too...Why? 2.- Calling a function suposes always resources to allocate. 3.- Moreover, a loop is executed altough an empty array is returned.. Why? Yes, the loop has few elements but it's a loop....it has always a cost. I don't want suppress errors. Error messages are good, but they can be logged instead of printed. You can print a message to advice about them if they have not solution or are important to the execution. In this case (parsing files) are the errors or warnings unnecessary, because they don't interrupt the execution and don't cause malfunction. They can be avoided easily and logged silently. For these reasons, It would be better to put the line before calling the funcion "parseFile". Thank you very much for your reply. Raul Link to comment Share on other sites More sharing options...
apeisa Posted June 1, 2013 Share Posted June 1, 2013 What is the result: a lot of warnings because the parser try to parse non-existent files. Raul, is there any steps that we could take to reproduce these? I have played a lot with translations and I have never seen anything like that. PW does have good error logging already, never outputs error messages on wild (unless you are superuser or in debug mode), so I don't fully understand what you are describing with error logging vs. printing. Link to comment Share on other sites More sharing options...
Raul Posted June 1, 2013 Author Share Posted June 1, 2013 Hi Apeisa, The only way I know is to have a PW2.2.9 and the last german language pack. Latera I have updated PW and all works correctly. About the errors, you are right. I'm always in debug mode and thereby I have seen this errors. Also, I'm sorry if i have confused someone. Thank you for your responses. Raul Link to comment Share on other sites More sharing options...
Soma Posted June 1, 2013 Share Posted June 1, 2013 And they're not errors but warnings. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now