Bug with 'require_once' file path [message #5415] |
Wed, 09 March 2016 21:34 |
kong
Messages: 90 Registered: December 2011
|
Member |
|
|
Replication:
1. Using Radicore v1.93, create 2 subsystems
- Subsystem A has 1 table
- Subsystem B has 2 tables that are related to each other with parent/child relationship
2. In subsystem A, create a component script in which subsystem B's child object is invoked using the singleton function and call getData() function using that object.
3. When this component script is executed the web application will hang with a white browser screen.
Problem trace:
The problem has been traced back to the file std.table.class.inc, function _sqlProcessJoin(), specifically the following lines: if (array_key_exists('subsys_dir', $reldata)) {
...
} else {
$dir = NULL;
} // if
if (!class_exists($parent_table)) {
require_once $dir ."classes/$parent_table.class.inc";
} // if The web app hangs at the execution of the require_once statement. It appears that all this code has been called as part of subsystem B child object's process to obtain its parent record information. Since both child and parent objects are in the same subsystem, the variable $dir will be NULL, which makes the 'require_once' file path invalid because the component file was executed under the directory of subsystem A.
Solution:
In the code shown above, change this line:into this: $dir = dirname($this->dirname) .DIRECTORY_SEPARATOR;
[Updated on: Thu, 10 March 2016 01:26] Report message to a moderator
|
|
|
|
Re: Bug with 'require_once' file path [message #5418 is a reply to message #5417] |
Thu, 10 March 2016 07:58 |
kong
Messages: 90 Registered: December 2011
|
Member |
|
|
About 1:
I think the answer is yes. I created LIST1 component script for the table in subsystem A and then added the following to its class file:
function _cm_pre_getData ($where, $where_array, $parent_data=null)
{
require_once "../systemb/classes/child_table.class.inc";
$tbl =& RDCsingleton::getInstance('child_table');
$rows = $tbl->getData();
return $where;
} // _cm_pre_getData In this way, every time we pull up LIST1 of subsystem A's table, it will invoke subsystem B's child_table class. This example does nothing with the obtained data from child_table, but is just a way to replicate the problem. So, if the solution I mentioned in the first post has been applied, the created LIST1 feature can be executed without any problems. And after I undo the solution, then every time we try to run the created LIST1 feature, the code will come to a halt at the location I mentioned in the first post and a blank browser screen will appear.
About 2:
Do you mean the include_path in .htaccess file in Radicore's root directory? That has been set as follows:php_value include_path ".;D:\Portable\Wamp\ServerZ\www\test_radicore\includes" Note that the problem only happens when child_table has a parent relationship with the other table in subsystem B. If I delete that relationship, the problem will not occur. So yes, I can see that component script in subsystem A can call objects and functions in subsystem B. But not sure whether that is what you meant by "script running in subsystem A can reference a script in subsystem B".
|
|
|
Re: Bug with 'require_once' file path [message #5419 is a reply to message #5418] |
Thu, 10 March 2016 11:05 |
AJM
Messages: 2371 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
I can immediately see that you are doing some things in a questionable way.
1) When using RDCsingleton:getInstance('table.class.inc') you do not need to require/include the class file beforehand as this is handled automatically in the getInstance method.
2) The ability to access classes in another subsystem should be handled by putting the path to that other subsystem in the htaccess file. Alternatively you can use 'subsystem/table.class.inc' in the call to getInstance() as this will automatically update include_path.
3) I do not understand why in the _cm_pre_getData method for that table you are reading data from a different table in a different subsystem. Your LIST1 task should go directly to the child table without having to go through the parent table.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|