View Issue Details

IDProjectCategoryView StatusLast Update
0002320Composrcorepublic2016-03-23 18:27
ReporterPatrick SchmalstigAssigned ToChris Graham 
SeverityMinor-bug 
Status resolvedResolutionfixed 
Product Version 
Fixed in Version 
Summary0002320: Composr 10b4: Missing require_code statements
DescriptionComposr 10b4 has a few missing require_code statements. In regular website functionality, these are usually not necessary. However for scripts that use minimal Composr interface (such as bots as well as custom scripts that load just the core of Composr), without these require code statements, many errors are triggered and functionality is abnormal.

*sources/globals3.php needs a "require_code('config')" inside the get_ip_address function.

*sources/config.php needs a "require_code('database')" within the function around line 34.

*sources/config.php needs a "require_code('caches')" within the function near line 162.
Additional InformationRelated to 0002316
TagsNo tags attached.
Time estimation (hours)
Sponsorship open

Activities

Patrick Schmalstig

2016-03-20 03:44

administrator   ~0003450

There may be more within the code... these are just the ones I discovered are necessary.

Chris Graham

2016-03-22 03:30

administrator   ~0003463

These 3 are core includes, loaded up in the normal bootstrap process. Adding extra require_code calls for them would be potentially a performance hit, and potentially obscure bugs (caused by weird bootstrapping order).

Any third party code must initialise Composr in the normal way, rather than jumping into it. E.g. data/ajax_tree.php, loads a big blob of standard code before the final 2 lines of that file which are custom code now that Composr has bootstrapped.

Patrick Schmalstig

2016-03-22 03:46

administrator   ~0003464

I must not be doing it right then. What is required at the beginning of any script that needs Composr code access?

Chris Graham

2016-03-22 03:55

administrator   ~0003465

Last edited: 2016-03-22 03:55

View 2 revisions

Try this, with the correct value for $FILE_BASE.

<?php /*

 Composr
 Copyright (c) ocProducts, 2004-2016

 See text/EN/licence.txt for full licencing information.


 NOTE TO PROGRAMMERS:
   Do not edit this file. If you need to make changes, save your changed file to the appropriate *_custom folder
   **** If you ignore this advice, then your website upgrades (e.g. for bug fixes) will likely kill your changes ****

*/

/**
 * @license http://opensource.org/licenses/cpal_1.0 Common Public Attribution License
 * @copyright ocProducts Ltd
 * @package core
 */

// Find Composr base directory, and chdir into it
global $FILE_BASE, $RELATIVE_PATH;
$FILE_BASE = ...;
$RELATIVE_PATH = '';
@chdir($FILE_BASE);

global $FORCE_INVISIBLE_GUEST;
$FORCE_INVISIBLE_GUEST = false;
global $EXTERNAL_CALL;
$EXTERNAL_CALL = true;
if (!is_file($FILE_BASE . '/sources/global.php')) {
    exit('<!DOCTYPE html>' . "\n" . '<html lang="EN"><head><title>Critical startup error</title></head><body><h1>Composr startup error</h1>

The second most basic Composr startup file, sources/global.php, could not be located. This is almost always due to an incomplete upload of the Composr system, so please check all files are uploaded correctly.

Once all Composr files are in place, Composr must actually be installed by running the installer. You must be seeing this message either because your system has become corrupt since installation, or because you have uploaded some but not all files from our manual installer package: the quick installer is easier, so you might consider using that instead.

ocProducts maintains full documentation for all procedures and tools, especially those for installation. These may be found on the http://compo.sr. If you are unable to easily solve this problem, we may be contacted from our website and can help resolve it for you.

<hr /><p style="font-size: 0.8em">Composr is a website engine created by ocProducts.

</body></html>');
}
require($FILE_BASE . '/sources/global.php');

Patrick Schmalstig

2016-03-22 03:57

administrator   ~0003466

That's exactly what I have. Strange.

Patrick Schmalstig

2016-03-22 03:59

administrator   ~0003467

Oop nope it wasn't. external_call was set to false in my code.

Chris Graham

2016-03-22 04:01

administrator   ~0003468

That won't cause an issue.
Is the error reproducable? I don't have FTP access to the site anymore, if you can email me (chris@ocproducts.com) I can likely take a look tomorrow.

Chris Graham

2016-03-23 18:26

administrator   ~0003491

The issue is if...
Static caching is enabled *and*
A backdoor IP is set *and*
No cookies are set

It would try and call get_ip_address() too early in the startup.

Issue History

Date Modified Username Field Change
2016-03-20 03:43 Patrick Schmalstig New Issue
2016-03-20 03:44 Patrick Schmalstig Note Added: 0003450
2016-03-22 03:30 Chris Graham Note Added: 0003463
2016-03-22 03:30 Chris Graham Status non-assigned => closed
2016-03-22 03:30 Chris Graham Assigned To => Chris Graham
2016-03-22 03:30 Chris Graham Resolution open => won't fix
2016-03-22 03:46 Patrick Schmalstig Note Added: 0003464
2016-03-22 03:55 Chris Graham Note Added: 0003465
2016-03-22 03:55 Chris Graham Note Edited: 0003465 View Revisions
2016-03-22 03:57 Patrick Schmalstig Note Added: 0003466
2016-03-22 03:59 Patrick Schmalstig Note Added: 0003467
2016-03-22 04:01 Chris Graham Note Added: 0003468
2016-03-23 18:26 Chris Graham Note Added: 0003491
2016-03-23 18:27 Chris Graham Status closed => resolved
2016-03-23 18:27 Chris Graham Resolution won't fix => fixed