TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,004
  • Total Topics: 21,330
  • Online today: 103
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 357
  • Total: 357

issues relate to: 8: Undefined index: xx Line: 1490

Started by safanth, August 03, 2008, 11:45:42 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

safanth

Hello,

Using the following:

SMF 1.1.5
TinyPortal 1.0.5 beta 1
Theme: Dilber MC

The error log was filled with error messages containing the following profile:
8: Undefined index: 3  .......... Line 1490 TPoral.php

I have already scanned the forum and Bugtracker and see some similar issues although it didnt make sense to me to fix it, so I did some research on my own.

Line 1490: $context['TPortal']['current_category']=$context['TPortal']['catnames'][$row['category']];

error trigger
What I figured is that the line 1490 is assigning an article category name to the $context array. The code on line 1490 assumes that the querry row ($row) returns an already defined index for the $context['TPortal']['catnames'] array. In my case (according to the database) the id for the category is 3 and therefor it assumes a valid category name at index 3 in the $context['TPortal']['catnames'] array ($context['TPortal']['catnames'][3].

In short: the undefined index #3 in my case can vary for each of you depending on the categories created. Line 1490 is trying to assign a category name that is previously assigned to an array with the index in that array corresponding with the database id for that category.

error cause
The actual cause of the error is to be found in the file TPsubs.php at line 312 it parses the set permissions for the categories queried in the request. Meaning that if the current user is not matching any of the set permissions to a member group for that particular category, the rest of the assigment for that category is not done. This causes an article category not to be assigned for $context['TPortal']['catnames'].

In short: the loop to process category assignment for array $context['TPortal']['catnames'] will not be completed if a particular category is not permitted for the current user. This causes the error for that user when it opens a page which is assigned to display articles but not permitted for that member group i.e. guests.

solution / work around
I have not yet altered any code myself but it looks obvious that the article processing in TPortal.php should not be done if the permissions are not met, this prevents trying to process article information that is not yet defined but assumed to be assigned.
I have found a work around by setting the articles also to be permitted by any user, even guests, hence the artcles do not contain any information that I would not present to guests.

However, a fix is prefered so article categories for particular member groups can be created without causing the errors.....

Hope I am not completely off here... and hope this helps to fix the issues if not already fixed.

Cheers!

IchBin

Since you did such a fantastic job explaining and researching I've added it to the bug tracker.
http://www.tinyportal.net/index.php?action=bugtracker;sa=bug338

swayforth

Awesome job on locating the issue, this work around fixed issue and my logs are clean once again.

thank you!

This website is proudly hosted on Crocweb Cloud Website Hosting.