Skip to content
Merged
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions administrator/components/com_admin/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ public function update($installer)
$this->deleteUnexistingFiles();
$this->updateManifestCaches();
$this->updateDatabase();

// Ensure templates are moved to the correct mode
$this->fixTemplateMode();
$this->updateAssets($installer);
$this->clearStatsCache();
$this->convertTablesToUtf8mb4(true);
Expand Down Expand Up @@ -8533,4 +8536,40 @@ protected function moveRemainingTemplateFiles()
}
}
}

/**
* Ensure the core templates are correctly moved to the new mode.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
protected function fixTemplateMode()
{
$db = Factory::getDbo();

array_map(

This comment was marked as abuse.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functional programming? No real reason, it's a bit shorter

This comment was marked as abuse.

Copy link
Contributor Author

@dgrammatiko dgrammatiko Jan 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't believe everything you find on the internet :)

FWIW browsers (JS) are optimizing for these functions and I would expect PHP would be doing that as well but for PHP I don't have any data...

Edit: actually this comment aligns with what I wrote ;)

This comment was marked as abuse.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional programming is very popular in the JS space and the reason is because React, Vue, Svelte, etc basically made the UI a function of the state UI = Fn(state)

This comment was marked as abuse.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate that I can't use the spread operator yet...

This comment was marked as abuse.

function ($template) use ($db)
{
$clientId = $template === 'atum' ? 1 : 0;
$query = $db->getQuery(true)
->update($db->quoteName('#__template_styles'))
->set($db->quoteName('inheritable') . ' = 1')
->where($db->quoteName('template') . ' = ' . $db->quote($template))
->where($db->quoteName('client_id') . ' = ' . $clientId);

try
{
$db->setQuery($query)->execute();
}
catch (Exception $e)
{
echo Text::sprintf('JLIB_DATABASE_ERROR_FUNCTION_FAILED', $e->getCode(), $e->getMessage()) . '<br>';

return;
}
},
['atum', 'cassiopeia']
);
}
}