Skip to content

Commit

Permalink
Merge branch '4.0-dev' into search
Browse files Browse the repository at this point in the history
  • Loading branch information
brianteeman committed Sep 6, 2018
2 parents 4f74674 + 811ab3f commit 4818537
Show file tree
Hide file tree
Showing 52 changed files with 2,089 additions and 141 deletions.
24 changes: 24 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,30 @@ pipeline:
commands:
- bash libraries/vendor/joomla/test-system/src/drone-run.sh "$(pwd)"

analysis3x:
image: rips/rips-cli
secrets: [rips_username, rips_password]
when:
branch: staging
commands:
- export RIPS_BASE_URI='https://api.rips.joomla.org'
- export RIPS_USERNAME=$RIPS_USERNAME
- export RIPS_PASSWORD=$RIPS_PASSWORD
- if [ $DRONE_REPO_OWNER != 'joomla' ]; then echo "The analysis check only run on the main repos"; exit 0; fi
- rips-cli rips:scan:start -a 1 -t 1 -p $(pwd) -t 1 -T $DRONE_REPO_OWNER-$DRONE_BRANCH || { echo "Please contact the security team at security@joomla.org"; exit 1; }

analysis4x:
image: rips/rips-cli
secrets: [rips_username, rips_password]
when:
branch: 4.0-dev
commands:
- export RIPS_BASE_URI='https://api.rips.joomla.org'
- export RIPS_USERNAME=$RIPS_USERNAME
- export RIPS_PASSWORD=$RIPS_PASSWORD
- if [ $DRONE_REPO_OWNER != 'joomla' ]; then echo "The analysis check only run on the main repos"; exit 0; fi
- rips-cli rips:scan:start -a 3 -t 1 -p $(pwd) -t 1 -T $DRONE_REPO_OWNER-$DRONE_BRANCH || { echo "Please contact the security team at security@joomla.org"; exit 1; }

services:
mysql:
image: mysql:5.7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ALTER TABLE `#__users` MODIFY `name` varchar(400) NOT NULL DEFAULT '';
--
-- Step 2.2: Convert all tables to utf8mb4 chracter set with utf8mb4_unicode_ci collation
-- except #__finder_xxx tables, those will have utf8mb4_general_ci collation.
-- Note: The database driver for mysql will change utf8mb4 to utf8 if utf8mb4 is not supported
-- Note: The database driver for mysql will change utf8mb4 to utf8 if utf8mb4 is not supported
--

ALTER TABLE `#__assets` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Expand Down Expand Up @@ -108,6 +108,7 @@ ALTER TABLE `#__redirect_links` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4
ALTER TABLE `#__schemas` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__session` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__tags` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__template_overrides` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__template_styles` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__ucm_base` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__ucm_content` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Expand Down Expand Up @@ -200,6 +201,7 @@ ALTER TABLE `#__redirect_links` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_un
ALTER TABLE `#__schemas` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__session` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__tags` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__template_overrides` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__template_styles` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__ucm_base` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `#__ucm_content` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CREATE TABLE IF NOT EXISTS `#__template_overrides` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`template` varchar(50) NOT NULL DEFAULT '',
`hash_id` varchar(255) NOT NULL DEFAULT '',
`extension_id` int(11) DEFAULT 0,
`state` tinyint(1) NOT NULL DEFAULT 0,
`action` varchar(50) NOT NULL DEFAULT '',
`client_id` tinyint(1) unsigned NOT NULL DEFAULT 0,
`created_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`modified_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
KEY `idx_template` (`template`),
KEY `idx_extension_id` (`extension_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;

INSERT INTO `#__extensions` (`extension_id`, `package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `checked_out`, `checked_out_time`, `ordering`, `state`, `namespace`) VALUES
(491, 0, 'plg_installer_override', 'plugin', 'override', 'installer', 0, 1, 1, 1, '', '', 0, '0000-00-00 00:00:00', 4, 0, ''),
(492, 0, 'plg_quickicon_overridecheck', 'plugin', 'overridecheck', 'quickicon', 0, 1, 1, 1, '', '', 0, '0000-00-00 00:00:00', 0, 0, ''),
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CREATE TABLE IF NOT EXISTS "#__template_overrides" (
"id" serial NOT NULL,
"template" varchar(50) DEFAULT '' NOT NULL,
"hash_id" varchar(255) DEFAULT '' NOT NULL,
"extension_id" bigint DEFAULT 0,
"state" smallint DEFAULT 0 NOT NULL,
"action" varchar(50) DEFAULT '' NOT NULL,
"client_id" smallint DEFAULT 0 NOT NULL,
"created_date" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL,
"modified_date" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL,
PRIMARY KEY ("id")
);
CREATE INDEX "#__template_overrides_idx_template" ON "#__template_overrides" ("template");
CREATE INDEX "#__template_overrides_idx_extension_id" ON "#__template_overrides" ("extension_id");

INSERT INTO "#__extensions" ("extension_id", "package_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "checked_out", "checked_out_time", "ordering", "state", "namespace") VALUES
(491, 0, 'plg_installer_override', 'plugin', 'override', 'installer', 0, 1, 1, 1, '', '', 0, '1970-01-01 00:00:00', 4, 0, ''),
(492, 0, 'plg_quickicon_overridecheck', 'plugin', 'overridecheck', 'quickicon', 0, 1, 1, 1, '', '', 0, '1970-01-01 00:00:00', 0, 0, '');
3 changes: 3 additions & 0 deletions administrator/components/com_installer/Model/UpdateModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ public function update($uids, $minimum_stability = Updater::STABILITY_STABLE)
*/
private function install($update)
{
// Load overrides plugin.
PluginHelper::importPlugin('installer');

$app = Factory::getApplication();

if (!isset($update->get('downloadurl')->_data))
Expand Down
23 changes: 20 additions & 3 deletions administrator/components/com_joomlaupdate/Model/UpdateModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Joomla\CMS\Log\Log;
use Joomla\CMS\Http\HttpFactory;
use Joomla\CMS\Installer\Installer;
use Joomla\CMS\Plugin\PluginHelper;

/**
* Joomla! update overview Model
Expand Down Expand Up @@ -389,7 +390,8 @@ protected function downloadPackage($url, $target)
}

/**
* Create restoration file.
* Create restoration file and trigger onJoomlaBeforeUpdate event, which find the updated core files
* which have changed during the update, where there are override for.
*
* @param string $basename Optional base path to the file.
*
Expand All @@ -399,11 +401,17 @@ protected function downloadPackage($url, $target)
*/
public function createRestorationFile($basename = null)
{
// Load overrides plugin.
PluginHelper::importPlugin('installer');

// Get a password
$password = UserHelper::genRandomPassword(32);
$app = Factory::getApplication();
$app->setUserState('com_joomlaupdate.password', $password);

// Trigger event before joomla update.
$app->triggerEvent('onJoomlaBeforeUpdate');

// Do we have to use FTP?
$method = Factory::getApplication()->getUserStateFromRequest('com_joomlaupdate.method', 'method', 'direct', 'cmd');

Expand Down Expand Up @@ -826,19 +834,28 @@ public function finaliseUpgrade()
}

/**
* Removes the extracted package file.
* Removes the extracted package file and trigger onJoomlaAfterUpdate event, which find the updated core files
* which have changed during the update, where there are override for.
*
* @return void
*
* @since 2.5.4
*/
public function cleanUp()
{
// Load overrides plugin.
PluginHelper::importPlugin('installer');

$app = Factory::getApplication();

// Trigger event after joomla update.
$app->triggerEvent('onJoomlaAfterUpdate');

// Remove the update package.
$config = Factory::getConfig();
$tempdir = $config->get('tmp_path');

$file = Factory::getApplication()->getUserState('com_joomlaupdate.file', null);
$file = $app->getUserState('com_joomlaupdate.file', null);
$target = $tempdir . '/' . $file;

if (!@unlink($target))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@

defined('_JEXEC') or die;

use Joomla\CMS\Client\ClientHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\Component\Installer\Administrator\Model\InstallModel;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Client\ClientHelper;
use Joomla\CMS\Factory;
use Joomla\Component\Installer\Administrator\Model\InstallModel;
use Joomla\Utilities\ArrayHelper;

/**
* Template style controller class.
Expand All @@ -44,6 +46,9 @@ public function __construct($config = array(), MVCFactoryInterface $factory = nu

// Apply, Save & New, and Save As copy should be standard on forms.
$this->registerTask('apply', 'save');
$this->registerTask('unpublish', 'publish');
$this->registerTask('publish', 'publish');
$this->registerTask('deleteOverrideHistory', 'publish');
}

/**
Expand Down Expand Up @@ -74,6 +79,64 @@ public function close()
$this->setRedirect(Route::_($url, false));
}

/**
* Marked as Checked/Unchecked of override history.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function publish()
{
// Check for request forgeries.
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));

$app = Factory::getApplication();
$file = $this->input->get('file');
$id = $this->input->get('id');

$ids = $this->input->get('cid', array(), 'array');
$values = array('publish' => 1, 'unpublish' => 0, 'deleteOverrideHistory' => -3);
$task = $this->getTask();
$value = ArrayHelper::getValue($values, $task, 0, 'int');

if (empty($ids))
{
$this->setMessage(Text::_('COM_TEMPLATES_ERROR_NO_FILE_SELECTED'), 'warning');
}
else
{
/* @var \Joomla\Component\Templates\Administrator\Model\TemplateModel $model */
$model = $this->getModel();

// Change the state of the records.
if (!$model->publish($ids, $value, $id))
{
$this->setMessage(implode('<br>', $model->getErrors()), 'warning');
}
else
{
if ($value === 1)
{
$ntext = 'COM_TEMPLATES_N_OVERRIDE_CHECKED';
}
elseif ($value === 0)
{
$ntext = 'COM_TEMPLATES_N_OVERRIDE_UNCHECKED';
}
elseif ($value === -3)
{
$ntext = 'COM_TEMPLATES_N_OVERRIDE_DELETED';
}

$this->setMessage(Text::plural($ntext, count($ids)));
}
}

$url = 'index.php?option=com_templates&view=template&id=' . $id . '&file=' . $file;
$this->setRedirect(Route::_($url, false));
}

/**
* Method for copying the template.
*
Expand Down Expand Up @@ -738,4 +801,43 @@ public function extractArchive()
$this->setRedirect(Route::_($url, false));
}
}

/**
* Fetch and report updates in \JSON format, for AJAX requests
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function ajax()
{
$app = $this->app;

if (!Session::checkToken('get'))
{
$app->setHeader('status', 403, true);
$app->sendHeaders();
echo Text::_('JINVALID_TOKEN');
$app->close();
}

// Checks status of installer override plugin.
if (!PluginHelper::isEnabled('installer', 'override'))
{
$error = array('installerOverride' => 'disabled');

echo json_encode($error);

$app->close();
}

/* @var \Joomla\Component\Templates\Administrator\Model\TemplateModel $model */
$model = $this->getModel();

$result = $model->getUpdatedList(true, true);

echo json_encode($result);

$app->close();
}
}

0 comments on commit 4818537

Please sign in to comment.