TinyPortal

Development => Support => Topic started by: Lesmond on July 20, 2020, 03:37:30 PM

Title: Undefined index
Post by: Lesmond on July 20, 2020, 03:37:30 PM
Maybe I'm doing something wrong :-[ but I am getting this error when clicking on  General Articles category.

Type of error: Undefined
8: Undefined index: showchild
https://forum.xxxxx.pw/index.php?cat=2
/home/lesmond/public_html/forum/Themes/default/TPsubs.template.php (Line 2103)


SMF 2.1 RC2 --- TinyPortal 1.6.7
Title: Re: Undefined index
Post by: lurkalot on July 20, 2020, 05:51:21 PM
Thanks Les.  I just replicated the error on my test site, not seen that one before. 

Type of error: Undefined_vars
Error message:
8: Undefined index: showchild
File: /home/vol11_7/byethost7.com/b7_24299229/htdocs/testsite7/Themes/default/TPsubs.template.php
Line: 2103
URL of page causing the error: http://lts4.byethost7.com/testsite7/index.php?cat=2

Backtrace information
#0: smf_error_handler()
Called from /home/vol11_7/byethost7.com/b7_24299229/htdocs/testsite7/Themes/default/TPsubs.template.php on line 2103

#1: category_childs()
Called from /home/vol11_7/byethost7.com/b7_24299229/htdocs/testsite7/Themes/default/TPortal.template.php on line 142

#2: template_category()
Called from /home/vol11_7/byethost7.com/b7_24299229/htdocs/testsite7/Themes/default/TPortal.template.php on line 38

#3: template_main()
Called from /home/vol11_7/byethost7.com/b7_24299229/htdocs/testsite7/Sources/Load.php on line 2636

#4: loadSubTemplate()
Called from /home/vol11_7/byethost7.com/b7_24299229/htdocs/testsite7/Sources/Subs.php on line 3472

#5: obExit()
Called from /home/vol11_7/byethost7.com/b7_24299229/htdocs/testsite7/index.php on line 176
Title: Re: Undefined index
Post by: Lesmond on July 20, 2020, 05:57:50 PM
I never checked the the backtrace info, looks the same on my site...

Code ( Backtrace information) Select

#0: smf_error_handler()
Called from /home/lesmond/public_html/forum/Themes/default/TPsubs.template.php on line 2103
#1: category_childs()
Called from /home/lesmond/public_html/forum/Themes/default/TPortal.template.php on line 142
#2: template_category()
Called from /home/lesmond/public_html/forum/Themes/default/TPortal.template.php on line 38
#3: template_main()
Called from /home/lesmond/public_html/forum/Sources/Load.php on line 2474
#4: loadSubTemplate()
Called from /home/lesmond/public_html/forum/Sources/Subs.php on line 3279
#5: obExit()
Called from /home/lesmond/public_html/forum/index.php on line 154
Title: Re: Undefined index
Post by: Lesmond on July 20, 2020, 05:59:34 PM
Could it be because there are no articles under "General Articles" ?
Title: Re: Undefined index
Post by: lurkalot on July 20, 2020, 06:12:57 PM
Quote from: Lesmond on July 20, 2020, 05:59:34 PM
Could it be because there are no articles under "General Articles" ?

No don't think so Les, I have articles in my General Category.  I can only replicate the error if I ad a sub cat to General articles.  Regardless of whether they have anything in them it seems to throw the error.

I noticed if I append my site url with ?cat=2 the page that comes up only shows a button with "Portal Features" on it, clicking this results in that error.
Title: Re: Undefined index
Post by: Lesmond on July 20, 2020, 06:26:43 PM
I have removed the "Portal Features" category but I am not sure if the error appeared before doing that.
Title: Re: Undefined index
Post by: lurkalot on July 20, 2020, 07:38:34 PM
Quote from: Lesmond on July 20, 2020, 06:26:43 PM
I have removed the "Portal Features" category but I am not sure if the error appeared before doing that.

I would leave as is for the moment Les, see if @rjen or Tino can come up with a fix for it, hopefully they can also replicate it.

One thing also noticed, but unrelated.  While trying to replicate this I deleted the sub cat name and saved, there was no way to get back to that category to edit it afterwards, even though it's obviously still there. So that's another issue.  Probably needs some sort of default value. 
Title: Re: Undefined index
Post by: @rjen on July 20, 2020, 08:31:33 PM
Quote from: lurkalot on July 20, 2020, 06:12:57 PM
I noticed if I append my site url with ?cat=2 the page that comes up only shows a button with "Portal Features" on it, clicking this results in that error.

That's the default Cat list setting. The page is empty because it does not contain any articles...

I can see the error: it comes up when there is a subcategory created...
Title: Re: Undefined index
Post by: @rjen on July 20, 2020, 08:42:25 PM
Go to the category settings, switch ON the setting show subcategories and save it. Errors will be gone.
It seems the variable is not set on install...
Title: Re: Undefined index
Post by: lurkalot on July 20, 2020, 08:55:24 PM
Quote from: @rjen on July 20, 2020, 08:42:25 PM
Go to the category settings, switch ON the setting show subcategories and save it. Errors will be gone.
It seems the variable is not set on install...

Thanks @rjen, yep switched on "Display any child categories?" and indeed the errors stopped.  O0
Title: Re: Undefined index
Post by: @rjen on July 20, 2020, 08:58:57 PM
Quote from: lurkalot on July 20, 2020, 08:55:24 PM
Quote from: @rjen on July 20, 2020, 08:42:25 PM
Go to the category settings, switch ON the setting show subcategories and save it. Errors will be gone.
It seems the variable is not set on install...

Thanks @rjen, yep switched on "Display any child categories?" and indeed the errors stopped.  O0

It actually should not matter what setting you change: it is caused by the variable missing when a new cat is created. Same happens when you create a new cat and not make ANY changes to the settings. Then create a child cat and it happens too...
Title: Re: Undefined index
Post by: @rjen on July 20, 2020, 09:04:24 PM
Attached file fixed it...
Title: Re: Undefined index
Post by: @rjen on July 20, 2020, 09:14:22 PM
Nice, same issue in 2.0.0... I'll fix that too...
Title: Re: Undefined index
Post by: Lesmond on July 20, 2020, 09:37:56 PM
 
Quote from: @rjen on July 20, 2020, 08:42:25 PM
Go to the category settings, switch ON the setting show subcategories and save it. Errors will be gone.
It seems the variable is not set on install...
Thanks mate fixed it for me too,  O0
Title: Re: Undefined index
Post by: @rjen on July 21, 2020, 07:57:55 AM
Quote from: lurkalot on July 20, 2020, 07:38:34 PM
One thing also noticed, but unrelated.  While trying to replicate this I deleted the sub cat name and saved, there was no way to get back to that category to edit it afterwards, even though it's obviously still there. So that's another issue.  Probably needs some sort of default value.

That is no longer an issue in 2.0.0: I did already add the 'Edit' icon on the reworked category layout as well. I could do the same in 1.6.x, but we agreed the 1.6 would be a bug-fix branch only, and this is not a bug, more of an 'unrequested-feature'..
Title: Re: Undefined index
Post by: @rjen on July 21, 2020, 08:11:00 AM
This actually makes me wonder: why do we even allow users to create articles and categories WITHOUT a name? Is that something that has a reason? Or is that because in the olden days no one thought to make the names required entry fields?

I am thinking to do that (make them required) to prevent such things from happening at all...
Title: Re: Undefined index
Post by: lurkalot on July 21, 2020, 08:18:06 AM
Quote from: @rjen on July 21, 2020, 08:11:00 AM
This actually makes me wonder: why do we even allow users to create articles and categories WITHOUT a name? Is that something that has a reason? Or is that because in the olden days no one thought to make the names required entry fields?

I am thinking to do that (make them required) to prevent such things from happening at all...

I wondered that too, hence why I said they should have some sort of default value, or it should prevent you from saving it without entering something.
Title: Re: Undefined index
Post by: @rjen on July 21, 2020, 08:22:19 AM
I noticed that I creates a default value when you create a new category without a name (-no name-), but it lets you delete it completely afterwards...

On articles something similar happens, but that seems to be more completely implemented.
I guess for categories it should be mandatory to specify a name at all times. What about articles?
Title: Re: Undefined index
Post by: lurkalot on July 21, 2020, 08:25:14 AM
Quote from: @rjen on July 21, 2020, 08:22:19 AM
I noticed that I creates a default value when you create a new category without a name (-no name-), but it lets you delete it completely afterwards...

On articles something similar happens, but that seems to be more completely implemented.
I guess for categories it should be mandatory to specify a name at all times. What about articles?

Or blocks.  ;)
Title: Re: Undefined index
Post by: @rjen on July 21, 2020, 08:29:31 AM
Quote from: lurkalot on July 21, 2020, 08:25:14 AM
Quote from: @rjen on July 21, 2020, 08:22:19 AM
I noticed that I creates a default value when you create a new category without a name (-no name-), but it lets you delete it completely afterwards...

On articles something similar happens, but that seems to be more completely implemented.
I guess for categories it should be mandatory to specify a name at all times. What about articles?

Or blocks.  ;)

That's not an answer, but another question  ^-^ ...
So what do you think / want there?
Title: Re: Undefined index
Post by: lurkalot on July 21, 2020, 08:39:12 AM
I was just adding to your question. ;)

What I think is it should not let you save unless you enter something, just give you a error message until you do. That kind of thing.
Title: Re: Undefined index
Post by: @rjen on July 21, 2020, 08:51:18 AM
I changed it for articles and cats. The blocks is also mostly done, just the blocks overview page is acting up: it errors on an empty name field but still wipes the name..

Will check out the TPdownloads too, guess that needs the same changes...
Title: Re: Undefined index
Post by: Lesmond on July 21, 2020, 10:52:01 AM
Sorry to have caused all this extra work guys :(
Title: Re: Undefined index
Post by: @rjen on July 21, 2020, 11:07:34 AM
Quote from: Lesmond on July 21, 2020, 10:52:01 AM
Sorry to have caused all this extra work guys :(

No problem at all...

Over the last year or so I have been going through the templates and sources to weed out a lot of this stuff, that I think is just 'legacy' and not necessarily there on purpose. In TP 2.0.0 I have corrected as much as I could find: cleaned up a lot of inline styling in the templates, rationalised templates to have identical layout and look and feel to make them easier to understand, but also these kind of improvements: to make it more 'solid'.

Your feedback makes me look at some stuff again that I did not notice before, so much appreciated.

But like I wrote before: we will not be spending any more effort on 1.6.x apart from real bug fixes. All improvements are in 2.0.0...