1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 12:20:44 +02:00

Defers SITEURL and dependencies until SQL loaded

This is the least intrusive solution I could come up with.

Anything else I tried to reduce technical debt would break the very
tangled dependency web, so I settled for this.

Fixes: #3033
This commit is contained in:
Deltik
2018-02-12 06:50:43 -06:00
parent de7fb1d1a0
commit d1a69b0c16
3 changed files with 199 additions and 186 deletions

4
class2.php Normal file → Executable file
View File

@@ -464,6 +464,10 @@ elseif ($merror === 'e2')
/* PHP Compatabilty should *always* be on. */
e107_require_once(e_HANDLER.'php_compatibility_handler.php');
// SITEURL constant depends on the database
// See https://github.com/e107inc/e107/issues/3033 for details.
$e107->set_urls_deferred();
//
// L: Extract core prefs from the database
//

34
e107_handlers/e107_class.php Normal file → Executable file
View File

@@ -374,8 +374,8 @@ class e107
*/
protected function _init($e107_paths, $e107_root_path, $e107_config_mysql_info, $e107_config_override = array())
{
if(empty($this->e107_dirs))
{
if(!empty($this->e107_dirs)) return $this;
// Do some security checks/cleanup, prepare the environment
$this->prepare_request();
@@ -424,8 +424,6 @@ class e107
// Prepare essential directories.
$this->prepareDirs();
}
return $this;
}
@@ -4151,8 +4149,8 @@ class e107
$this->file_path = $path;
if(!defined('e_HTTP') || !defined('e_ADMIN') )
{
if(defined('e_HTTP') && defined('e_ADMIN')) return $this;
if(!defined('e_HTTP'))
{
define('e_HTTP', $this->server_path); // Directory of site root relative to HTML base directory
@@ -4215,7 +4213,7 @@ class e107
define('e_WEB_JS', $this->get_override_rel('WEB_JS'));
define('e_WEB_CSS', $this->get_override_rel('WEB_CSS'));
define('e_WEB_IMAGE', $this->get_override_rel('WEB_IMAGES'));
// define('e_WEB_PACK', $this->get_override_rel('WEB_PACKS'));
// define('e_WEB_PACK', $this->get_override_rel('WEB_PACKS'));
define('e_CACHE', $this->get_override_rel('CACHE'));
define('e_CACHE_CONTENT', $this->get_override_rel('CACHE_CONTENT'));
@@ -4249,10 +4247,7 @@ class e107
define('e_MEDIA_VIDEO_ABS', $this->get_override_http('MEDIA_VIDEOS'));
define('e_MEDIA_IMAGE_ABS', $this->get_override_http('MEDIA_IMAGES'));
define('e_MEDIA_ICON_ABS', $this->get_override_http('MEDIA_ICONS'));
// define('e_MEDIA_AVATAR_ABS', $this->get_override_http('MEDIA_AVATARS'));
// define('e_MEDIA_AVATAR_ABS', $this->get_override_http('MEDIA_AVATARS'));
// XXX DISCUSSS - e_JS_ABS, e_CSS_ABS etc is not following the naming standards but they're more usable.
// Example: e_JS_ABS vs e_WEB_JS_ABS
@@ -4261,7 +4256,7 @@ class e107
define('e_WEB_ABS', $this->get_override_http('WEB'));
define('e_JS_ABS', $this->get_override_http('WEB_JS'));
define('e_CSS_ABS', $this->get_override_http('WEB_CSS'));
// define('e_PACK_ABS', $this->get_override_http('WEB_PACKS'));
// define('e_PACK_ABS', $this->get_override_http('WEB_PACKS'));
define('e_WEB_IMAGE_ABS', $this->get_override_http('WEB_IMAGES'));
define('e_JS', $this->get_override_http('WEB_JS')); // ABS Alias
@@ -4284,8 +4279,6 @@ class e107
define('e_BOOTSTRAP', e_WEB."bootstrap/");
}
return $this;
}
@@ -4473,7 +4466,20 @@ class e107
define('ADMINDIR', $ADMIN_DIRECTORY);
return $this;
}
/**
* The second part of e107::set_urls()
* Supposed to load after database has been initialized
*
* Implemented out of necessity due to
* https://github.com/e107inc/e107/issues/3033
*
* @return e107
*/
public function set_urls_deferred()
{
if(self::isCli())
{
define('SITEURL', self::getPref('siteurl'));

3
thumb.php Normal file → Executable file
View File

@@ -149,6 +149,9 @@ class e_thumbpage
// basic Admin area detection - required for proper path parsing
define('ADMIN', strpos(e_SELF, ($e107->getFolder('admin')) !== false || strpos(e_PAGE, 'admin') !== false));
$e107->set_urls(false);
// Next function call maintains behavior identical to before; might not be needed
// See https://github.com/e107inc/e107/issues/3033
$e107->set_urls_deferred();
$pref = $e107->getPref(); //TODO optimize/benchmark