Error while upgrading from 1.9.10.2 to 1.11.0. Fixed by migration to 1.11.2
I tried to upgrade our installation from 1.9.10.2 to 1.10.2. This failed with errors and other issues.
After restoration of 1.9.10.2, database included, we tried to upgrade directly from 1.9.10.2 to 1.11.0, by unpacking 1.11 over 1.9.10.2 and running the web based installer, selecting 'Upgrade'.
This failed as well with the fatal error message below, indicating a missing column in the db.
Any ideas on what we can be do now would be very much appreciated.
` VERSION: 20160808110200 ---------------------------------------------- UPDATE c_forum_post SET post_parent_id = NULL WHERE post_parent_id = 0
DONE!
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054
Unknown column 'session_id' in 'where clause''
in /var/www/chamilo-lms-1.9.10.2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:104
Stack trace:
#0 /var/www/chamilo-lms-1.9.10.2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(104): PDO->query('UPDATE c_item_p...')
#1 /var/www/chamilo-lms-1.9.10.2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(833): Doctrine\DBAL\Driver\PDOConnection->query('UPDATE c_item_p...')
#2 /var/www/chamilo-lms-1.9.10.2/main/install/install.lib.php(2192): Doctrine\DBAL\Connection->executeQuery('UPDATE c_item_p...')
#3 /var/www/chamilo-lms-1.9.10.2/main/install/install.lib.php(2962): fixIds(Object(Doctrine\ORM\EntityManager))
#4 /var/www/chamilo-lms-1.9.10.2/main/install/index.php(756): migrateSwitch('1.9.10', Object(Doctrine\ORM\EntityManager))
#5 {main}
Next exception 'Doctrine\DBAL\Driver\PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054
Un in /var/www/chamilo-lms-1.9.10.2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php on line 71
`
System info: chamilo-lms-1.9.10.2 php-5.4.16 mariadb-5.5.50 httpd-2.4.6 centos-release-7 Linux 3.10.0-327.36.1.el7.x86_64
Url when failing: http://localhost/main/install/index.php?running=1&installType=update&updateFromConfigFile=main%2Finc%2Fconf%2Fconfiguration.php
Did you download the last version of 1.11.x from github?
Did you download the last version of 1.11.x from github?
Yes, I suppose so. I used https://github.com/chamilo/chamilo-lms/releases/download/v1.11.0/chamilo-lms-1.11.0.tar.gz having a md5sum of 42579edf135aa47c57a35575a3bad9a7 is what I have at hand.
The installation was pretty straight forward: $ tar -xzf chamilo-lms-1.11.0.tar.gz $ cd chamilo-lms-1.11.0 $ tar -cf /tmp/junk.tar .
cd /var/www/chamilo-lms-1.9.10.2
tar -xf /tmp/junk.tar .
find . -exec chown apache.apache "{}" ";"
find . -type d -exec chmod 775 "{}" ";"
find . -type f -exec chmod 664 "{}" ";"
$ firefox http://localhost/
That package doesn't have the latest code.
You can try with this one https://github.com/chamilo/chamilo-lms/archive/1.11.x.zip It's the latest code from 1.11.x. But it requires to install the vendors folders using composer.
We will release version 1.11.2 to solve a series of issues with the upgrades in a few days. We've been testing a lot of different situations, but obviously not enough. Softaculous also reported issues with the upgrade.
Restored 1.9.10.2 and db again. Works. Unpacked the mentioned 1.11.x.zip over 1.9.10.2, fixed permissions. Now loading http://localhost/ provides a blank screen instead of the installation page. The following error message is provided in the apache error log:
[Tue Oct 25 18:58:27.457745 2016] [:error] [pid 28419] [client 127.0.0.1:60182] PHP Fatal error: Class 'Symfony\\Component\\HttpKernel\\Kernel' not found in /var/www/chamilo-lms-1.9.10.2/app/AppKernel.php on line 12
I know nothing of the composer thing ...
You can either learn about the "composer thing" (which is really a MUST-learn in PHP development nowadays) by reading the 1.11.x README.md or, alternatively, wait for the release of 1.11.2 later this week, which should fix those migration issues.
@jmontoyaa did you check if the bug reported by @simbulu was already fixed in 1.11.x?
@ywarnier When I run an upgrade I didnt have that error. c_item_property has the session_id. The change was added in file Version110.php
In our database as of 1.9.10.2 id_session exists in c_item_property, session_rel_course, session_rel_course_rel_user and session_rel_user.
Got my hands on composer and let the webuser run 'composer update' in /var/www/chamilo-1.9.10.2 Thanks @ywarnier for the hint about composer :-)
Now http://localhost/ shows the installation screen. Taking the upgrade path we got the same fatal php error:
Update-db script: memory_limit set to -1
Update-db script: max_execution_time 0
Starting migration process from 1.9.10 (2016-10-26 11:44:32)
Migrations files were executed.
fixIds,
PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'session_id' in 'where clause'' in /var/www/chamilo-lms-1.9.10.2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:104
Stack trace:
#0 /var/www/chamilo-lms-1.9.10.2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver PDOConnection.php(104): PDO->query('UPDATE c_item_p...')
#1 /var/www/chamilo-lms-1.9.10.2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(833): Doctrine\\DBAL\\Driver\\PDOConnection->query('UPDATE c_item_p...')
#2 /var/www/chamilo-lms-1.9.10.2/main/install/install.lib.php(2192): Doctrine\\DBAL\\Connection->executeQuery('UPDATE c_item_p...')
#3 /var/www/chamilo-lms-1.9.10.2/main/install/install.lib.php(2962): fixIds(Object(Doctrine\\ORM\\EntityManager))
#4 /var/www/chamilo-lms-1.9.10.2/main/install/index.php(756): migrateSwitch('1.9.10', Object(Doctrine\\ORM\\EntityManager))
#5 {main}
Next exception 'Doctrine\\DBAL\\Driver\\PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Un in /var/www/chamilo-lms-1.9.10.2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php on line 71, referer: http://localhost/main/install/index.php?running=1&installType=update&updateFromConfigFile=main%2Finc%2Fconf%2Fconfiguration.php
And rightfully c_item_property still has id_session rather than session_id, which might indicate that up() in Version110.php has not been called in due time, which might be prior to up() in Version20150603181728.php which I think triggers the error.
The line that should fix the issue might be in app/Migrations/Schema/V110/Version110.php as mentioned by @jmontoyaa
$this->addSql("ALTER TABLE c_item_property CHANGE id_session session_id int");
The line that triggers the error might be app/Migrations/Schema/V110/Version20150603181728.php :
$this->addSql('UPDATE c_item_property SET session_id = NULL WHERE session_id = 0');
Can we fix this somehow ?
After that failed migration what's the status of "c_item_property"?
in mysql > describe c_item_property;
c_item_property seems unchanged to me as id_session is still around.
MariaDB [chamilo]> describe c_item_property;
+------------------+------------------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+------------------+------+-----+---------------------+----------------+
| c_id | int(11) | NO | PRI | NULL | |
| id | int(11) | NO | PRI | NULL | auto_increment |
| tool | varchar(100) | NO | MUL | | |
| insert_user_id | int(10) unsigned | NO | | 0 | |
| insert_date | datetime | NO | | 0000-00-00 00:00:00 | |
| lastedit_date | datetime | NO | | 0000-00-00 00:00:00 | |
| ref | int(11) | NO | | 0 | |
| lastedit_type | varchar(100) | NO | | | |
| lastedit_user_id | int(10) unsigned | NO | | 0 | |
| to_group_id | int(10) unsigned | YES | MUL | NULL | |
| to_user_id | int(10) unsigned | YES | | NULL | |
| visibility | tinyint(4) | NO | | 1 | |
| start_visible | datetime | NO | | 0000-00-00 00:00:00 | |
| end_visible | datetime | NO | | 0000-00-00 00:00:00 | |
| id_session | int(11) | NO | | 0 | |
+------------------+------------------+------+-----+---------------------+----------------+
15 rows in set (0.00 sec)
And can you do (after failed migration)
select * from version
It's very weird your table has no changed after "Migrations files were executed".
And even 110 is present in version:
MariaDB [chamilo]> select * from version;
+----------------+
| version |
+----------------+
| 110 |
| 20150423093100 |
| 20150504182600 |
| 20150505132304 |
| 20150505142900 |
| 20150507152600 |
| 20150511133949 |
| 20150519153200 |
| 20150521113600 |
| 20150522112023 |
| 20150522222222 |
| 20150527101600 |
| 20150527114220 |
| 20150527120703 |
| 20150528103216 |
| 20150529164400 |
| 20150603142550 |
| 20150603151200 |
| 20150603181728 |
| 20150604145047 |
| 20150608104600 |
| 20150609113500 |
| 20150610143426 |
| 20150615171900 |
| 20150616093200 |
| 20150624164100 |
| 20150625155000 |
| 20150706135000 |
| 20150709083710 |
| 20150713132630 |
| 20150803163400 |
| 20150803171220 |
| 20150805161000 |
| 20150810132615 |
| 20150812230500 |
| 20150813143000 |
| 20150813200000 |
| 20150819095300 |
| 20150821150000 |
| 20150825141100 |
| 20151101082200 |
| 20151101082300 |
| 20151119082400 |
| 20151214164000 |
| 20151214170800 |
| 20151221150100 |
| 20160707131900 |
| 20160808110200 |
+----------------+
48 rows in set (0.10 sec)
Are you sure the table "version" didn't exist before the migration?
Just upgraded a 1.10.x site to 1.11.x with git but that is not without trouble.
The "composer update" is realy important after "git checkout 1.11.x".
Then the main/install/index.php page will do the update process but if I do a check with "php bin/doctrine.php orm:schema-tool:update --dump-sql " I see 97 more database changes!
How can that be and is there a way to do the update with CLI without the install/index.php web page?
A simple db change can take a long time: mysql> ALTER TABLE message ADD votes INT DEFAULT NULL, CHANGE update_date update_date DATETIME DEFAULT NULL; Query OK, 0 rows affected (13 min 41.53 sec)
@jmontoyaa You are great, and please forgive me my ignorance. The table 'version' does not exist in 1.9, but it did, in this case, exist fully populated prior to the latest migrations. This made the migration fail. The reason was the restoration of the database which needed a 'drop database chamilo;' before a 'mysql<mysqldump'. After this modification the migration to v1.11.2 (v1.11.2.tar.gz which is the same as chamilo-lms-1.11.2.tar.gz), within two hours, completed successfully.
Some minor issues were present like four php notices of 'Undefined variable' (new_version, new_version_stable, software_name and software_url in update-configuration.inc.php) and a little issue with "Display Errors" which is OFF, but the installer somehow reads as ON.
While everything looked great, on the front page, we got another fatal php error after going to the main page. By entering credentials and trying to login we get a blank page and a message in the apache error log:
[Wed Nov 02 17:34:01.463846 2016] [:error] [pid 32118] [client 127.0.0.1:51574]
PHP Fatal error:
Uncaught exception 'ReflectionException' with message 'Property Chamilo\\UserBundle\\Entity\\User::$chatcallUserId does not exist' in /var/www/chamilo-lms-1.9.10.2/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php:80
Stack trace:
#0 /var/www/chamilo-lms-1.9.10.2/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php(80): ReflectionProperty->__construct('Chamilo\\UserBun...', 'chatcallUserId')
#1 /var/www/chamilo-lms-1.9.10.2/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php(964): Doctrine\\Common\\Persistence\\Mapping\\RuntimeReflectionService->getAccessibleProperty('Chamilo\\UserBun...', 'chatcallUserId')
#2 /var/www/chamilo-lms-1.9.10.2/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php(721): Doctrine\\ORM\\Mapping\\ClassMetadataInfo->wakeupReflection(Object(Doctrine\\Common\\Persistence\\Mapping\\RuntimeReflectionService))
#3 /var/www/chamilo-lms-1.9.10.2/vendor/doctrine/common/lib/Doctrine/Common/Persistence in /var/www/chamilo-lms-1.9.10.2/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php on line 80
referer: http://localhost/index.php?language=english
Running 'composer update' after as well as prior to migration gave the same result, but
php bin/doctrine.php orm:clear-cache:metadata
cleared the error as mentioned in https://github.com/chamilo/chamilo-lms/issues/1480
So finally it seems we have a working upgraded version 1.11.2 up and running :-)
@jderriks:
The "composer update" is realy important after "git checkout 1.11.x".
Yes. Since the introduction of Composer into Chamilo (which improves greatly the way we manage dependencies), the "composer update" command (or at least "composer install") is something you might want to execute each time you update something through git.
Note that the "git checkout 1.11.x" itself might not work without issues, depending on the state (whether pristine or not) of your initial branch.
Then the main/install/index.php page will do the update process but if I do a check with "php bin/doctrine.php orm:schema-tool:update --dump-sql " I see 97 more database changes! How can that be and is there a way to do the update with CLI without the install/index.php web page?
@jmontoyaa should be reviewing the "chash" project (parallel to the chamilo-lms project) this week. This is a command line tool to execute a series of management operations. It is not yet updated for 1.11, but we generally do that a few weeks after a major stable release.
A simple db change can take a long time: mysql> ALTER TABLE message ADD votes INT DEFAULT NULL, CHANGE update_date update_date DATETIME DEFAULT NULL; Query OK, 0 rows affected (13 min 41.53 sec)
Yes, it depends on:
- the size of the table (in rows),
- the server on which you run the operation (number of cores and memory available)
- the configuration of your MySQL server (memory available to put the entire table inside it while it's changing it)
- whether your table is InnoDB or not
- whether you have users connected to your system while upgrading (not recommended)
But yes, "message", "track_e_login", "track_e_course_access" and a series of other tables have a tendency to become enormous and take a long time to process structural changes.
The install-update page took 50 minutes(!) to update the 1.10.x database.
But why does php bin/doctrine.php orm:schema-tool:update --dump-sql keep telling me there are more changes like:
ALTER TABLE user CHANGE username username VARCHAR(100) NOT NULL, CHANGE username_canonical username_canonical VARCHAR(100) NOT NULL, CHANGE email email VARCHAR(100) NOT NULL, CHANGE email_canonic al email_canonical VARCHAR(100) NOT NULL, CHANGE credentials_expired credentials_expired TINYINT(1) NOT NULL, CHANGE locked locked TINYINT(1) NOT NULL;
?
@jderriks Our upgrade from 1.9.2 to 1.11.2 on a test server, with some 265+164 database changes, took two hours. Time is not an issue to us as long as things work as expected.
The original issue here was a failure to upgrade. This issue has been solved by now as described previously.
@jderriks: Could you issue a "SHOW CREATE TABLE user" on your database so we know what the current state of the table is? It is likely (if you previously proceeded to partial upgrades within different versions of 1.10.x) that some minor change was made that was later cancelled, but I'm not excluding the possibility of a remaining issue (although it shouldn't, really, because we made a table-by-table comparison and so did the Softaculous guys).