Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

[SOLVED] Upgrade from 7.02.07 - No database upgrade available

Hi folks,

I've cloned my main server and am running tests of the upgrade from 7.02.07 >> 9.0 RC1.

After copying the upgrade files to the php-fusion root (merging and replacing files as requested), I had to first edit locale/English/setup.php @ around line 310:

ORIGINAL CODE
CodeDownload  
// Make checks on new files that comes with 9
//if (file_exists(LOCALE."user_fields/user_timezone.php")) {
  require_once("user_fields/user_timezone.php");
//}
//if (file_exists(LOCALE."user_fields/user_blacklist.php")) {
  require_once("user_fields/user_blacklist.php");
//}



ALTERED CODE
CodeDownload  
// Make checks on new files that comes with 9
if (file_exists(LOCALE."user_fields/user_timezone.php")) {
  require_once("user_fields/user_timezone.php");
}
if (file_exists(LOCALE."user_fields/user_blacklist.php")) {
  require_once("user_fields/user_blacklist.php");
}



This was necessary to resolve a WSOD caused by a fatal 500 error as my PHP-Fusion 7 install does not have user_timezone.php as it does not come with PHP-Fusion 7.02.07. Once the if statements were uncommented I was able to proceed.

However once I proceed, I simply get "There is no database upgrade available." and cannot continue with the upgrade procedure.
You are right, they were actually commented at some point, Can you please test the attached version of the upgrade and see if it behaves for you?
You do not have access to view attachments
That behaved much better Domi, thank you. However I don't ever seem to hit 'case4' where the actual database upgrade is performed. Perhaps it was performed after maintenance was available but was too quick.. but I never saw any of the messages I that I see in this code block:

CodeDownload  
         case 4:
            $content .= "<div class='admin-message'>\n";
            $content .= "<p>Several changes will be made to the database.</p>\n";
            $content .= "<div class='alert alert-warning'></i>We strongly recommend that you make a <a target='_blank' href='db_backup.php".$aidlink."'>Database Backup</a> before proceeding!</div>\n";
            $content .= "</div>\n";
            $disabled = FALSE; // true to disable.
            $content .= "<input type='hidden' name='stage' value='".($disabled ? 5 : 4)."'>\n";
            $content .= "<input type='submit' name='upgrade_database' value='Upgrade Database' class='button btn btn-primary'><br /><br />\n";
            if (!$disabled && isset($_POST['upgrade_database'])) {
               // @todo: upgrade package shall be rolled out automatically
               include "upgrade/upgrade-7.02-9.00.php";
               dbquery("UPDATE ".DB_SETTINGS." SET settings_value='9.00.00' WHERE settings_name='version'");
               echo "<div class='admin-message'>The database was upgraded.</div>";
               redirect(FUSION_SELF.$aidlink."&amp;upgrade_ok");
            }
            break;




What I got was:

- Add additional lines to config.php and enable PDO
- Enable maintenance mode and backup database.
- Move gallery and forum files.
- "No database upgrade is available" and the 'Move forum files' button never goes away.
Ok I kept working with this. I started from scratch and wound up with the same result. Additionally the .htaccess file is never created as the update script says it will be.

I made an attempt to move forward, thinking that maybe it updated the database and just didn't give me a message. So I copied the files in place after removing infusions, etc... and I got a WSOD with this error:

CodeDownload  
[Fri Dec 25 06:31:53.946919 2015] [:error] [pid 5630] [client 192.168.51.8:51491] PHP Fatal error:  Class 'PHPFusion\\Database\\DatabaseFactory' not found in /var/www/html/includes/core_resources_include.php on line 40, referer: http://dev.amateurwriting.net/administration/index.php?aid=4b9ae0e3fbca1f0f&pagenum=3



Any suggestions you have are appreciated. Also I can blow this clone away and start from scratch at any point.
Good to see some progress, Id try without PDO and see, there is something the DatabaseFactory is failing to load, your server need to have support for PDO installed in order to have it operational.
Tried without PDO and I have the same error. Also, my server has PDO support installed:

CodeDownload  
Package php-pdo-5.4.16-36.el7_1.x86_64 already installed and latest version



Server is CentOS 7 with latest updates.
It looks good to me, I read the error more carefully now and it seems that the DatabaseFactory class is not found on your server.
Regarding messages, once the databases are completed it should redirect you back to maintain screen with no message to follow.
It need to do that because of the new tokens in config vs db updates.

Do you have a chance to try a clean installation?
That way we have a chance to differ the issue from upgrade or general DatabaseFactory issue on Cent Os 7 with your pack.
Hi, sorry about this. But lets try manual method to solve this bit of puzzle. Each server is configured differently, and so I can't make a wild guess how to troubleshoot it correctly unless I have look into your server personally.

However, it seems that by:

CodeDownload  

[Fri Dec 25 06:31:53.946919 2015] [:error] [pid 5630] [client 192.168.51.8:51491] PHP Fatal error:  Class 'PHPFusion\\Database\\DatabaseFactory' not found in /var/www/html/includes/core_resources_include.php on line 40, referer: http://dev.amateurwriting.net/administration/in...;pagenum=3



Means that you can't get to DatabaseFactory. loaded. Please check autoloader.php in includes folder. and dump the $filePath to see if it passes the is_file check. If file is successfully loaded, the class should exist and everything should resume normal for you.

Hope it helps.
Ok I'm now attempting a new installation. It's failing to load the install page.

I've dug through the documentation for this release and there is little to no mention of dependencies:

CodeDownload  
Requirements for this version
- PHP 5.3 or higher
- MySQL 4.1 or higher



Certainly, PDO is not mentioned. So I'm guessing there are other mystery dependencies as well.

Currently this is what I'm getting:

CodeDownload  
Fatal error: Class 'PHPFusion\OutputHandler' not found in /var/www/html/install/setup_includes.php on line 37



Looking at that line, this is what is being called:

CodeDownload  
$fusion_page_head_tags = &\PHPFusion\OutputHandler::$pageHeadTags;



I dug through the files and found ./includes/classes/PHPFusion/OutputHandler.php -- There are no permissions issues on the files. It seems PHP cannot load any of the classes in the new PHP-Fusion.
@Hein - Sorry I missed your reply. Checking your steps now.
@Hein: Autoloader exists in both my upgrade attempt and the new installation attempt. I ran an interactive PHP shell and checked the file as you requested, it returns true:

CodeDownload  

[root@upgradetest includes]# php -a
Interactive shell
php > echo is_file("/var/www/html/includes/autoloader.php");
1



I believe this is what you've asked for.
Took this a step further and ran this from the PHP shell from within the includes directory:

CodeDownload  

php > $path = str_replace('\\', DIRECTORY_SEPARATOR, 'PHPFusion\OutputHandler');
php > $fullPath = $baseDir.$path.'.php';
php > echo $fullPath;
/var/www/newinstall/includes/classes/PHPFusion/OutputHandler.php
php > echo is_file($fullPath);
1




So it seems to me that the path is not the issue, as this is what I would expect it to return. It seems more like autoloader is not being called.
Thats the reason why DatabaseFactory was not loaded. the script that calls autoloader is at core_resource_include.php itself with __DIR__."/autoloader.php", from another file it is - INCLUDES."autoloader.php";
CodeDownload  

So it seems to me that the path is not the issue, as this is what I would expect it to return. It seems more like autoloader is not being called.



Please troubleshoot the server's virtual host and see what both _DIR_ and BASEDIR is. Both need to path correctly.
I'm not sure what you expect me to try here. __DIR__ and BASEDIR are not configurable. They are take from the current directory of the script and the root directory of the virtual host. If BASEDIR was incorrect the virtual host wouldn't hit index.php in the root of the installation (which it does) - and if __DIR__ was not set correctly then the previous test I ran would not have produced the correct result.
Actually I'm incorrect. BASEDIR isn't an Apache variable at all. It's a PHP fusion variable. You set it in your code on line 23:

CodeDownload  
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) PHP-Fusion Inc
| https://www.php-fusion.co.uk/
+--------------------------------------------------------*
| Filename: install/index.php
| Author: PHP-Fusion Development Team
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
define("IN_FUSION", TRUE);
use PHPFusion\Database\DatabaseFactory;
use PHPFusion\Authenticate;

ini_set('display_errors', 1);
define('BASEDIR', '../');
require_once 'setup_includes.php';



..Right before you include setup_includes.php. Also note that the two classes you call before autoloader work without issue.

I'm no longer trying the upgrade until I see that a fresh install works. And it's still failing.
Interestingly, there is something definitely to Apache being at fault here.. when I run the code from install.php in an interactive shell, the setup_includes.php does not break on line 37, it works. It seems to only fail from within Apache...

CodeDownload  
[root@upgradetest install]# php -a
Interactive shell

php >
php > define("IN_FUSION", TRUE);
php >
php > use PHPFusion\Database\DatabaseFactory;
php >
php > use PHPFusion\Authenticate;
php > ini_set('display_errors', 1);
php >
php > define('BASEDIR', '../');
php >
php > require_once 'setup_includes.php';
PHP Notice:  Undefined index: REMOTE_ADDR in /var/www/newinstall/includes/core_constants_include.php on line 44

Notice: Undefined index: REMOTE_ADDR in /var/www/newinstall/includes/core_constants_include.php on line 44
PHP Notice:  Undefined index: REMOTE_ADDR in /var/www/newinstall/includes/core_constants_include.php on line 46

Notice: Undefined index: REMOTE_ADDR in /var/www/newinstall/includes/core_constants_include.php on line 46
php > exit

Aha, I got it.

It would appear that VirtualHosts are required for PHP-Fusion 9.0 with Apache.

With PHP-Fusion 7 and below, I always just put my install in the default document root of Apache as I use Virtual Machines or self built private servers to host my site. I've never had to use a VirtualHost definition to make it work, and have never had a use for them as I only have one site per server.

It seems that this messes with the autoloader. Installer is working now. I'm going to test a fresh installation and then wipe the server and test an upgrade. I'll report back once done.
I did some tinkering for you.
Hien talked about virtual dir and or apache environment not routing the __DIR__ paths correcty
What we can do is bypass it as a whole in the includes/autoloader.php like ,

CodeDownload  
spl_autoload_register(function ($className) {
   $baseDir = $_SERVER['DOCUMENT_ROOT'].'/includes/classes/';
   $path = str_replace('\\', DIRECTORY_SEPARATOR, $className);
   $fullPath = $baseDir.$path.'.php';
   if (is_readable($fullPath)) {
      require $fullPath;
   }
});
/*
 * Autoloader for compatibility reason
 *
 * It loads only classes from ClassName.class.php in global namespace
 */
spl_autoload_register(function ($className) {
   if (strpos($className, '\\') !== FALSE) {
      return;
   }
   $baseDir = $_SERVER['DOCUMENT_ROOT'].'/includes/classes/';
   $fullPath = $baseDir.$className.'.class.php';
   if (is_readable($fullPath)) {
      require $fullPath;
   }
});



If you are unsure on the real path just do an
echo $_SERVER['DOCUMENT_ROOT'];

Above the first function and it should echo it for you.

Now lets say you see usr/bin/public_html
then it is correct. But if you site is in usr/bin/public_html/test
you need to add it to the $_SERVER['DOCUMENT_ROOT'] with
$baseDir = $_SERVER['DOCUMENT_ROOT'].'/test/includes/classes/';

Hope it helps.
Thread Information
Author
Replies
36 posts
Views
3,931 times
Last Post
Last updated on 4 years ago
You can view all discussion threads in this forum.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You cannot download attachments in this forum.