Skip to content

[4.2] PHP8.2 Define the JComponentTitle property in WebApplication class#39592

Merged
roland-d merged 8 commits intojoomla:4.2-devfrom
Digital-Peak:php82/toolbar
Jan 14, 2023
Merged

[4.2] PHP8.2 Define the JComponentTitle property in WebApplication class#39592
roland-d merged 8 commits intojoomla:4.2-devfrom
Digital-Peak:php82/toolbar

Conversation

@laoneo
Copy link
Copy Markdown
Member

@laoneo laoneo commented Jan 11, 2023

Summary of Changes

Adds a check when the title is rendered in the toolbar if the app has the property JComponentTitle.

We are going basically back to the beginning cdd4173#diff-5f6eb93d25275fcc88e719c1c9e8df1de7be12c716b4632404256471aa953ad4L41.

Defines the missing property JComponentTitle in the WebApplication class. After this is upmerged to 4.3, it will be deprecated.

Testing Instructions

Open the back end with PHP 8.2.

Actual result BEFORE applying this Pull Request

The wollowing warning is shown:
`Creation of dynamic property Joomla\CMS\Application\AdministratorApplication::$JComponentTitle is deprecated in libraries/src/Toolbar/ToolbarHelper.php on line 52

Expected result AFTER applying this Pull Request

No warning.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@laoneo laoneo added PHP 8.x PHP 8.x deprecated issues and removed PR-4.2-dev labels Jan 11, 2023
@laoneo laoneo changed the title Test if an app has the property JComponentTitle [4.2] PHP8.2 Test if an app has the property JComponentTitle Jan 11, 2023
@joomdonation
Copy link
Copy Markdown
Contributor

With the change in this PR, JComponentTitle won't be set to $app, so there is backward incompatible change here in case there is an extension (like mod_title in our core code) want to access to this value via $app->JComponentTitle . Also, I'm not sure if using $app->set to store random data is a good change.

For this, maybe we should add JComponentTitle as a public property to CMSApplication instead (ToolbarHelper::title could be used on both from frontend and backend)

@laoneo
Copy link
Copy Markdown
Member Author

laoneo commented Jan 12, 2023

This property was never defined, nor documented, so I wouldn't count it as public API, therefore no BC break.

It was added as a property just for the sake of micro optimization and was before in the internal storage of the app, see my linked commit. So we are going basically back to where we were at the beginning.

@joomdonation
Copy link
Copy Markdown
Contributor

This property was never defined, nor documented, so I wouldn't count it as public API, therefore no BC break

I'm unsure about this, so I won't record my test result, sorry. Even if that's accepted, why do we have to use the isset command in the code below on both files modified in this PR? That never returns true if the property is not defined.

if (isset($app->JComponentTitle)) {
       
}

@laoneo
Copy link
Copy Markdown
Member Author

laoneo commented Jan 12, 2023

Because it is a hack, you should not define a custom property in a class which doesn't support it. So I'm glad PHP 8.2 did report that. This is an abuse and is bad code practice, I would remove it completely, but you never know what for apps do exist into the wild, so I'm leaving the variable assignment.

I would even go that far and deprecated it in 4.3 and remove in 6.0.

@HLeithner
Copy link
Copy Markdown
Member

I found this on github

https://github.com/valeriekebz/WebsiteKEBS/blob/bc01497de0e49e3fe89a2b7b7c7af4a9159e450c/administrator/components/com_breezingforms/breezingforms.php#L58-L62

if this is normal for breezingforms I would expect we break this component right?

@HLeithner
Copy link
Copy Markdown
Member

here is another one:
https://github.com/hooNam/Solidres/blob/8b21829e18284680732a66c3e6cf0dbcde4e0b49/com_solidres/frontend/com_solidres/helpers/toolbar.php#L37-L39

adding this variable to WebApplication and deprecate it with j4.3 and remove it in 6 would be ok, but we need a bzw. layer for it right?

Also I would go more specific with an own g/setTitle() function in the WebApplication instead of a generic set/get.

Or maybe moving this variable to the htmldocument? would this make more sense?

@laoneo
Copy link
Copy Markdown
Member Author

laoneo commented Jan 12, 2023

I found this on github

https://github.com/valeriekebz/WebsiteKEBS/blob/bc01497de0e49e3fe89a2b7b7c7af4a9159e450c/administrator/components/com_breezingforms/breezingforms.php#L58-L62

if this is normal for breezingforms I would expect we break this component right?

Nope, because breezing forms is defining that variable (will also result in a deprecate warning) which then takes precedence here over the value from the app data store.

The same applies for solidres. So from BC perspective we are covered, except when a module is using that variable only with core. Then it is not available, but again this is undocumented and not even close to a public API.

Also I would go more specific with an own g/setTitle() function in the WebApplication instead of a generic set/get.

This is not the title of the application, it is really only a html string which gets then printed in the title module. So for now I think the closest would probably be the toolbar itself.

@laoneo
Copy link
Copy Markdown
Member Author

laoneo commented Jan 12, 2023

Changed my mind and just added the missing property to the WebApplication class. Once upmerged to 4.3 we can then deprecate it.

@joomdonation and @carlitorweb would you mind to give it a test?

@laoneo laoneo changed the title [4.2] PHP8.2 Test if an app has the property JComponentTitle [4.2] PHP8.2 Define the JComponentTitle property in WebApplication class Jan 12, 2023
@carlitorweb
Copy link
Copy Markdown
Member

I have tested this item ✅ successfully on 9dee2a2


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39592.

1 similar comment
@joomdonation
Copy link
Copy Markdown
Contributor

I have tested this item ✅ successfully on 9dee2a2


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39592.

@joomdonation
Copy link
Copy Markdown
Contributor

RTC. Thanks !


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39592.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Jan 13, 2023
@roland-d roland-d merged commit cff0c4b into joomla:4.2-dev Jan 14, 2023
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Jan 14, 2023
@roland-d
Copy link
Copy Markdown
Contributor

Thank you

@roland-d roland-d deleted the php82/toolbar branch January 14, 2023 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PHP 8.x PHP 8.x deprecated issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants