User tests: Successful: Unsuccessful:
Pull Request for Issue #30223 .
This pull request (PR) fixes an error from PR #17537 which has introduced database schema checker and fixer for extensions in Joomla 4.
The double error is that an arry index and not the value of an array which holds extension IDs is compared with the extension element value 'com_admin'.
This PR fixes it by using the element
property of the extensions
element of the previously obtained changeset
for the given extension ID.
Have a clean, current 4.0-dev branch or a 4.0 nightly or a Beta 3 with at least one extension installed, e.g. the patchtester.
Have error reporting set to "Maximum" in Global Configuration in server settings.
In your PHP settings, have display errors on or log errors on and log into a file.
Open file administrator/components/com_installer/src/Model/DatabaseModel.php
in an editor and go to following line:
https://github.com/joomla/joomla-cms/blob/4.0-dev/administrator/components/com_installer/src/Model/DatabaseModel.php#L264.
Before that line, add a line with debug output into the PHP log as follows:
error_log('Hello, I am com_admin');
or whatever else comes into your mind, so it finally looks like:
if ($i === 'com_admin')
{
error_log('Hello, I am com_admin');
$installer = new \JoomlaInstallerScript;
...
}
Go to "System -> Information -> Database".
Use the "Update Structure" button with each of the following combinations of selected check boxes and then check your PHP error log if there is the debug log you have added before with the preparation for the test.
a) Only some extension's check box selected, but not the one for "Joomla CMS" = the core.
b Only "Joomla CMS" = the core's check box selected, but not any other check box for any extension.
c) The check box for "Joomla CMS" and also one of some extension selected.
Result: See section "Actual result BEFORE applying this Pull Request" below.
Apply the patch of this PR.
Note: When using patchtester you might have to remove the debug log which you have added before in step 2, then apply the patch and after that add back the debug log, so it looks like:
if ($changeSet['extension']->element === 'com_admin')
{
error_log('Hello, I am com_admin');
$installer = new \JoomlaInstallerScript;
...
}
In all 3 cases a) to c) no debug log.
a) Only some extension's check box selected, but not the one for "Joomla CMS" = the core => No debug log.
b Only "Joomla CMS" = the core's check box selected, but not any other check box for any extension => Debug log.
c) The check box for "Joomla CMS" and also one of some extension selected => Debug log.
None.
Status | New | ⇒ | Pending |
Category | ⇒ | Administration com_installer |
But it's displayed for "Joomla CMS" extension (eid=208) where
element
isjoomla
. Is it correct to compareelement
ascom_admin
?
Here it is extension ID 213, which has element = 'com_admin. Maybe the difference is due to your update history? I have used a brand nex installation of current 4.0-dev branch. But you can check it yourself by adding some debug output like in my instructions, extended a bit, e.g. error_log('$i=' . $i . ', $cid=' . $cid . ', $changeSet[\'extension\']->element=' .$changeSet['extension']->element);
deleted a column ....
Surprisingly, clicking "Update Structure" helped even on the current beta3 code without patch applied (the column was re-created).
Well, that is how it shall work and is absolutely unrelated to this PR. The schema changes are done anway, with and without this PR. The only thing what the check for ' com_admin' is good for is to run additional utf8mb4 stuff for the core.
@Denitz You are right, it's weird that in database, the extension record has element
= 'joomla'. But could you test as described in the testing instructions, and if in doubt add the additional debug output which I've mentioned in my previous comment? Then you should see it my PR works or not. I think the reason is that the changeset of the core belongs to com_admin and not to joomla files which is used for display.
Just corrected testing instructions, now they are ok.
@richard67 I performed clean beta3 installation and performed the same trick with column removal.
eid is 213 and element is really 'joomla' but not com_admin
.
Schemas are checked via
SELECT `extensions`.`client_id`,`extensions`.`element`,`extensions`.`extension_id`,`extensions`.`folder`,`extensions`.`manifest_cache`,`extensions`.`name`,`extensions`.`type`,`schemas`.`version_id`
FROM `jos_schemas` AS `schemas`
INNER JOIN `jos_extensions` AS `extensions` ON `schemas`.`extension_id` = `extensions`.`extension_id`
#__schemas has a single record with extension_id = 213 which is files_joomla
. Hence, #__schemas are unrelated to com_admin at all.
But the load changeset really has element=com_admin even though extension_id is 213 which is not com_admin:
object(stdClass)[723]
public 'client_id' => int 0
public 'element' => string 'com_admin' (length=9)
public 'extension_id' => int 213
public 'folder' => string '' (length=0)
public 'manifest_cache' => string '{"name":"files_joomla","type":"file","creationDate":"July 2020","author":"Joomla! Project","copyright":"(C) 2005 - 2020 Open Source Matters. All rights reserved","authorEmail":"admin@joomla.org","authorUrl":"www.joomla.org","version":"4.0.0-beta3","description":"FILES_JOOMLA_XML_DESCRIPTION","group":""}' (length=304)
public 'name' => string 'Joomla CMS' (length=10)
public 'type' => string 'file' (length=4)
public 'version_id' => string '4.0.0-2020-05-29' (length=16)
public 'creationDate' => string 'July 2020' (length=9)
public 'author' => string 'Joomla! Project' (length=15)
public 'copyright' => string '(C) 2005 - 2020 Open Source Matters. All rights reserved' (length=56)
public 'authorEmail' => string 'admin@joomla.org' (length=16)
public 'authorUrl' => string 'www.joomla.org' (length=14)
public 'version' => string '4.0.0-beta3' (length=11)
public 'description' => string 'Joomla! 4 Content Management System.' (length=36)
public 'group' => string '' (length=0)
public 'author_info' => string 'admin@joomla.org<br>www.joomla.org' (length=34)
public 'client' => string 'Site' (length=4)
public 'client_translated' => string 'Site' (length=4)
public 'type_translated' => string 'File' (length=4)
public 'folder_translated' => string 'N/A' (length=3)
It's because of model code which auto-replaces element from joomla
to com_admin
to load the schema SQLs:
if (strcmp($result->element, 'joomla') === 0)
{
$result->element = 'com_admin';
if (!$this->getDefaultTextFilters())
{
$errorMessages[] = Text::_('COM_INSTALLER_MSG_DATABASE_FILTER_ERROR');
$errorCount++;
}
}
So, checking for element=com_admin is correct.
And: the patch works.
But: the utf8mb4 conversion is still executed if #__utf8_conversion table is found and the conversion will be never finished due to new #__history table.
But: the utf8mb4 conversion is still executed if #__utf8_conversion table is found and the conversion will be never finished due to new #__history table.
For fixing this you need my other PR #30227 .
So please test both as described and then mark the test results on the issue tracker by using the "Test this" button, selecting the appropriate test result and then submitting.
Issue tracker item for this PR: https://issues.joomla.org/tracker/joomla-cms/30233
Issue tracker item for the other PR: https://issues.joomla.org/tracker/joomla-cms/30227
Thanks in advance.
I have tested this item
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
RTC
Thanks guys for testing.
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-08-01 23:58:37 |
Closed_By | ⇒ | Quy | |
Labels |
Added:
?
?
|
I deleted a column in
#__content_frontpage
table, run the schema checker and see the problem:Table 'jos_content_frontpage' does not have column 'featured_down'. (From file 4.0.0-2019-08-20.sql.)
But it's displayed for "Joomla CMS" extension (eid=208) where
element
isjoomla
. Is it correct to compareelement
ascom_admin
?Surprisingly, clicking "Update Structure" helped even on the current beta3 code without patch applied (the column was re-created).