ElkArte Community

Elk Development => Bug Reports => Exterminated Bugs => Topic started by: niloc on June 17, 2016, 12:50:16 am

Title: HTTP ERROR 500 when clicking "Layout" in Admin area (1.1)
Post by: niloc on June 17, 2016, 12:50:16 am
Configuration > Features & Options > Layout

When I click Layout, it crashes. Hmm...
Title: Re: HTTP ERROR 500 when clicking "Layout" in Admin area (1.1)
Post by: emanuele on June 17, 2016, 03:39:10 am
Linux?
Windows?
PHP version?
Some "special" setting?

The only potentially peculiar thing that the page does is scan a few directories for controllers, so it's either a problem with win VS lin file structure or some php extension not working the way it is supposed to. I guess.
Title: Re: HTTP ERROR 500 when clicking "Layout" in Admin area (1.1)
Post by: niloc on June 17, 2016, 05:50:44 am
Linux. PHP 5.6 (tried on 5.4 as well, crashes too).

Not sure what you mean by "Special Setting" though.. :/

Edit: Woops, I thought you were asking for my own computer's OS. Updated to "Linux" instead. :p
Title: Re: HTTP ERROR 500 when clicking "Layout" in Admin area (1.1)
Post by: emanuele on June 17, 2016, 05:55:46 am
/me has to fire up wamp on the laptop... :'( <= it takes ages on the poor thing!! :'( :'(
Title: Re: HTTP ERROR 500 when clicking "Layout" in Admin area (1.1)
Post by: niloc on June 17, 2016, 05:57:28 am
T.T Sorry, it's Linux, not Windows.
Title: Re: HTTP ERROR 500 when clicking "Layout" in Admin area (1.1)
Post by: emanuele on June 17, 2016, 06:09:54 am
Heck.
I hoped it was windows because at least it gave me something to work on...

Could you check the permissions are all set correctly? (Maybe you have some file around in the controllers or addons directories that has a wrong permission/owner?)
Title: Re: HTTP ERROR 500 when clicking "Layout" in Admin area (1.1)
Post by: niloc on June 17, 2016, 06:35:14 am
All the files in Controllers & Addons are 644. Is that correct?
Title: Re: HTTP ERROR 500 when clicking "Layout" in Admin area (1.1)
Post by: emanuele on June 17, 2016, 02:11:16 pm
Ok, let's try to pinpoint the issue.
Could you open sources/admin/ManageFeatures.controller.php search for the line:
Code: [Select]
$config_vars = getFrontPageControllers();
and change it to:
Code: [Select]
$config_vars = array();
Title: Re: HTTP ERROR 500 when clicking "Layout" in Admin area (1.1)
Post by: niloc on June 18, 2016, 04:10:14 am
Wow it worked! :D :D :D

Nice job!
Title: Re: HTTP ERROR 500 when clicking "Layout" in Admin area (1.1)
Post by: emanuele on June 18, 2016, 05:54:01 am
No, that's not a fix, it's just to confirm where the issue is.
Now, restore that line the way it was.
Open sources/subs/ManageFeatures.subs.php, close to the end there is this block:
Code: [Select]
	$glob = new GlobIterator(CONTROLLERDIR . '/*.controller.php', FilesystemIterator::SKIP_DOTS);
$classes += scanFileSystemForControllers($glob);

$glob = new GlobIterator(ADDONSDIR . '/*/controllers/*.controller.php', FilesystemIterator::SKIP_DOTS);
$classes += scanFileSystemForControllers($glob, '\\ElkArte\\Addon\\');
Try commenting it out and see if you can reach the page.
Title: Re: HTTP ERROR 500 when clicking "Layout" in Admin area (1.1)
Post by: niloc on June 18, 2016, 06:01:59 am
Code: [Select]
//	$glob = new GlobIterator(CONTROLLERDIR . '/*.controller.php', FilesystemIterator::SKIP_DOTS);
// $classes += scanFileSystemForControllers($glob);

// $glob = new GlobIterator(ADDONSDIR . '/*/controllers/*.controller.php', FilesystemIterator::SKIP_DOTS);
// $classes += scanFileSystemForControllers($glob, '\\ElkArte\\Addon\\');

Alright done! It works once it's commented out.

So yeah good luck in your next step...  8)
Title: Re: HTTP ERROR 500 when clicking "Layout" in Admin area (1.1)
Post by: emanuele on June 18, 2016, 07:39:01 am
Restore the commented code and comment out only the first pair of lines:
Code: [Select]
	$glob = new GlobIterator(CONTROLLERDIR . '/*.controller.php', FilesystemIterator::SKIP_DOTS);
$classes += scanFileSystemForControllers($glob);
Title: Re: HTTP ERROR 500 when clicking "Layout" in Admin area (1.1)
Post by: niloc on June 18, 2016, 07:50:46 am
Yup it still works.
Title: Re: HTTP ERROR 500 when clicking "Layout" in Admin area (1.1)
Post by: emanuele on June 18, 2016, 08:34:25 am
Now, just to double check: restore the two commented lines and comment out the other two.

Just to reduce confusion (because I'm not sure myself what I wrote LOL), the final code should look like:
Code: [Select]
	$glob = new GlobIterator(CONTROLLERDIR . '/*.controller.php', FilesystemIterator::SKIP_DOTS);
$classes += scanFileSystemForControllers($glob);

// $glob = new GlobIterator(ADDONSDIR . '/*/controllers/*.controller.php', FilesystemIterator::SKIP_DOTS);
// $classes += scanFileSystemForControllers($glob, '\\ElkArte\\Addon\\');
Title: Re: HTTP ERROR 500 when clicking "Layout" in Admin area (1.1)
Post by: niloc on June 18, 2016, 10:29:25 am
Oh jeez.. it crashed. Error 500. :p

So yup those two lines are the culprit :@
Title: Re: HTTP ERROR 500 when clicking "Layout" in Admin area (1.1)
Post by: emanuele on June 18, 2016, 11:57:44 am
Good.
Now, let's assume the iterator is fine and it crashes at some point during the scanning.
Try changing:
Code: [Select]
	foreach ($iterator as $file)
{
$class_name = $namespace . preg_replace('~([^^])((?<=)[A-Z](?=[a-z]))~', '$1_$2', $file->getBasename('.controller.php')) . '_Controller';
to:
Code: [Select]
	foreach ($iterator as $file)
{
echo $glob->getFilename() . '<br>';
Errors::instance()->log_error($file->getFilename());
$class_name = $namespace . preg_replace('~([^^])((?<=)[A-Z](?=[a-z]))~', '$1_$2', $file->getBasename('.controller.php')) . '_Controller';

it we are lucky the last showed/logged is the problematic file.
If you don't see anything accessing the page, try looking in the error log.
Title: Re: HTTP ERROR 500 when clicking "Layout" in Admin area (1.1)
Post by: niloc on June 19, 2016, 02:07:27 am
Notice: Undefined variable: glob
@ index.php?action=admin;area=featuresettings;sa=layout;PGafAYj35W=da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny

File:
/sources/subs/ManageFeatures.subs.php
Line: 845



Here you go!
Title: Re: HTTP ERROR 500 when clicking "Layout" in Admin area (1.1)
Post by: emanuele on June 19, 2016, 02:25:29 am
Sorry, my typo:
Code: [Select]
echo $glob->
should be:
Code: [Select]
$file->
Title: Re: HTTP ERROR 500 when clicking "Layout" in Admin area (1.1)
Post by: niloc on June 19, 2016, 02:46:28 am
Well.. well.. well..

A whole boatload of errors:



Today at 02:42:15 PM
 
da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny
Type of error: General
Markasread.controller.php
 index.php?action=admin;area=featuresettings;sa=layout;PGafAYj35W=da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny      
 
Today at 02:42:15 PM
 
da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny
Type of error: General
MarkRead.controller.php
 index.php?action=admin;area=featuresettings;sa=layout;PGafAYj35W=da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny      
 
Today at 02:42:15 PM
 
da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny
Type of error: General
Likes.controller.php
 index.php?action=admin;area=featuresettings;sa=layout;PGafAYj35W=da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny      
 
Today at 02:42:15 PM
 
da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny
Type of error: General
Karma.controller.php
 index.php?action=admin;area=featuresettings;sa=layout;PGafAYj35W=da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny      
 
Today at 02:42:15 PM
 
da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny
Type of error: General
Jslocale.controller.php
 index.php?action=admin;area=featuresettings;sa=layout;PGafAYj35W=da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny      
 
Today at 02:42:15 PM
 
da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny
Type of error: General
Help.controller.php
 index.php?action=admin;area=featuresettings;sa=layout;PGafAYj35W=da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny      
 
Today at 02:42:15 PM
 
da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny
Type of error: General
Groups.controller.php
 index.php?action=admin;area=featuresettings;sa=layout;PGafAYj35W=da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny      
 
Today at 02:42:15 PM
 
da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny
Type of error: General
Emailuser.controller.php
 index.php?action=admin;area=featuresettings;sa=layout;PGafAYj35W=da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny      
 
Today at 02:42:15 PM
 
da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny
Type of error: General
Emailpost.controller.php
 index.php?action=admin;area=featuresettings;sa=layout;PGafAYj35W=da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny      
 
Today at 02:42:15 PM
 
da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny
Type of error: General
Draft.controller.php
 index.php?action=admin;area=featuresettings;sa=layout;PGafAYj35W=da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny      
 
Today at 02:42:15 PM
 
da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny
Type of error: General
Display.controller.php
 index.php?action=admin;area=featuresettings;sa=layout;PGafAYj35W=da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny      
 
Today at 02:42:15 PM
 
da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny
Type of error: General
Calendar.controller.php
 index.php?action=admin;area=featuresettings;sa=layout;PGafAYj35W=da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny      
 
Today at 02:42:15 PM
 
da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny
Type of error: General
BoardIndex.controller.php
 index.php?action=admin;area=featuresettings;sa=layout;PGafAYj35W=da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny      
 
Today at 02:42:15 PM
 
da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny
Type of error: General
Auth.controller.php
 index.php?action=admin;area=featuresettings;sa=layout;PGafAYj35W=da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny      
 
Today at 02:42:15 PM
 
da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny
Type of error: General
Attachment.controller.php
 index.php?action=admin;area=featuresettings;sa=layout;PGafAYj35W=da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny      
 
Today at 02:42:15 PM
 
da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny
Type of error: General
Announce.controller.php
 index.php?action=admin;area=featuresettings;sa=layout;PGafAYj35W=da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny
Title: Re: HTTP ERROR 500 when clicking "Layout" in Admin area (1.1)
Post by: emanuele on June 19, 2016, 06:46:52 am
Code: [Select]
da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny
Type of error: General
Markasread.controller.php
 index.php?action=admin;area=featuresettings;sa=layout;PGafAYj35W=da9ffq3mkmmGqEg5JrbzNz2lHhGTBRny
This is is.

Markasread.controller.php has been "recently" renamed to Markread.controller.php, so the file left in place is crashing the system.
I'd consider indeed that a bug.
The "quick fix" is to simply delete the file.
Title: Re: HTTP ERROR 500 when clicking "Layout" in Admin area (1.1)
Post by: niloc on June 20, 2016, 12:16:05 am
Oooh.. I see.. So all I need to do is to delete "Markasread.controller.php" under Sources/Controller, right?

Alright, done and it works as expected! :D Nice!