? Failure

User tests: Successful: Unsuccessful:

avatar mbabker
mbabker
15 Mar 2015

With PHP 7 in active development, I'm trying to be forward looking a bit and look at how compatibility for Joomla's code is affected by changes in the branch. This first PR addresses what is easily the most common difference in PHP 5 and 7 at the moment and should be B/C (unit tests for PHP 5.3 pass with these changes in Framework code that's been updated).

PHP 7 throws an Array to string conversion error if you are accessing an object with a nested array using syntax like $object->$array['key']; I haven't researched the exact reason for this but the parser tries to convert the array to a string versus reading the array element. Wrapping the array in curly brackets (like $object->{$array['key']}) allows the parser to interpret this correctly.

In code that is unit tested, the problematic areas come from the Registry package, JHtmlSelect, JKeychain, and JArrayHelper. These areas are updated with the required changes. A review on extension level code (and untested library code) will need to happen as well.

Also, there appears to be a B/C break with the SimpleXMLElement class and its handling of empty XML nodes between PHP 5 & 7. This needs to be researched also, but it causes fatal errors in the JRegistryFormatXmlTest class, so those tests are skipped for the moment.

Testing

This should be well tested on stable PHP versions that the CMS supports (5.3.10+). Below is a gist of how different aspects can be tested:

  • JHtmlSelect
    • Any <select> element should continue to be populated correctly
  • Joomla\Registry\Registry
    • Most any request should validate this works correctly as the session's data is written to a Registry object stored there
  • JArrayHelper
    • The Extension Manager's update sites view triggers code that calls the updated method
  • JKeychain
    • There isn't any uses of this in the CMS but if the other 3 areas work right and this code has the same fix...

This gist demonstrates the PHPUnit test results pre- and post- patch. Note that the failures are not yet addressed, those will come at a later time.

avatar mbabker mbabker - open - 15 Mar 2015
avatar joomla-cms-bot joomla-cms-bot - change - 15 Mar 2015
Labels Added: ?
avatar zero-24 zero-24 - change - 15 Mar 2015
Easy No Yes
avatar zero-24 zero-24 - change - 15 Mar 2015
Category Libraries
avatar nonumber
nonumber - comment - 16 Mar 2015

Another few:
/libraries/cms/menu/menu.php [269, 277]
/libraries/fof/utils/array/array.php [524, 525]
/libraries/vendor/joomla/registry/src/Format/Xml.php [67, 123]
/libraries/vendor/joomla/utilities/src/ArrayHelper.php [499, 500]

avatar mbabker
mbabker - comment - 16 Mar 2015

The stuff in the ArrayHelper class is fixed in the Framework repo, on the 2.x branch specifically and needs backported to the 1.x branch.

As for the rest, it isn't stuff that was covered by automated testing so I didn't include it here. This is really just one big patch to get PHPUnit running on the Vagrant box Rasmus Lerdorf has which can pull in the current PHP 7 branch without me needing to hack up a lot of things and make it easier to start working through some of the incompatibilities.

avatar mbabker
mbabker - comment - 16 Mar 2015

Also, I'm really trying to do this in smaller chunks and not get to a point where the final patch covers a few hundred files and is practically untestable. Still got plenty of time to work on PHP 7 compatibility :smile:

avatar nonumber
nonumber - comment - 16 Mar 2015

These were all the uses of $foo->bar[...] I could find in the whole repo. So it wouldn't become any larger.

avatar mbabker
mbabker - comment - 16 Mar 2015

Well if it's that few I'll get what I can updated in a little bit.

avatar nonumber
nonumber - comment - 16 Mar 2015

That's the spirit :P

avatar wilsonge
wilsonge - comment - 16 Mar 2015

I've PR'd the FOF ones into that repo. They'll stay as they are obviously until we update the library next release though

avatar mbabker
mbabker - comment - 16 Mar 2015

PR updated. JMenu is fixed and Registry and Utilities packages updated.

avatar nonumber
nonumber - comment - 16 Mar 2015

Looks fine. But 2 things in libraries/vendor/joomla/utilities/src/ArrayHelper.php:

  • The copyright in the doc block of says 2013 now instead of 2015.
  • Shouldn't the InvalidArgumentException use a language string?
avatar mbabker
mbabker - comment - 16 Mar 2015

1) The copyrights in the Framework repo need to be updated. We shouldn't be modifying anything in the libraries/vendor folder; it is all coming from external sources.

2) The Framework isn't using language strings for exceptions.

avatar nonumber
nonumber - comment - 16 Mar 2015

1) Then why was the year set to 2015 in the file before this PR? Was that a mistake?

2) Ok :)

avatar wilsonge
wilsonge - comment - 16 Mar 2015

JM just replaced everything including in all the upstream repo's. Which is why as we update them again we're going back. Generally the CMS rule is only user facing strings need to be translated

avatar wilsonge wilsonge - close - 16 Mar 2015
avatar wilsonge wilsonge - reference | - 16 Mar 15
avatar wilsonge wilsonge - merge - 16 Mar 2015
avatar wilsonge wilsonge - close - 16 Mar 2015
avatar wilsonge wilsonge - change - 16 Mar 2015
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2015-03-16 21:39:40
avatar wilsonge wilsonge - change - 16 Mar 2015
Milestone Added:
avatar mbabker mbabker - head_ref_deleted - 1 Dec 2015
avatar stAn47
stAn47 - comment - 7 Dec 2015

hello friends, the php7 is now stable and i just got it installed for my DEV needs.

on Joomla 3.4.5 we got a problem with String class

/libraries/vendor/joomla/string/src/string.php

abstract class String
to
abstract class StringHelper

now all occurances of

use Joomla/String/String

must be changed to:

use Joomla/String/StringHelper

i am not sure how the autoload works for these files, so if anybody can suggest Git change, pls do so.

now i am trying to get these resolved:

Fatal error: Uncaught TypeError: Argument 1 passed to JErrorPage::render() must be an instance of Exception, instance of Error given in /libraries/cms/error/page.php:28 Stack trace: #0 [internal function]: JErrorPage::render(Object(Error)) #1 {main} thrown in /libraries/cms/error/page.php on line 28

(just a try for PDO since no mysql worked):
Fatal error: Uncaught Error: Cannot instantiate abstract class JDatabaseDriverPdo in /libraries/joomla/database/driver.php:315 Stack trace: #0 /libraries/joomla/factory.php(631): JDatabaseDriver::getInstance(Array) #1 /libraries/joomla/factory.php(329): JFactory::createDbo() #2 /libraries/joomla/session/storage/database.php(69): JFactory::getDbo() #3 [internal function]: JSessionStorageDatabase->write('e8c213614afecab...', '') #4 [internal function]: session_write_close() #5 {main} thrown in /libraries/joomla/database/driver.php on line 315

when trying to use mysqli:
Error displaying the error page: Application Instantiation Error: Could not connect to MySQL.


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

avatar mbabker
mbabker - comment - 7 Dec 2015
avatar VAT81
VAT81 - comment - 14 Jul 2018

Hi Guys,

I have a Notice: Array to string conversion in registry.php line 342

I have install xampp7.2.7 and the template is Joomla 2.5

I have solved all the over errors but is stuck with this one.

The current code in the .php file is:

325 // Explode the registry path into an array
325 if ($nodes = explode('.', $path))
327 {
328 // Initialize the current node to be the registry root.
329 $node = $this->data;
330
331 // Traverse the registry to find the correct node for the result.
332 for ($i = 0, $n = count($nodes) - 1; $i < $n; $i++)
333 {
334 if (!isset($node->$nodes[$i]) && ($i != $n))
335 {
336 $node->$nodes[$i] = new stdClass;
337 }
338 $node = $node->$nodes[$i];
339 }
340
341 // Get the old value if exists so we can return it
342 $result = $node->$nodes[$i] = $value;
343 }
344
345 return $result;

Thank you


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

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 14 Jul 2018

and the template is Joomla 2.5

@VAT81 Joomla 2.5 hit it's end-of-life (EOL) December 31, 2014.

Add a Comment

Login with GitHub to post a comment