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

bug in lib/autoloader.php::isValidPath() in NC14 and NC15beta2 #10613

Closed
julien-nc opened this issue Aug 9, 2018 · 14 comments
Closed

bug in lib/autoloader.php::isValidPath() in NC14 and NC15beta2 #10613

julien-nc opened this issue Aug 9, 2018 · 14 comments
Labels

Comments

@julien-nc
Copy link
Member

Sometimes, the content of $this->validRoots in isValidPath() method of Autoloader class is :

  ["/var/www/cloud2/n14b3/lib/private/legacy"]=>                                                                                                                                                                  
  bool(true)                                                                                                                                                                                                      
  [0]=>                                                                                                                                                                                                           
  bool(true)                                                                                                                                                                                                      
  ["/var/www/cloud2/n14b3/apps/accessibility"]=>                   
  bool(true)                                                                        
  ["/var/www/cloud2/n14b3/apps/activity"]=>
  bool(true)      
  ["/var/www/cloud2/n14b3/apps/cloud_federation_api"]=>      
  bool(true)                                                              
  ["/var/www/cloud2/n14b3/apps/files_pdfviewer"]=>
  bool(true)                                
  ["/var/www/cloud2/n14b3/apps/files_texteditor"]=>                    
  bool(true)
  ["/var/www/cloud2/n14b3/apps/files_videoplayer"]=>
  bool(true)
  ["/var/www/cloud2/n14b3/apps/firstrunwizard"]=>
  bool(true)
  ["/var/www/cloud2/n14b3/apps/gallery"]=>
  bool(true)
  ["/var/www/cloud2/n14b3/apps/logreader"]=>
  bool(true)
  ["/var/www/cloud2/n14b3/apps/nextcloud_announcements"]=>
  bool(true)
  ["/var/www/cloud2/n14b3/apps/notifications"]=>
  bool(true)
  ["/var/www/cloud2/n14b3/apps/password_policy"]=>
  bool(true)
  ["/var/www/cloud2/n14b3/apps/serverinfo"]=>
  bool(true)
  ["/var/www/cloud2/n14b3/apps/support"]=>
  bool(true)
  ["/var/www/cloud2/n14b3/apps/survey_client"]=>
  bool(true)
  ["/var/www/cloud2/n14b3/apps/theming"]=>
  bool(true)
  ["/var/www/cloud2/n14b3/apps/workflowengine"]=>
  bool(true)
  ["/var/www/cloud2/n14b3/apps/phonetrack"]=>
  bool(true)

The method fails because it's calling strlen() on this array's keys.

This only happens when running PhpUnit tests, as described below.

Steps to reproduce

  1. Deploy Nextcloud 14 beta 3
  2. Get PhoneTrack last master branch state
cd /path/to/nc14/apps/
git clone https://gitlab.com/eneiluj/phonetrack-oc phonetrack
  1. Activate PhoneTrack
sudo -u www-data php7.2 /var/www/html/nc14/occ app:enable phonetrack
  1. Run PhpUnit tests
cd /path/to/nc14/apps/phonetrack
sudo -u www-data phpunit --configuration phpunit.xml

Expected behaviour

Tests should run 😉.

Actual behaviour

PhpUnit fails with following error message :

There were 3 errors:

1) OCA\PhoneTrack\Controller\PageNLogControllerTest::testUtils
TypeError: strlen() expects parameter 1 to be string, integer given

/var/www/cloud2/n14b3/lib/autoloader.php:134
/var/www/cloud2/n14b3/lib/autoloader.php:163
/var/www/cloud2/n14b3/apps/phonetrack/tests/php/controller/pageControllerTest.php:51
/usr/bin/phpunit:34

2) OCA\PhoneTrack\Controller\PageNLogControllerTest::testLog
TypeError: strlen() expects parameter 1 to be string, integer given

/var/www/cloud2/n14b3/lib/autoloader.php:134
/var/www/cloud2/n14b3/lib/autoloader.php:163
/var/www/cloud2/n14b3/apps/phonetrack/tests/php/controller/pageControllerTest.php:51
/usr/bin/phpunit:34

3) OCA\PhoneTrack\Controller\PageNLogControllerTest::testPage
TypeError: strlen() expects parameter 1 to be string, integer given

/var/www/cloud2/n14b3/lib/autoloader.php:134
/var/www/cloud2/n14b3/lib/autoloader.php:163
/var/www/cloud2/n14b3/apps/phonetrack/tests/php/controller/pageControllerTest.php:51
/usr/bin/phpunit:34

ERRORS!
Tests: 3, Assertions: 0, Errors: 3.

Server configuration

Operating system:
Debian testing

Web server:
Apache 2.4.33-3

Database:
Sqlite

PHP version:
7.2.4-1

Nextcloud version:
14 beta 3

Updated from an older Nextcloud/ownCloud or fresh install:
fresh install

List of activated apps:

Enabled:

  • accessibility: 1.0.1
  • activity: 2.7.0
  • cloud_federation_api: 0.0.1
  • comments: 1.4.0
  • dav: 1.6.0
  • federatedfilesharing: 1.4.0
  • federation: 1.4.0
  • files: 1.9.0
  • files_pdfviewer: 1.3.2
  • files_sharing: 1.6.2
  • files_texteditor: 2.6.0
  • files_trashbin: 1.4.1
  • files_versions: 1.7.1
  • files_videoplayer: 1.3.0
  • firstrunwizard: 2.3.0
  • gallery: 18.1.0
  • logreader: 2.0.0
  • lookup_server_connector: 1.2.0
  • nextcloud_announcements: 1.3.0
  • notifications: 2.2.1
  • oauth2: 1.2.1
  • password_policy: 1.4.0
  • phonetrack: 0.2.8
  • provisioning_api: 1.4.0
  • serverinfo: 1.4.0
  • sharebymail: 1.4.0
  • support: 1.0.0
  • survey_client: 1.2.0
  • systemtags: 1.4.0
  • theming: 1.5.0
  • twofactor_backupcodes: 1.3.0
  • updatenotification: 1.4.1
  • workflowengine: 1.4.0

Disabled:

  • admin_audit
  • encryption
  • files_external
  • user_external
  • user_ldap

Nextcloud configuration:
default fresh install config

@julien-nc julien-nc added the bug label Aug 9, 2018
@julien-nc julien-nc changed the title bug in lib/autoloader.php::isValidPath() bug in lib/autoloader.php::isValidPath() in NC14 beta 3 Aug 9, 2018
@nextcloud-bot
Copy link
Member

GitMate.io thinks possibly related issues are #3771 (Autoloader issue in lib/private/Files/Storage/DAV.php), #8721 ([BUG] Invalid PHP Settings Being Displayed), #9730 (php mail bug in swift), #1257 (allowSymlinks in /lib/private/Files/Storage/Local.php), and #6784 (Php error?).

@julien-nc julien-nc changed the title bug in lib/autoloader.php::isValidPath() in NC14 beta 3 bug in lib/autoloader.php::isValidPath() in NC14 Sep 16, 2018
@MorrisJobke
Copy link
Member

As we haven't seen this in the past again I would close this for now. Thanks for the feedback anyways. 👍 If you still get this then we can have another look at this.

@julien-nc
Copy link
Member Author

It is still happening to me with Nextcloud 14.0.3.0.

@julien-nc julien-nc reopened this Nov 7, 2018
@julien-nc julien-nc changed the title bug in lib/autoloader.php::isValidPath() in NC14 bug in lib/autoloader.php::isValidPath() in NC14 and NC15beta2 Nov 19, 2018
@julien-nc
Copy link
Member Author

It is still happening in NC15 beta2.

@kesselb
Copy link
Contributor

kesselb commented Feb 3, 2019

Still happening?

@julien-nc
Copy link
Member Author

Yes, running fresh Nextcloud 15.0.2 :

1) OCA\PhoneTrack\Controller\PageNLogControllerTest
TypeError: strlen() expects parameter 1 to be string, integer given in /var/www/html/n15/lib/autoloader.php:133                                                             
Stack trace:                                                                                                                                                                
#0 /var/www/html/n15/lib/autoloader.php(133): strlen(0)
#1 /var/www/html/n15/lib/autoloader.php(162): OC\Autoloader->isValidPath('/var/www/html/n...')                                                                              
#2 [internal function]: OC\Autoloader->load('OCA\\PhoneTrack\\...')                                                                                                         
#3 /var/www/html/n15/apps/phonetrack/tests/php/controller/pageControllerTest.php(47): spl_autoload_call('OCA\\PhoneTrack\\...')                                             
#4 phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php(703): OCA\PhoneTrack\Controller\PageNLogControllerTest::setUpBeforeClass()                                 
#5 phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php(750): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult))                               
#6 phar:///usr/local/bin/phpunit/phpunit/TextUI/TestRunner.php(622): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult))                                 
#7 phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php(206): PHPUnit\TextUI\TestRunner->doRun(Object(PHPUnit\Framework\TestSuite), Array, true)                        
#8 phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php(162): PHPUnit\TextUI\Command->run(Array, true)                                                                  
#9 /usr/local/bin/phpunit(613): PHPUnit\TextUI\Command::main()
#10 {main}

@kesselb
Copy link
Contributor

kesselb commented Feb 6, 2019

1) OCA\PhoneTrack\Controller\PageNLogControllerTest::testPage
Doctrine\DBAL\Exception\DriverException: An exception occurred while executing '
                    UPDATE oc_phonetrack_devices
                    SET shape='triangle'
                    WHERE id='11'
                          AND sessionid='1384366d2325983f4b0412257910c843' ;':

SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'shape' at row 1

/home/vagrant/code/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:125
/home/vagrant/code/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:184
/home/vagrant/code/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:158
/home/vagrant/code/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Statement.php:178
/home/vagrant/code/nextcloud/apps/phonetrack/controller/pagecontroller.php:1246
/home/vagrant/code/nextcloud/apps/phonetrack/tests/php/controller/pageControllerTest.php:1070
/home/vagrant/code/nextcloud/phpunit.phar:570

Caused by
Doctrine\DBAL\Driver\PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'shape' at row 1

/home/vagrant/code/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:143
/home/vagrant/code/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Statement.php:169
/home/vagrant/code/nextcloud/apps/phonetrack/controller/pagecontroller.php:1246
/home/vagrant/code/nextcloud/apps/phonetrack/tests/php/controller/pageControllerTest.php:1070
/home/vagrant/code/nextcloud/phpunit.phar:570

Caused by
PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'shape' at row 1

/home/vagrant/code/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:141
/home/vagrant/code/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Statement.php:169
/home/vagrant/code/nextcloud/apps/phonetrack/controller/pagecontroller.php:1246
/home/vagrant/code/nextcloud/apps/phonetrack/tests/php/controller/pageControllerTest.php:1070
/home/vagrant/code/nextcloud/phpunit.phar:570

ERRORS!
Tests: 4, Assertions: 141, Errors: 1.

Tried to look but i'm running into this one 🤔

@julien-nc
Copy link
Member Author

Ow sorry. Strange that nobody reported that bug yet. Anyway, it's fixed and pushed to master.

Manually increase the app version number to make sure DB scheme is upgraded on your test instance.

@kesselb
Copy link
Contributor

kesselb commented Feb 6, 2019

PHPUnit 6.5.13 by Sebastian Bergmann and contributors.

....                                                                4 / 4 (100%)

Time: 8.07 seconds, Memory: 32.00MB

OK (4 tests, 316 assertions)

Cool. It does work for me with nextcloud 16. Could you try to rebuild the autoloaders? https://github.com/nextcloud/server/blob/master/build/autoloaderchecker.sh (don't run this on production)

@julien-nc
Copy link
Member Author

Great,

Do you mean that i should deploy Nextcloud from repo's master branch and run autoloaderchecker.sh ?

@kesselb
Copy link
Contributor

kesselb commented Feb 6, 2019

Yes. Should also work with stable15, stable14. I guess something with the autoloader is wrong.

@julien-nc
Copy link
Member Author

With a fresh NC install from repo's master branch it works like a charm, even without running autoloaderchecker.sh .

As I was only using official releases, I was not able to run autoloaderchecker.sh on an existing instance.

I guess the issue is solved. Thanks a lot.

@kesselb
Copy link
Contributor

kesselb commented Feb 6, 2019

Ok. I'm not sure if everything required for running the tests is included in the official release.

@kesselb kesselb closed this as completed Feb 6, 2019
@MorrisJobke
Copy link
Member

Ok. I'm not sure if everything required for running the tests is included in the official release.

Not really - we remove all test related code parts and configs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants