Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] Removing calls to legacy ->set() #44011

Merged
merged 5 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
31 changes: 14 additions & 17 deletions administrator/components/com_fields/tmpl/field/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,24 @@
<?php endforeach; ?>
</div>
<div class="col-lg-3">
<?php $this->set(
'fields',
[
[
'published',
'state',
'enabled',
],
'group_id',
'assigned_cat_ids',
'access',
'language',
'note',
]
); ?>
<?php $this->fields = [
[
'published',
'state',
'enabled',
],
'group_id',
'assigned_cat_ids',
'access',
'language',
'note',
]; ?>
<?php echo LayoutHelper::render('joomla.edit.global', $this); ?>
<?php $this->set('fields', null); ?>
<?php $this->fields = null; ?>
</div>
</div>
<?php echo HTMLHelper::_('uitab.endTab'); ?>
<?php $this->set('ignore_fieldsets', ['fieldparams']); ?>
<?php $this->ignore_fieldsets = ['fieldparams']; ?>
<?php echo LayoutHelper::render('joomla.edit.params', $this); ?>
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'publishing', Text::_('JGLOBAL_FIELDSET_PUBLISHING', true)); ?>
<fieldset id="fieldset-publishingdata" class="options-form">
Expand Down
27 changes: 12 additions & 15 deletions administrator/components/com_fields/tmpl/group/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,22 @@
<?php echo $this->form->renderField('description'); ?>
</div>
<div class="col-lg-3">
<?php $this->set(
'fields',
[
[
'published',
'state',
'enabled',
],
'access',
'language',
'note',
]
); ?>
<?php $this->fields = [
[
'published',
'state',
'enabled',
],
'access',
'language',
'note',
]; ?>
<?php echo LayoutHelper::render('joomla.edit.global', $this); ?>
<?php $this->set('fields', null); ?>
<?php $this->fields = null; ?>
</div>
</div>
<?php echo HTMLHelper::_('uitab.endTab'); ?>
<?php $this->set('ignore_fieldsets', ['fieldparams']); ?>
<?php $this->ignore_fieldsets = ['fieldparams']; ?>
<?php echo LayoutHelper::render('joomla.edit.params', $this); ?>
<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'publishing', Text::_('JGLOBAL_FIELDSET_PUBLISHING', true)); ?>
<fieldset id="fieldset-rules" class="options-form">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function getTypeOptions()
*/
public function addReverseLookupUrl($option)
{
$this->rlu[MenusHelper::getLinkKey($option->request)] = $option->get('title');
$this->rlu[MenusHelper::getLinkKey($option->request)] = $option->title;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ public function getItem()
}

foreach ($rows as $row) {
$item->set($row->cfg_name, $row->cfg_value);
$property = $row->cfg_name;
$item->$property = $row->cfg_value;
}

$this->preprocessData('com_messages.config', $item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected function addToolbar()
$sender = $this->getUserFactory()->loadUserById($this->item->user_id_from);

if (
$sender->id !== $app->getIdentity()->get('id') && ($sender->authorise('core.admin')
$sender->id !== $app->getIdentity()->id && ($sender->authorise('core.admin')
|| $sender->authorise('core.manage', 'com_messages') && $sender->authorise('core.login.admin'))
&& $app->getIdentity()->authorise('core.manage', 'com_users')
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function parseXMLTemplateFile($templateBaseDir, $templateDir)
}

foreach ($xml as $key => $value) {
$data->set($key, $value);
$data->$key = $value;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static function parseXMLTemplateFile($templateBaseDir, $templateDir)
}

foreach ($xml as $key => $value) {
$data->set($key, $value);
$data->$key = $value;
}
}

Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_users/src/Helper/Mfa.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static function getConfigurationInterface(User $user): ?string
$view->setDocument($app->getDocument());
$view->returnURL = base64_encode(Uri::getInstance()->toString());
$view->user = $user;
$view->set('forHMVC', true);
$view->forHMVC = true;
$view->setLanguage($app->getLanguage());

@ob_start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private function _sendEmail($data, $contact, $emailCopyToSender)

if ($contact->email_to == '' && $contact->user_id != 0) {
$contact_user = $this->getUserFactory()->loadUserById($contact->user_id);
$contact->email_to = $contact_user->get('email');
$contact->email_to = $contact_user->email;
}

$templateData = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function display($cachable = false, $urlparams = [])
$vName = $this->input->get('view', 'categories');
$this->input->set('view', $vName);

if ($this->app->getIdentity()->get('id')) {
if ($this->app->getIdentity()->id) {
$cachable = false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function display($cachable = false, $urlparams = false)
$vName = $this->input->get('view', 'categories');
$this->input->set('view', $vName);

if ($this->app->getIdentity()->get('id') || ($this->input->getMethod() === 'POST' && $vName === 'category')) {
if ($this->app->getIdentity()->id || ($this->input->getMethod() === 'POST' && $vName === 'category')) {
$cachable = false;
}

Expand Down
4 changes: 1 addition & 3 deletions components/com_users/src/Controller/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ public function edit()
return false;
}

$cookieLogin = $user->get('cookieLogin');

// Check if the user logged in with a cookie
if (!empty($cookieLogin)) {
if (isset($user->cookieLogin) && !empty($user->cookieLogin)) {
// If so, the user must login to edit the password and other data.
$app->enqueueMessage(Text::_('JGLOBAL_REMEMBER_MUST_LOGIN'), 'message');
$this->setRedirect(Route::_('index.php?option=com_users&view=login', false));
Expand Down
14 changes: 7 additions & 7 deletions components/com_users/src/Model/RegistrationModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ public function activate($token)
// Compile the admin notification mail values.
$data = $user->getProperties();
$data['activation'] = ApplicationHelper::getHash(UserHelper::genRandomPassword());
$user->set('activation', $data['activation']);
$data['siteurl'] = Uri::base();
$data['activate'] = Route::link(
$user->activation = $data['activation'];
$data['siteurl'] = Uri::base();
$data['activate'] = Route::link(
'site',
'index.php?option=com_users&task=registration.activate&token=' . $data['activation'],
false,
Expand Down Expand Up @@ -205,8 +205,8 @@ public function activate($token)
}
} elseif (($userParams->get('useractivation') == 2) && $user->getParam('activate', 0)) {
// Admin activation is on and admin is activating the account
$user->set('activation', '');
$user->set('block', '0');
$user->activation = '';
$user->block = '0';

// Compile the user activated notification mail values.
$data = $user->getProperties();
Expand Down Expand Up @@ -240,8 +240,8 @@ public function activate($token)
return false;
}
} else {
$user->set('activation', '');
$user->set('block', '0');
$user->activation = '';
$user->block = '0';
}

// Store the user object.
Expand Down
4 changes: 1 addition & 3 deletions components/com_users/src/View/Profile/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ public function display($tpl = null)
}

// View also takes responsibility for checking if the user logged in with remember me.
$cookieLogin = $user->get('cookieLogin');

if (!empty($cookieLogin)) {
if (isset($user->cookieLogin) && !empty($user->cookieLogin)) {
// If so, the user must login to edit the password and other data.
// What should happen here? Should we force a logout which destroys the cookies?
$app = Factory::getApplication();
Expand Down
4 changes: 1 addition & 3 deletions components/com_users/tmpl/login/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@

/** @var \Joomla\Component\Users\Site\View\Login\HtmlView $this */

$cookieLogin = $this->user->get('cookieLogin');

if (!empty($cookieLogin) || $this->user->guest) {
if ((isset($this->user->cookieLogin) && !empty($this->user->cookieLogin)) || $this->user->guest) {
// The user is not logged in or needs to provide a password.
echo $this->loadTemplate('login');
} else {
Expand Down
2 changes: 1 addition & 1 deletion installation/src/Model/LanguagesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ protected function getPackageUrl($remoteManifest)
$update->loadFromXml($remoteManifest);

// Get the download url from the remote manifest
$downloadUrl = $update->get('downloadurl', false);
$downloadUrl = $update->downloadurl ?? false;

// Check if the download url exist, otherwise return empty value
if ($downloadUrl === false) {
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Access/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function getAllowed($identity)

foreach ($this->data as $name => &$action) {
if ($action->allow($identity)) {
$allowed->set($name, true);
$allowed->$name = true;
}
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Application/CMSApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ public function login($credentials, $options = [])
$user = Factory::getUser();

if ($response->type === 'Cookie') {
$user->set('cookieLogin', true);
$user->cookieLogin = true;
}

if (\in_array(false, $results, true) == false) {
Expand Down
10 changes: 6 additions & 4 deletions libraries/src/MVC/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,15 @@ public function displayList()
$offset = null;

if (\array_key_exists('offset', $paginationInfo)) {
$offset = $paginationInfo['offset'];
$this->modelState->set($this->context . '.limitstart', $offset);
$offset = $paginationInfo['offset'];
$property = $this->context . '.limitstart';
$this->modelState->$property = $offset;
}

if (\array_key_exists('limit', $paginationInfo)) {
$limit = $paginationInfo['limit'];
$this->modelState->set($this->context . '.list.limit', $limit);
$limit = $paginationInfo['limit'];
$property = $this->context . '.list.limit';
$this->modelState->$property = $limit;
}

$viewType = $this->app->getDocument()->getType();
Expand Down
6 changes: 5 additions & 1 deletion libraries/src/MVC/View/AbstractView.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ public function get($property, $default = null)
}
}

return $this->legacyGet($property, $default);
if (isset($this->$property)) {
return $this->$property;
}

return $default;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ public function bind(&$array)
$array['password'] = UserHelper::hashPassword($array['password']);

// Set the registration timestamp
$this->set('registerDate', Factory::getDate()->toSql());
$this->registerDate = Factory::getDate()->toSql();
} else {
// Updating an existing user
if (!empty($array['password'])) {
Expand Down
4 changes: 2 additions & 2 deletions libraries/src/User/UserHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ public static function activateUser($activation)
if ($id) {
$user = User::getInstance($id);

$user->set('block', '0');
$user->set('activation', '');
$user->block = 0;
$user->activation = '';

// Time to take care of business.... store the user.
if (!$user->save()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function getArticles(Registry $params, SiteApplication $app)

// Access filter
$access = !ComponentHelper::getParams('com_content')->get('show_noauth');
$authorised = Access::getAuthorisedViewLevels($app->getIdentity()->get('id'));
$authorised = Access::getAuthorisedViewLevels($app->getIdentity()->id);
$articles->setState('filter.access', $access);

// Prep for Normal or Dynamic Modes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function getArticles(Registry $moduleParams, SiteApplication $app)
$items = [];
$itemParams = new \stdClass();

$itemParams->authorised = Access::getAuthorisedViewLevels($app->getIdentity()->get('id'));
$itemParams->authorised = Access::getAuthorisedViewLevels($app->getIdentity()->id);
$itemParams->access = $access;

foreach ($articlesModel->getItems() as $item) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/user/joomla/src/Extension/Joomla.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ private function getUser($user, $options = [])
}
} else {
// No existing user and autoregister off, this is a temporary user.
$instance->set('tmp_user', true);
$instance->tmp_user = true;
}

return $instance;
Expand Down