1 (edited by poncho1234 07/17/2018 07:35:53 pm)

Topic: How is ‘path_to_root’ set? Or how to reset the working directory?

How is ‘path_to_root’ set? Or how to reset the working directory?


I am writing a small extension to add some additional fields to customers.


So sales/manage/customers.php
Is now modules/additional_fields/manage/ customers.php


File:  /additional_fields/manage/customers.php

Line 13: $path_to_root = "../..";
Is changed to:-
Line 13: $path_to_root = "../../..";

The necessary code is added for the additional fields which work as expected.


However, clicking on the Transactions tab the following error (and 4 others similar appear):-

include_once(../../includes/db_pager.inc): failed to open stream: No such file or directory in file: /sales/inquiry/customer_inquiry.php at line 14
/sales/inquiry/customer_inquiry.php:14: include_once()
modules/additional_fields/manage/add_customers.php:449: include_once(' /sales/inquiry/customer_inquiry.php')

And

include_once(): Failed opening '../../includes/db_pager.inc' for inclusion (include_path='.;C:\php\pear') in file: sales\inquiry\customer_inquiry.php at line 14
sales\inquiry\customer_inquiry.php:14:     include_once()
modules\additional_fields\manage\add_customers.php:450:     include_once('sales\inquiry\customer_inquiry.php')

(Similar errors appear on the Sales Orders tab)

If the path_to_root in customer_inquiry.php is changed to ../../.. then it works, but obviously now I cannot access Sales -> Customer Transaction Inquiry as numerous fatal errors appear.


How do I reset the working directory?

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

Re: How is ‘path_to_root’ set? Or how to reset the working directory?

Use a different variable for your extension's path to root and it will lapse after it's scope vanishes.

3 (edited by poncho1234 07/19/2018 11:57:04 am)

Re: How is ‘path_to_root’ set? Or how to reset the working directory?

Changed path_to_root to new_path_to_root

Now getting the following fatal errors:-

( ! ) Warning: include_once(../../includes/ui/db_pager_view.inc): failed to open stream: No such file or directory in E:\wamp64\www\FAmods\includes\db_pager.inc on line 18
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0027    537576    include_once( 'E:\wamp64\www\FAmods\includes\db_pager.inc' )    ...\add_customers.php:16

( ! ) Warning: include_once(): Failed opening '../../includes/ui/db_pager_view.inc' for inclusion (include_path='.;C:\php\pear') in E:\wamp64\www\FAmods\includes\db_pager.inc on line 18
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0027    537576    include_once( 'E:\wamp64\www\FAmods\includes\db_pager.inc' )    ...\add_customers.php:16

( ! ) Warning: include_once(../../includes/errors.inc): failed to open stream: No such file or directory in E:\wamp64\www\FAmods\includes\session.inc on line 374
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

( ! ) Warning: include_once(): Failed opening '../../includes/errors.inc' for inclusion (include_path='.;C:\php\pear') in E:\wamp64\www\FAmods\includes\session.inc on line 374
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

( ! ) Warning: set_error_handler() expects the argument (error_handler) to be a valid callback in E:\wamp64\www\FAmods\includes\session.inc on line 376
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17
3    0.1137    679056    set_error_handler ( )    ...\session.inc:376

( ! ) Warning: set_exception_handler() expects the argument (exception_handler) to be a valid callback in E:\wamp64\www\FAmods\includes\session.inc on line 377
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17
3    0.1594    679040    set_exception_handler ( )    ...\session.inc:377

( ! ) Warning: include_once(../../includes/current_user.inc): failed to open stream: No such file or directory in E:\wamp64\www\FAmods\includes\session.inc on line 379
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

( ! ) Warning: include_once(): Failed opening '../../includes/current_user.inc' for inclusion (include_path='.;C:\php\pear') in E:\wamp64\www\FAmods\includes\session.inc on line 379
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

( ! ) Warning: include_once(../../frontaccounting.php): failed to open stream: No such file or directory in E:\wamp64\www\FAmods\includes\session.inc on line 380
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

( ! ) Warning: include_once(): Failed opening '../../frontaccounting.php' for inclusion (include_path='.;C:\php\pear') in E:\wamp64\www\FAmods\includes\session.inc on line 380
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

( ! ) Warning: include_once(../../admin/db/security_db.inc): failed to open stream: No such file or directory in E:\wamp64\www\FAmods\includes\session.inc on line 381
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

( ! ) Warning: include_once(): Failed opening '../../admin/db/security_db.inc' for inclusion (include_path='.;C:\php\pear') in E:\wamp64\www\FAmods\includes\session.inc on line 381
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

( ! ) Warning: include_once(../../includes/lang/language.inc): failed to open stream: No such file or directory in E:\wamp64\www\FAmods\includes\session.inc on line 382
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

( ! ) Warning: include_once(): Failed opening '../../includes/lang/language.inc' for inclusion (include_path='.;C:\php\pear') in E:\wamp64\www\FAmods\includes\session.inc on line 382
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

( ! ) Warning: include_once(../../config_db.php): failed to open stream: No such file or directory in E:\wamp64\www\FAmods\includes\session.inc on line 383
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

( ! ) Warning: include_once(): Failed opening '../../config_db.php' for inclusion (include_path='.;C:\php\pear') in E:\wamp64\www\FAmods\includes\session.inc on line 383
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

( ! ) Warning: include_once(../../includes/ajax.inc): failed to open stream: No such file or directory in E:\wamp64\www\FAmods\includes\session.inc on line 384
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

( ! ) Warning: include_once(): Failed opening '../../includes/ajax.inc' for inclusion (include_path='.;C:\php\pear') in E:\wamp64\www\FAmods\includes\session.inc on line 384
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

( ! ) Warning: include_once(../../includes/ui/ui_msgs.inc): failed to open stream: No such file or directory in E:\wamp64\www\FAmods\includes\session.inc on line 385
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

( ! ) Warning: include_once(): Failed opening '../../includes/ui/ui_msgs.inc' for inclusion (include_path='.;C:\php\pear') in E:\wamp64\www\FAmods\includes\session.inc on line 385
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

( ! ) Warning: include_once(../../includes/prefs/sysprefs.inc): failed to open stream: No such file or directory in E:\wamp64\www\FAmods\includes\session.inc on line 386
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

( ! ) Warning: include_once(): Failed opening '../../includes/prefs/sysprefs.inc' for inclusion (include_path='.;C:\php\pear') in E:\wamp64\www\FAmods\includes\session.inc on line 386
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

( ! ) Warning: include_once(../../includes/hooks.inc): failed to open stream: No such file or directory in E:\wamp64\www\FAmods\includes\session.inc on line 388
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

( ! ) Warning: include_once(): Failed opening '../../includes/hooks.inc' for inclusion (include_path='.;C:\php\pear') in E:\wamp64\www\FAmods\includes\session.inc on line 388
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

( ! ) Notice: Undefined variable: installed_extensions in E:\wamp64\www\FAmods\includes\session.inc on line 392
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

( ! ) Warning: Invalid argument supplied for foreach() in E:\wamp64\www\FAmods\includes\session.inc on line 392
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

( ! ) Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at E:\wamp64\www\FAmods\includes\session.inc:374) in E:\wamp64\www\FAmods\includes\session.inc on line 31
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17
3    0.8302    679304    SessionManager->sessionStart( )    ...\session.inc:398
4    0.8303    680456    session_start ( )    ...\session.inc:31

( ! ) Fatal error: Class 'sys_prefs' not found in E:\wamp64\www\FAmods\includes\session.inc on line 400
Call Stack
#    Time    Memory    Function    Location
1    0.0013    426160    {main}( )    ...\add_customers.php:0
2    0.0641    678720    include_once( 'E:\wamp64\www\FAmods\includes\session.inc' )    ...\add_customers.php:17

Recreated the original variable with original path ($path_to_root = "../..";) whilst keeping path to root in file as new_path_to_root ../../.. but it seems session.inc takes its path from the path used to access it (if that makes sense - path to root is not defined in session.inc)

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

Re: How is ‘path_to_root’ set? Or how to reset the working directory?

Looks like you downloaded the FAMods into a separate folder and did not integrate it with your FA core.

Re: How is ‘path_to_root’ set? Or how to reset the working directory?

FAMods is just the name i choose for the root dir.

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

Re: How is ‘path_to_root’ set? Or how to reset the working directory?

Then make sure that the original path to root variable also gets passed on as well but as it's original value.

7 (edited by poncho1234 07/23/2018 09:02:55 pm)

Re: How is ‘path_to_root’ set? Or how to reset the working directory?

Can also confirm I was using:-

$new_path_to_root = "../../.."; //new path for includes in customers.php

And

$path_to_root = "../.."; //Old path to pass in session

It seems that once the path is set in the session it remains the same – is this correct?

I installed on lamp server as well, this did provide slightly different faults:-

include_once(../../includes/db_pager.inc): failed to open stream: No such file or directory in file: /sales/inquiry/customer_inquiry.php at line 14
/sales/inquiry/customer_inquiry.php:14:     include_once()
/modules/additional_fields/manage/add_customers.php:451:     include_once(' /sales/inquiry/customer_inquiry.php')
include_once(): Failed opening '../../includes/db_pager.inc' for inclusion (include_path='.:/opt/alt/php56/usr/share/pear:/opt/alt/php56/usr/share/php') in file: /sales/inquiry/customer_inquiry.php at line 14
/sales/inquiry/customer_inquiry.php:14:     include_once()
/modules/additional_fields/manage/add_customers.php:451:     include_once(' /sales/inquiry/customer_inquiry.php')

The pear / php path is doubled up isn’t it?

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


EDIT

this maybe interesting

I changed php ver to 7.0 (Also tried 7.1... same result)

and the fault changed to:-

(include_path='.:/opt/cpanel/ea-php70/root/usr/share/pear')

No mention of .....share/php??????

Tried changing php ver on wamp, no change in errors - so this maybe a red herring?

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

Re: How is ‘path_to_root’ set? Or how to reset the working directory?

Please put a copy of the customer_inquiry.php to additional_fields/inquiry/
Modify the $path_to_root of new customer_inquiry.php to the same as of add_customer.php.
Then change the include path in additional_fields/manage/add_customer.php to:
include_once('modules/additional_fields/inquiry/customer_inquiry.php')

Don't need to change anything in the core

Phuong

Re: How is ‘path_to_root’ set? Or how to reset the working directory?

@notrinos, thank you so much for that, added for all tabs in cust. supp. and items

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/