Page 1 of 2
Admin page returns 404 error
Posted: Fri May 03, 2019 7:19 pm
by Sammyskills
Hi,
I recently upgraded my store from version 3.0.2.0 to the latest 3.0.3.0, without overwriting the config.php and admin/config.php files. Now, when I log in to my admin area, it shows a 404 page not found error.
Before the upgrade, mails were not been sent out to customers (upon registration) and also an admin (when an order is placed). I also found out that if I click on the Modification menu, under Extensions, it returns a 404 page not found error, likewise when I try to update some settings via System>>Settings. So, I felt upgrading to the latest version would resolve all the issues.
But now, I can't even view the admin page. It is returning a 404 error.
Re: Admin page returns 404 error
Posted: Fri May 03, 2019 7:50 pm
by straightlight
Check your error / server access logs regarding the 404 error codes. Since you don't have access to the admin (or partial access), you can also look in your storage/logs folder for your error logs.
Re: Admin page returns 404 error
Posted: Fri May 03, 2019 9:03 pm
by Sammyskills
Thanks for the reply.
I have checked through the storage folder: storage/logs/error.log and there are a lot of errors I see there:
Code: Select all
2019-05-03 10:57:47 - PHP Warning: sizeof(): Parameter must be an array or an object that implements Countable in /home/****/storage/modification/admin/controller/common/dashboard.php on line 12
What could be the cause of this error + how do I resolve it?
Re: Admin page returns 404 error
Posted: Fri May 03, 2019 9:10 pm
by straightlight
See if the same issue can be reproduced with OC v3.0.3.2 in a test environment. I haven't seen this report as a frequent incident on the forum. Also, which PHP version are you using?
Re: Admin page returns 404 error
Posted: Fri May 03, 2019 9:39 pm
by Sammyskills
I have been able to resolve the admin login issue. It was a php version problem.
I downgraded to version 7.0, now I can log in to the store admin.
But the former problem is still there:
- When I click on Extensions >> Modification, it returns a 404 error page
- When I click on System >> Settings, and save, it returns a 404 error page
What can I do??
Re: Admin page returns 404 error
Posted: Fri May 03, 2019 9:50 pm
by straightlight
What can I do??
Check your error logs!
Re: Admin page returns 404 error
Posted: Fri May 03, 2019 9:53 pm
by Sammyskills
Where exactly?
public_html/error.log is empty.
public_html/admin/error.log is also empty.
Where else can I check?
Re: Admin page returns 404 error
Posted: Fri May 03, 2019 10:06 pm
by straightlight
Sammyskills wrote: ↑Fri May 03, 2019 9:53 pm
Where exactly?
public_html/error.log is empty.
public_html/admin/error.log is also empty.
Where else can I check?
This post already mentions where else to check:
viewtopic.php?f=199&t=211540#p754061
Re: Admin page returns 404 error
Posted: Fri May 03, 2019 10:09 pm
by Sammyskills
The storage >> logs >> error.log is also empty.
Is there a place I'm missing?
Re: Admin page returns 404 error
Posted: Fri May 03, 2019 10:43 pm
by straightlight
Check your server access logs in your FTP root folder under: access_logs or the logs folder. Recent activities should be listed there. If not, check your host console under the logs icon. Forum rules.
Re: Admin page returns 404 error
Posted: Sat May 04, 2019 4:40 pm
by Sammyskills
I've checked all the logs you mentioned, but nothing seems to point out where the error is coming from.
So, I decided to do a fresh install in a sub-directory. After the installation, when I click on System >> Settings and click on the "Save" button, it returns a 404 page not found error.
I have PHP 7 installed in my server.
Please, is there something my server is missing that could be causing this error?
Re: Admin page returns 404 error
Posted: Sat May 04, 2019 8:59 pm
by straightlight
So far, it looks like an SSL configuration issue or from your .htaccess file. You can either contact your host to get this resolved or create a new service request in the Commercial Support section of the forum to get this issue fixed as a custom job.
Re: Admin page returns 404 error
Posted: Sat May 04, 2019 9:19 pm
by IP_CAM
This countable problem has been seen before, it's some
routine, not yet made work with PHP v.7.2x in some Versions.
I had it once in this (model/module/module.php) File:
Code: Select all
foreach($modules as $module){
foreach($module as $array){
// if(count($array[0]) > 0 && is_array($array)){
if (is_array($array) && count($array[0]) > 0) {
for($i = 0; $i<count($array[0]); $i++){
if( isset($array[0][$i]['layout_id']) ){
$ms[$array[0][$i]['layout_id']][] = array("name"=> $module['name'], "position" => $array[0][$i]['position']);
}
}
}
}
}
Google is full of it.
https://php.net/manual/en/function.count.php
viewtopic.php?t=210541
https://themeforest.net/item/journal-ad ... s?page=462
https://stackoverflow.com/questions/523 ... t-implemen
Re: Admin page returns 404 error
Posted: Sun May 05, 2019 2:24 am
by straightlight
Code: Select all
foreach($modules as $module){
foreach($module as $array){
// if(count($array[0]) > 0 && is_array($array)){
if (is_array($array) && count($array[0]) > 0) {
for($i = 0; $i<count($array[0]); $i++){
if( isset($array[0][$i]['layout_id']) ){
$ms[$array[0][$i]['layout_id']][] = array("name"=> $module['name'], "position" => $array[0][$i]['position']);
}
}
}
}
}
should be changed to:
Code: Select all
$ms = array();
foreach($modules as $module) {
foreach($module as $array) {
if (!empty($array[0]) && is_array($array[0])) {
foreach ($array[0] as $module_value) {
if (!empty($module_value['layout_id'])) {
$ms[$module_value['layout_id']][] = array('name' => $module['name'],
'position' => $module_value['position'],
);
}
}
}
}
}
Re: Admin page returns 404 error
Posted: Sun May 05, 2019 4:42 am
by IP_CAM
By use of the above, everything tested worked, it even told me, that an 'orphan' file still
resides in the Admin Module Section. But going back to Home, that's, what I got, in the
last (new) code line left curly '
}' of the File.

Re: Admin page returns 404 error
Posted: Sun May 05, 2019 4:44 am
by straightlight
Missing ended bracket. Code fixed on the above.
Re: Admin page returns 404 error
Posted: Sun May 05, 2019 7:37 am
by IP_CAM
Well done!

I still don't know, what purpose this file serves. It was
part of PEKU's OC2 Theme to 1.5.6.x Mod and EDGE Version, and it
failed to work with PHP-7.x, as it came by PEKU default, that's, why
I know, that it exists ...
Ernie
Re: Admin page returns 404 error
Posted: Sun May 05, 2019 11:32 am
by straightlight
The reason why this code was obviously failing was due to the genius who did this with a count / sizeof function without validating the array knowing if it's empty or not before verifying if the get type was an array as the count / sizeof function is not a necessity in this case.
Re: Admin page returns 404 error
Posted: Sun May 05, 2019 1:12 pm
by IP_CAM
It was not the only one, later OC-Versions had the same problem,
after moving up in PHP Version. And I at least found a Solution.

Colorblind Coders have to take n'use, what exists, regardless of, if
it comes in light-brown or dark-green Color, as long as it works ...

Ernie
Re: Admin page returns 404 error
Posted: Sun May 24, 2020 11:49 pm
by nightwing
I momentarily get these errors as well, being logged like 40 times in a 2 minute span.
Code: Select all
2020-05-24 5:19:32 - PHP Warning: count(): Parameter must be an array or an object that implements Countable in /public_html/system/library/template/Twig/Extension/Core.php on line 1266
In that file I have:
Code: Select all
// add multibyte extensions if possible
if (function_exists('mb_get_info')) {
/**
* Returns the length of a variable.
*
* @param Twig_Environment $env A Twig_Environment instance
* @param mixed $thing A variable
*
* @return int The length of the value
*/
function twig_length_filter(Twig_Environment $env, $thing)
{
return is_scalar($thing) ? mb_strlen($thing, $env->getCharset()) : count($thing);
}
Hi Straight is it possible that it could be the same senario as module.php that you resolved above?
Regards,
Night