Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s9y current master: language constants already defined #798

Open
bauigel opened this issue Dec 4, 2022 · 15 comments
Open

s9y current master: language constants already defined #798

bauigel opened this issue Dec 4, 2022 · 15 comments
Labels

Comments

@bauigel
Copy link

bauigel commented Dec 4, 2022

With current master (4.12.2022) I get a lot of errors and warnings and the webpage doesn't run. Following you will find the debug log.

== ERROR-REPORT (DEBUGGING ENABLED) == 
== (When you copy this debug output to a forum or other places, make sure to remove your username/passwords, as they may be contained within function calls) ==
#0  errorToExceptionHandler(2, Constant LANG_CHARSET already defined, /var/www/virtual/bauigel/bernd.distler.ws/lang/UTF-8/serendipity_lang_en.inc.php, 6) called at [/var/www/virtual/bauigel/bernd.distler.ws/lang/UTF-8/serendipity_lang_en.inc.php:6]
#1  include_once(/var/www/virtual/bauigel/bernd.distler.ws/lang/UTF-8/serendipity_lang_en.inc.php) called at [/var/www/virtual/bauigel/bernd.distler.ws/include/lang.inc.php:48]
#2  include(/var/www/virtual/bauigel/bernd.distler.ws/include/lang.inc.php) called at [/var/www/virtual/bauigel/bernd.distler.ws/serendipity_config.inc.php:411]
#3  include(/var/www/virtual/bauigel/bernd.distler.ws/serendipity_config.inc.php) called at [/var/www/virtual/bauigel/bernd.distler.ws/index.php:12]
Warning: Constant LANG_CHARSET already defined in /var/www/virtual/bauigel/bernd.distler.ws/lang/UTF-8/serendipity_lang_en.inc.php on line 6.


Fatal error: Uncaught ErrorException: Warning: Constant LANG_CHARSET already defined in /var/www/virtual/bauigel/bernd.distler.ws/lang/UTF-8/serendipity_lang_en.inc.php:6 Stack trace: #0 /var/www/virtual/bauigel/bernd.distler.ws/lang/UTF-8/serendipity_lang_en.inc.php(6): errorToExceptionHandler(2, 'Constant LANG_C...', '/var/www/virtua...', 6) #1 /var/www/virtual/bauigel/bernd.distler.ws/include/lang.inc.php(48): include_once('/var/www/virtua...') #2 /var/www/virtual/bauigel/bernd.distler.ws/serendipity_config.inc.php(411): include('/var/www/virtua...') #3 /var/www/virtual/bauigel/bernd.distler.ws/index.php(12): include('/var/www/virtua...') #4 {main} thrown in /var/www/virtual/bauigel/bernd.distler.ws/lang/UTF-8/serendipity_lang_en.inc.php on line 6
== ERROR-REPORT (DEBUGGING ENABLED) == 
== (When you copy this debug output to a forum or other places, make sure to remove your username/passwords, as they may be contained within function calls) ==
#0  errorToExceptionHandler(1, Uncaught ErrorException: Warning: Constant LANG_CHARSET already defined in /var/www/virtual/bauigel/bernd.distler.ws/lang/UTF-8/serendipity_lang_en.inc.php:6
Stack trace:
#0 /var/www/virtual/bauigel/bernd.distler.ws/lang/UTF-8/serendipity_lang_en.inc.php(6): errorToExceptionHandler(2, 'Constant LANG_C...', '/var/www/virtua...', 6)
#1 /var/www/virtual/bauigel/bernd.distler.ws/include/lang.inc.php(48): include_once('/var/www/virtua...')
#2 /var/www/virtual/bauigel/bernd.distler.ws/serendipity_config.inc.php(411): include('/var/www/virtua...')
#3 /var/www/virtual/bauigel/bernd.distler.ws/index.php(12): include('/var/www/virtua...')
#4 {main}
  thrown, /var/www/virtual/bauigel/bernd.distler.ws/lang/UTF-8/serendipity_lang_en.inc.php, 6) called at [/var/www/virtual/bauigel/bernd.distler.ws/include/compat.inc.php:233]
#1  fatalErrorShutdownHandler()
Fatal Error: Uncaught ErrorException: Warning: Constant LANG_CHARSET already defined in /var/www/virtual/bauigel/bernd.distler.ws/lang/UTF-8/serendipity_lang_en.inc.php:6 Stack trace: #0 /var/www/virtual/bauigel/bernd.distler.ws/lang/UTF-8/serendipity_lang_en.inc.php(6): errorToExceptionHandler(2, 'Constant LANG_C...', '/var/www/virtua...', 6) #1 /var/www/virtual/bauigel/bernd.distler.ws/include/lang.inc.php(48): include_once('/var/www/virtua...') #2 /var/www/virtual/bauigel/bernd.distler.ws/serendipity_config.inc.php(411): include('/var/www/virtua...') #3 /var/www/virtual/bauigel/bernd.distler.ws/index.php(12): include('/var/www/virtua...') #4 {main} thrown in /var/www/virtual/bauigel/bernd.distler.ws/lang/UTF-8/serendipity_lang_en.inc.php on line 6.


Fatal error: Uncaught ErrorException: Fatal Error: Uncaught ErrorException: Warning: Constant LANG_CHARSET already defined in /var/www/virtual/bauigel/bernd.distler.ws/lang/UTF-8/serendipity_lang_en.inc.php:6 Stack trace: #0 /var/www/virtual/bauigel/bernd.distler.ws/lang/UTF-8/serendipity_lang_en.inc.php(6): errorToExceptionHandler(2, 'Constant LANG_C...', '/var/www/virtua...', 6) #1 /var/www/virtual/bauigel/bernd.distler.ws/include/lang.inc.php(48): include_once('/var/www/virtua...') #2 /var/www/virtual/bauigel/bernd.distler.ws/serendipity_config.inc.php(411): include('/var/www/virtua...') #3 /var/www/virtual/bauigel/bernd.distler.ws/index.php(12): include('/var/www/virtua...') #4 {main} thrown in /var/www/virtual/bauigel/bernd.distler.ws/lang/UTF-8/serendipity_lang_en.inc.php:6 Stack trace: #0 /var/www/virtual/bauigel/bernd.distler.ws/include/compat.inc.php(233): errorToExceptionHandler(1, 'Uncaught ErrorE...', '/var/www/virtua...', 6) #1 [internal function]: fatalErrorShutdownHandler() #2 {main} thrown in /var/www/virtual/bauigel/bernd.distler.ws/lang/UTF-8/serendipity_lang_en.inc.php on line 6
@onli
Copy link
Member

onli commented Dec 4, 2022

@fe-hicking Could this be related to the upgrader fixes?

@onli onli added the bugs label Dec 4, 2022
@fe-hicking
Copy link
Contributor

I don't see how my commits should cause this; they don't affect the normal operation?

@bauigel maybe you can roll back to master before my commits, see if that changes.

To me it looks like the language handler is the culprit; I remember it being called multiple times for fallback - maybe a check is missing for an existing constant?!

@bauigel
Copy link
Author

bauigel commented Dec 4, 2022

If I go back to 2.4.0 release everything works like a charm again. Seems the errors depends on changes in the meantime.

@bauigel
Copy link
Author

bauigel commented Dec 4, 2022

Hmm...nothing like a charm. Maybe there has been a cache shown? Now I get a 500 on start page with 2.4.0. The admin page still works.

@fe-hicking
Copy link
Contributor

2.4.0 release has no extra debugging. You might see the same error like before.

What are your language settings, especially charset related? Check serendipity_config_local.inc.php and the serendipity_config table for authorid=0....?

@garvinhicking
Copy link
Member

Could it be you're using PHP 8.1? I'm not sure s9y is compatible with PHP 8.1 yet? The lang framework uses @define in many places, I am not sure if PHP 8.1 still supports that without exceptions.

@onli Do you know something about the 8.1 compatibility?

@stevleibelt
Copy link

Could it be you're using PHP 8.1? I'm not sure s9y is compatible with PHP 8.1 yet? The lang framework uses @define in many places, I am not sure if PHP 8.1 still supports that without exceptions.

@onli Do you know something about the 8.1 compatibility?

At least from the official documentation, I don't see a deprecation for @define.

Best regards,
Stev

@garvinhicking
Copy link
Member

I just checked, a simple PHP:

error_reporting(E_ALL);
ini_set('display_errors', 'on');

define('LANG_CHARSET', 'UTF-8');
define('LANG_CHARSET', 'ISO-8859-1');

only raises a warning on PHP 8.1. I also checked with PHP 8.2RC3 and there also only a warning is issued.

And suppressing a warning with @define doesn't raise an error for me. Our errorToExceptionHandler (defined in include/compat.inc.php) actually also searches for silenced errors:

        // NOTE: We do NOT use ini_get('error_reporting'), because that would return the global error reporting,
        // and not the one in our current content. @-silenced errors would otherwise never be caught on.
        $rep  = error_reporting();

        // Bypass error processing because it's @-silenced.
        if ($rep == 0) {
            return false;
        }

So basically, the error with a

@define('LANG_CHARSET', 'XXX');

should never throw such an uncaught exception from a warning. The only way I imagine it erroring is, if the code at some point calls define('LANG_CHARSET') without silencing the error.

@bauigel Could you search your deployed code for define('LANG_CHARSET and define("LANG_CHARSET and see if that shows any results where no @ is shown? How does your serendipity_config_local.inc.php look like?

Regards,
Garvin

@onli
Copy link
Member

onli commented Dec 5, 2022

@garvinhicking

@onli Do you know something about the 8.1 compatibility?

For now I'm only aware of #784 and that in https://board.s9y.org/viewtopic.php?t=25716 commenting stopped working with PHP 8.1.

PS: I only thought the last fixes could be related because of the utf8mb4 thing, that maybe now an upgrade task works again that sets the LANG_CHARSET in some file. I had no specific code in mind though that could be responsible.

@bauigel
Copy link
Author

bauigel commented Dec 5, 2022

FYI : PHP 8.0

@bauigel Could you search your deployed code for define('LANG_CHARSET and define("LANG_CHARSET and see if that shows any results where no @ is shown? How does your serendipity_config_local.inc.php look like?

As far as I can see, every define has an @ in front.

My config:

        $serendipity['versionInstalled']  = '2.5.0-alpha1';
        $serendipity['dbName']            = 'bauigel_...';
        $serendipity['dbPrefix']          = 'serendipity_';
        $serendipity['dbHost']            = 'localhost';
        $serendipity['dbUser']            = '...';
        $serendipity['dbPass']            = '...';
        $serendipity['dbType']            = 'mysqli';
        $serendipity['dbPersistent']      = false;
        $serendipity['dbCharset']         = 'utf8mb4';

@bauigel
Copy link
Author

bauigel commented Dec 5, 2022

Funny. In my backend I get another error message...

Die Javascript-Bibliothek von Serendipity konnte nicht geladen werden. Das kann aufgrund von PHP- oder Pluginfehlern, eventuell auch aufgrund eines zerstörten Browsercaches vorkommen. Um die genaue Fehlermeldung zu sehen, öffnen Sie bitte https://bernd.distler.ws/index.php?/plugin/admin/serendipity_editor.js von Hand im Browser und suchen nach Fehlermeldungen.

@bauigel
Copy link
Author

bauigel commented Dec 5, 2022

To be sure, my installation is not broken, I switched back to php 7.4 and everything works fine. Seems to be an php 8 issue.

@garvinhicking
Copy link
Member

The backend JS-Error is just if you open said URL in a window you'll see the PHP error message you get in the frontend, so that's expected.

I don't know how to debug this. Are you maybe able to setup a copy of the installation and temporarily give me SSH access to it, so I could debug stuff? Or maybe in a ddev/virtualbox VM image...

@surrim
Copy link
Contributor

surrim commented Dec 23, 2022

I can reproduce with PHP8.1 on 4ecb0770da213a2326f4fe610fba2c2e5ecee334. No defines without "@" found, but everything full of errors:

== ERROR-REPORT (BETA/ALPHA-BUILDS) ==

Warning: Constant LANG_CHARSET already defined in [...]/lang/UTF-8/serendipity_lang_en.inc.php on line 6.
For more details set $serendipity['production'] = 'debug' in serendipity_config_local.inc.php to receive a stack-trace.
== ERROR-REPORT (BETA/ALPHA-BUILDS) ==

Warning: Constant SQL_CHARSET already defined in [...]/lang/UTF-8/serendipity_lang_en.inc.php on line 7.
For more details set $serendipity['production'] = 'debug' in serendipity_config_local.inc.php to receive a stack-trace.
== ERROR-REPORT (BETA/ALPHA-BUILDS) ==

Warning: Constant DATE_LOCALES already defined in [...]/lang/UTF-8/serendipity_lang_en.inc.php on line 8.
For more details set $serendipity['production'] = 'debug' in serendipity_config_local.inc.php to receive a stack-trace.
== ERROR-REPORT (BETA/ALPHA-BUILDS) ==

Warning: Constant DATE_FORMAT_ENTRY already defined in [...]/lang/UTF-8/serendipity_lang_en.inc.php on line 9.
For more details set $serendipity['production'] = 'debug' in serendipity_config_local.inc.php to receive a stack-trace.
== ERROR-REPORT (BETA/ALPHA-BUILDS) ==

Warning: Constant DATE_FORMAT_SHORT already defined in [...]/lang/UTF-8/serendipity_lang_en.inc.php on line 10.
For more details set $serendipity['production'] = 'debug' in serendipity_config_local.inc.php to receive a stack-trace.
[...]

@surrim
Copy link
Contributor

surrim commented Dec 24, 2022

Putting $serendipity['production'] = true; into serendipity_config_local.inc.php helped a lot. Now there are other errors [...]

Anyway, the error handling should be rewritten. $serendipity['production'] can be true, false, debug. This value is not set by default. In this case $serendipity['production'] will be set depending on the ending of $serendipity['version'] e.g. ("alpha", "beta" etc.

The S9Y error handler is currently hard to understand (see Technical debts) and should be rewritten.

Setting $serendipity['version'] = '2.4.0'; in serendipity_config.inc.php (maybe $serendipity['production'] = 'true'; in serendipity_config_local.inc.php (can't test ATM)) solves all problems.
But thats a hotfix and no a real solution, because the site can't run with $serendipity['production'] = 'debug' anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants