Jump to content
TNG Community
mahesh

Undefined variable: subroot

Recommended Posts

mahesh

Not sure if this is right place to ask this.

I am using include, to get values for my plugin, from config.php.

All works okay but I am unable to get rid of
PHP Notice: Undefined variable: subroot.

I am not using $suboot anywhere in my code.

 

Ohh.. While I am here,

Just upgraded to 12 from 10. Now $cms does not appear to work in index.php of V12.

.  "$cms[tngpath]" gives me

  'support' => string '' (length=0)
  'url' => string '' (length=0)
  'tngpath' => string '' (length=0)
  'module' => string '' (length=0)
  'cloaklogin' => string '' (length=0)
  'credits' => string '' (length=0)
  'adminurl' => string '' (length=0)

Any ideas?

 

Share this post


Link to post
Share on other sites
Ken Roy
1 hour ago, mahesh said:

Just upgraded to 12 from 10. Now $cms does not appear to work in index.php of V12.

.  "$cms[tngpath]" gives me


  'support' => string '' (length=0)
  'url' => string '' (length=0)
  'tngpath' => string '' (length=0)
  'module' => string '' (length=0)
  'cloaklogin' => string '' (length=0)
  'credits' => string '' (length=0)
  'adminurl' => string '' (length=0)

Sounds like these are from an old index page that needs to be updated to use quoted variables since $cms['tngpath']  should be within single quotes.

I do not know anything about WordPress but if your plugin is meant to be used by users who might move their TNG configuration files outside of web browser addressability, you do need to use the $subroot to get to the config.php file

Share this post


Link to post
Share on other sites
mahesh
On 9/27/2019 at 4:33 PM, Ken Roy said:

Sounds like these are from an old index page that needs to be updated to use quoted variables since $cms['tngpath']  should be within single quotes.

  This is embarassing, Ken.

Yes, looks like I have using this since V8. I see there a syntex error was introduced along the line. I guess I got away with it  because relative paths in include statements worked. Now PHP 7.x requires real path, hence the error.


For now, my workaround is
include_once($rootpath. "/add_ons/surnames-top10.php");

I am bit confused about $cms because I am getting nil values. Must dig deeper to findout about this.

On 9/27/2019 at 4:33 PM, Ken Roy said:

I do not know anything about WordPress but if your plugin is meant to be used by users who might move their TNG configuration files outside of web browser addressability, you do need to use the $subroot to get to the config.php file

Ken, my knowledge of TNG is less than 10% of your Wordpress knowledge. So, thank you so much for flagging up use of $subroot. I see that all I have to do is replace config.php with subroot.php in my include statements.

I still have not found a way to suppress

PHP Notice:  Undefined variable: $subroot in config.php.

Adding $subroot = "" in config.php  is, probably, not the correct way of doing it.

Really appreciate your help in this.

Thanks

 

Share this post


Link to post
Share on other sites
Newfloridian

Hi Mahesh

What does the full PHP error message say. It usually tells you the undefined variable and the line and file the error occurs in. Need both to clarify

I did battle with this issue when I upgraded my own TNG 10.1.3 to run with PHP 7.3

I needed help from Darrin on that one. It does turn out that there was an upgrade to the file subroot.php somewhere within TNG 10 and TNG 11 but the update file was included in the specials folder in the upgrade not in the upgrade itself. Have a look at your subroot.php file and compare it with what I have now:

<?php
error_reporting(E_ERROR);
$tngconfig = array();
$tngconfig['subroot'] = "";
$subroot = $tngconfig['subroot'] ? $tngconfig['subroot'] : "";
?>

Cheers Alan

 

Share this post


Link to post
Share on other sites
Ken Roy

Thanks Alan,

I must have missed that in the upgrade.   Will need to figure out what the values need to be if one uses the Config Path to move the TNG configuration file outside of the web  browser access.

Share this post


Link to post
Share on other sites
mahesh

Hi Alan,

Thanks Alan. I did have older version subroot.php. I have updated that. Thanks a lot for flagging this.

I think I am being pedantic here. Now I do not have any error messages generated by error_reporting.
But in Wordpress, I have query monitor plugin installed which helps me debug my plugins.
 

Quote

  Query Monitor is the developer tools panel for WordPress. It enables debugging of database queries, PHP errors, hooks and actions, Block Editor blocks, enqueued scripts and style sheets, HTTP API calls, and more.

The error is

Notice:
Undefined variable: subroot
C:/wamp64/www/tng12xx/config.php:216

I think I can ignore it but it would satisfy my curiocity if I knew how to fix it.!

Again, thanks Alan for the update. Appreciate it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×