Forum

Thread tagged as: Error, Installation

Setup error: Undefined constant PERCH_ERROR_MODE

When I run setup, I get the following error:

Warning: constant(): Couldn't find constant PERCH_ERROR_MODE in [path]/perch/core/lib/PerchDB_MySQL.class.php on line 44

It happens after the user creation step in the setup. This seems very similar to this question/post/answer https://forum.grabaperch.com/forum/04-07-2017-warning-constant-couldnt-find-constant-perch-db-password, but it seems very odd that I should need to edit the config after it's been created (unless I want to customize something). The setup seems to have created the tables, but the user table is still empty. I also can't seem to find anyway around it other than hacking the user in manually (you don't want to know).

Any ideas how to solve it?

Here's the full error:

( ! ) Warning: constant(): Couldn't find constant PERCH_ERROR_MODE in [path]/perch/core/lib/PerchDB_MySQL.class.php on line 44
Call Stack
#   Time    Memory  Function    Location
1   0.0001  260624  {main}( )   .../index.php:0
2   0.0001  261200  include( '[path]/perch/setup/env.php' ) .../index.php:2
3   0.0012  353120  PerchAPI->__construct( )    .../env.php:80
4   0.0013  359536  PerchLang::fetch( ) .../PerchAPI.class.php:21
5   0.0013  359896  PerchLang->__construct( )   .../PerchLang.class.php:44
6   0.0016  397384  PerchSettings->get( )   .../PerchLang.class.php:19
7   0.0016  397808  PerchDB_MySQL->get_rows( )  .../PerchSettings.class.php:59
8   0.0018  399760  PerchDB_MySQL->get_link( )  .../PerchDB_MySQL.class.php:166
9   0.0018  399952  PerchDB_MySQL->open_link( ) .../PerchDB_MySQL.class.php:115
10  0.0024  429536  PerchDB_MySQL->config( )    .../PerchDB_MySQL.class.php:79
11  0.0024  429584  constant ( )    .../PerchDB_MySQL.class.php:44

( ! ) Warning: Cannot modify header information - headers already sent by (output started at [path]/perch/core/lib/PerchDB_MySQL.class.php:44) in [path]/perch/core/lib/PerchUtil.class.php on line 233
Call Stack
#   Time    Memory  Function    Location
1   0.0001  260624  {main}( )   .../index.php:0
2   0.0001  261200  include( '[path]/perch/setup/env.php' ) .../index.php:2
3   0.0012  353120  PerchAPI->__construct( )    .../env.php:80
4   0.0013  359536  PerchLang::fetch( ) .../PerchAPI.class.php:21
5   0.0013  359896  PerchLang->__construct( )   .../PerchLang.class.php:44
6   0.0016  397384  PerchSettings->get( )   .../PerchLang.class.php:19
7   0.0016  397808  PerchDB_MySQL->get_rows( )  .../PerchSettings.class.php:59
8   0.0018  399760  PerchDB_MySQL->get_link( )  .../PerchDB_MySQL.class.php:166
9   0.0018  399952  PerchDB_MySQL->open_link( ) .../PerchDB_MySQL.class.php:115
10  0.0026  429872  PerchUtil::redirect( )  .../PerchDB_MySQL.class.php:93
11  0.0027  434696  header ( )  .../PerchUtil.class.php:233
Darryl Hein

Darryl Hein 0 points

  • 4 years ago

Have you removed details from diagnostic report [path] or is that the actual output?

I replaced the actual path with [path]...no need to know my server structure :)

Add PERCH_ERROR_MODE, 'SILENT' to configure.php and see what happens.

So, here's the problem: I can add it to the config (thus creating the non-existent config) but then the setup process immediately overwrites the file and we're back at square one. I can kinda hack around by refreshing and going back and forth through the setup process, but it seems extremely odd that this would happen at all. I would think it should either check for the constant's existence before using it or ensure it's defined somewhere.

It looks like the constant is defined when using the runtime, but not always during setup (and maybe not at all).

What is your dev environment? I am guessing windows??

Nope, it's Linux (CentOS) with Apache/PHP-FPM 5.6/MySQL.

Drew McLellan

Drew McLellan 2638 points
Perch Support

That's one of the very first constants that gets defined - I can't think of a way your database would be accessed before that's defined.

What's the URL when you get that error?