? Error

User tests: Successful: Unsuccessful:

avatar itbra
itbra
30 Jun 2014

JTable::_construct($table, $key, $db) initialises several class fields such as JTable::$_tbl_keys. When the constructor parameter $key is properly initialised and assigned to the field JTable::$_tbl_keys overriding its default value the class field JTable::$_tbl_keys may get broken. Consider the case where the constructor parameter $key becomes null due to the null-value passed in for it. Through the assignment to JTable::$_tbl_keys that class fields value becomes null too which will cause trouble.

For example JTable::reset(), which executes an in_array() based on JTable::$_tbl_keys. This check then fails with the following error:

in_array() expects parameter 2 to be array, null given in /libraries/joomla/table/table.php on line 563

because JTable::$_tbl_keys value is null.

This pull request extends the constructor to consider the null-value and initialise $key with an empty array in case the passed in value is null.

The related tracker item #33907 can be found at joomlacode.org.

avatar itbra itbra - open - 30 Jun 2014
avatar itbra itbra - change - 30 Jun 2014
Title
JTable constructor not considering the null-value for the primary key breaks JTable::reset()
[#33907] JTable constructor not considering the null-value for the primary key breaks JTable::reset()
avatar itbra itbra - change - 22 Jul 2014
Title
[#33907] JTable constructor not considering the null-value for the primary key breaks JTable::reset()
[#33907] JTable not considering the null-value for the primary key breaks JTable::reset()
avatar brianteeman brianteeman - change - 21 Aug 2014
Status New Pending
avatar nicksavov nicksavov - change - 21 Aug 2014
Labels Removed: ?
avatar brianteeman brianteeman - change - 2 Sep 2014
Category SQL
avatar roland-d
roland-d - comment - 20 Aug 2015

@itbra Your PR fails due to not passing the unit tests:

PHP Fatal error: Cannot access empty property in /home/travis/build/joomla/joomla-cms/libraries/cms/helper/tags.php on line 775

PHP Stack trace:

PHP 1. {main}() /home/travis/.phpenv/versions/5.3.27/bin/phpunit:0

PHP 2. PHPUnit_TextUI_Command::main() /home/travis/.phpenv/versions/5.3.27/bin/phpunit:583

PHP 3. PHPUnit_TextUI_Command->run() phar:///home/travis/.phpenv/versions/5.3.27/bin/phpunit/phpunit/TextUI/Command.php:132

PHP 4. PHPUnit_TextUI_TestRunner->doRun() phar:///home/travis/.phpenv/versions/5.3.27/bin/phpunit/phpunit/TextUI/Command.php:179

PHP 5. PHPUnit_Framework_TestSuite->run() phar:///home/travis/.phpenv/versions/5.3.27/bin/phpunit/phpunit/TextUI/TestRunner.php:421

PHP 6. PHPUnit_Framework_TestSuite->run() phar:///home/travis/.phpenv/versions/5.3.27/bin/phpunit/phpunit/Framework/TestSuite.php:675

PHP 7. PHPUnit_Framework_TestSuite->run() phar:///home/travis/.phpenv/versions/5.3.27/bin/phpunit/phpunit/Framework/TestSuite.php:675

PHP 8. PHPUnit_Framework_TestCase->run() phar:///home/travis/.phpenv/versions/5.3.27/bin/phpunit/phpunit/Framework/TestSuite.php:675

PHP 9. PHPUnit_Framework_TestResult->run() phar:///home/travis/.phpenv/versions/5.3.27/bin/phpunit/phpunit/Framework/TestCase.php:754

PHP 10. PHPUnit_Framework_TestCase->runBare() phar:///home/travis/.phpenv/versions/5.3.27/bin/phpunit/phpunit/Framework/TestResult.php:686

PHP 11. PHPUnit_Framework_TestCase->runTest() phar:///home/travis/.phpenv/versions/5.3.27/bin/phpunit/phpunit/Framework/TestCase.php:818

PHP 12. ReflectionMethod->invokeArgs() phar:///home/travis/.phpenv/versions/5.3.27/bin/phpunit/phpunit/Framework/TestCase.php:952

PHP 13. JTableContentTest->testStore() phar:///home/travis/.phpenv/versions/5.3.27/bin/phpunit/phpunit/Framework/TestCase.php:952

PHP 14. JTableContent->store() /home/travis/build/joomla/joomla-cms/tests/unit/suites/libraries/legacy/table/JTableContentTest.php:179

PHP 15. JTable->store() /home/travis/build/joomla/joomla-cms/libraries/legacy/table/content.php:283

PHP 16. JObserverUpdater->update() /home/travis/build/joomla/joomla-cms/libraries/joomla/table/table.php:861

PHP 17. call_user_func_array() /home/travis/build/joomla/joomla-cms/libraries/joomla/observer/updater.php:104

PHP 18. JTableObserverTags->onAfterStore() /home/travis/build/joomla/joomla-cms/libraries/joomla/observer/updater.php:104

PHP 19. JHelperTags->postStoreProcess() /home/travis/build/joomla/joomla-cms/libraries/joomla/table/observer/tags.php:132

Fatal error: Cannot access empty property in /home/travis/build/joomla/joomla-cms/libraries/cms/helper/tags.php on line 775

Call Stack:

0.0012     778408   1. {main}() /home/travis/.phpenv/versions/5.3.27/bin/phpunit:0

0.0217    1372328   2. PHPUnit_TextUI_Command::main() /home/travis/.phpenv/versions/5.3.27/bin/phpunit:583

0.0217    1372944   3. PHPUnit_TextUI_Command->run() phar:///home/travis/.phpenv/versions/5.3.27/bin/phpunit/phpunit/TextUI/Command.php:132

4.1717  170646840   4. PHPUnit_TextUI_TestRunner->doRun() phar:///home/travis/.phpenv/versions/5.3.27/bin/phpunit/phpunit/TextUI/Command.php:179

4.2999  171789136   5. PHPUnit_Framework_TestSuite->run() phar:///home/travis/.phpenv/versions/5.3.27/bin/phpunit/phpunit/TextUI/TestRunner.php:421

358.3956 398131728 6. PHPUnit_Framework_TestSuite->run() phar:///home/travis/.phpenv/versions/5.3.27/bin/phpunit/phpunit/Framework/TestSuite.php:675

360.6647 402450168 7. PHPUnit_Framework_TestSuite->run() phar:///home/travis/.phpenv/versions/5.3.27/bin/phpunit/phpunit/Framework/TestSuite.php:675

362.1709 402520664 8. PHPUnit_Framework_TestCase->run() phar:///home/travis/.phpenv/versions/5.3.27/bin/phpunit/phpunit/Framework/TestSuite.php:675

362.1709 402520664 9. PHPUnit_Framework_TestResult->run() phar:///home/travis/.phpenv/versions/5.3.27/bin/phpunit/phpunit/Framework/TestCase.php:754

362.1715 402521656 10. PHPUnit_Framework_TestCase->runBare() phar:///home/travis/.phpenv/versions/5.3.27/bin/phpunit/phpunit/Framework/TestResult.php:686

362.7760 403875408 11. PHPUnit_Framework_TestCase->runTest() phar:///home/travis/.phpenv/versions/5.3.27/bin/phpunit/phpunit/Framework/TestCase.php:818

362.7761 403876808 12. ReflectionMethod->invokeArgs() phar:///home/travis/.phpenv/versions/5.3.27/bin/phpunit/phpunit/Framework/TestCase.php:952

362.7761 403876840 13. JTableContentTest->testStore() phar:///home/travis/.phpenv/versions/5.3.27/bin/phpunit/phpunit/Framework/TestCase.php:952

362.8604 403909376 14. JTableContent->store() /home/travis/build/joomla/joomla-cms/tests/unit/suites/libraries/legacy/table/JTableContentTest.php:179

362.8722 403924704 15. JTable->store() /home/travis/build/joomla/joomla-cms/libraries/legacy/table/content.php:283

362.9089 403937752 16. JObserverUpdater->update() /home/travis/build/joomla/joomla-cms/libraries/joomla/table/table.php:861

362.9090 403938216 17. call_user_func_array() /home/travis/build/joomla/joomla-cms/libraries/joomla/observer/updater.php:104

362.9090 403938584 18. JTableObserverTags->onAfterStore() /home/travis/build/joomla/joomla-cms/libraries/joomla/observer/updater.php:104

362.9091 403938584 19. JHelperTags->postStoreProcess() /home/travis/build/joomla/joomla-cms/libraries/joomla/table/observer/tags.php:132

Can you have a look at it please?


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

avatar roland-d roland-d - change - 24 Aug 2015
Status Pending Information Required
avatar roland-d
roland-d - comment - 8 Nov 2015

Hello @itbra

Thank you for your contribution.

The last comment here was on August 21st. Can you have a look at the feedback?

If no reply is received within 4 weeks we will close this issue.

Thanks for understanding!


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

avatar brianteeman brianteeman - change - 17 Dec 2015
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2015-12-17 11:09:44
Closed_By brianteeman
avatar brianteeman
brianteeman - comment - 17 Dec 2015

Closed due to lack of response for further information - it can always be reopened if that is provided


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

avatar brianteeman brianteeman - close - 17 Dec 2015

Add a Comment

Login with GitHub to post a comment