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

Encapsulate require_once to avoid name space bleedind #11634

Merged
merged 1 commit into from
Oct 17, 2014

Conversation

PVince81
Copy link
Contributor

The script required by require_once might use variable names like $app
which will conflict with the code that follows.

This fix encapsulates require_once into its own function to avoid such
issues.

Fixes #11553

Please review/test @MorrisJobke @DeepDiver1975 @mmattel @kedanli

@LukasReschke
Copy link
Member

👍 - THAT'S a bad bug.

@karlitschek We should backport this IMHO.

@MorrisJobke
Copy link
Contributor

Fixes the issue. Thanks for debugging this so fast. You're fantastic @PVince81 :)

👍

@PVince81
Copy link
Contributor Author

Thanks to you @MorrisJobke for providing the debug case 😄

*
* @param string $app app name
*/
private static function doLoadApp($app) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I propose a different method name?

requireAppFile

The script required by require_once might use variable names like $app
which will conflict with the code that follows.

This fix encapsulates require_once into its own function to avoid such
issues.
@PVince81 PVince81 force-pushed the loadapps-encapsulaterequire branch from 16a3d9e to 27c22f0 Compare October 17, 2014 10:46
@PVince81
Copy link
Contributor Author

@DeepDiver1975 renamed as requested.

@DeepDiver1975
Copy link
Member

@DeepDiver1975 renamed as requested.

thanks a lot!

@ghost
Copy link

ghost commented Oct 17, 2014

🚀 Test PASSed. 🚀
Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/626/
🚀 Test PASSed. 🚀

@ghost
Copy link

ghost commented Oct 17, 2014

💣 Test FAILed. 💣
Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/630/

Build result: FAILURE

GitHub pull request #11634 of commit 27c22f0 automatically merged.Building remotely on vm-slave-02 (SLAVE) in workspace /var/jenkins/workspace/pull-request-analyser-ng-simple@3 > git rev-parse --is-inside-work-tree # timeout=10Fetching changes from the remote Git repository > git config remote.origin.url https://github.com/owncloud/core.git # timeout=10Fetching upstream changes from https://github.com/owncloud/core.git > git --version # timeout=10 > git fetch --tags --progress https://github.com/owncloud/core.git +refs/pull/:refs/remotes/origin/pr/ > git rev-parse origin/pr/11634/merge^{commit} # timeout=10Checking out Revision cc0d1712d8b7d18cf482882de050b7b084fc005d (detached) > git config core.sparsecheckout # timeout=10 > git checkout -f cc0d1712d8b7d18cf482882de050b7b084fc005d > git rev-list 8523d9d6861a04290bf8938c225c963977b20c5e # timeout=10 > git remote # timeout=10 > git submodule init # timeout=10 > git submodule sync # timeout=10 > git config --get remote.origin.url # timeout=10 > git submodule update --init --recursiveTriggering pull-request-analyser-ng-simple » vm-slave-02Configuration pull-request-analyser-ng-simple » vm-slave-02 is still in the queue: Waiting for next available executor on vm-slave-02pull-request-analyser-ng-simple » vm-slave-02 completed with result FAILUREStarted calculate disk usage of buildFinished Calculation of disk usage of build in 0 secondsStarted calculate disk usage of workspaceFinished Calculation of disk usage of workspace in 6 second
💣 Test FAILed. 💣

@LukasReschke
Copy link
Member

Unrelated => merge.

LukasReschke added a commit that referenced this pull request Oct 17, 2014
Encapsulate require_once to avoid name space bleedind
@LukasReschke LukasReschke merged commit 439b33e into master Oct 17, 2014
@LukasReschke LukasReschke deleted the loadapps-encapsulaterequire branch October 17, 2014 12:32
@karlitschek
Copy link
Contributor

Great fix. 👍 Please backport.
This probably breaks if app.php defines a function or class but this is a bad idea anyways.

@scrutinizer-notifier
Copy link

The inspection completed: 1 updated code elements

@MorrisJobke
Copy link
Contributor

stable7 9998861

@actyler555
Copy link

Hi all. For the noob, where does this script get placed in the file system? General installation steps?

@PVince81
Copy link
Contributor Author

Steps:

  1. Grab the commit that fixes it, it's above: 9998861
  2. Open the link in new tab: 9998861
  3. Append ".patch": https://github.com/owncloud/core/commit/9998861402d9b16e2e7d8ebd9382633fc91a5dae.patch
  4. Save file as: "theawesomepatch.patch"
  5. Put the patch file inside your owncloud folder, for example "/var/www/owncloud"
  6. Start a shell in "/var/www/owncloud"
  7. Run the command patch -p1 < theawesomepatch.patch

This will apply the patch to your install.
If you get an error message, abort with Ctrl+C (maybe something wasn't right)
If everything worked well you should see no error message.

Let me know if that worked.

@actyler555
Copy link

Just applied the patch. Thanks for the instructions! Here is the output I received after running the command:

sudo patch -p1 < 9998861.patch
patching file lib/private/app.php

Unfortunately it appears the Windows client is still experiencing the problem.

An internal error number 1060 happened. 500 Internal Server Error.

Tried restarting Apache service first, then restarted the server. Same result.

Error log:

[Mon Oct 20 10:36:33.435583 2014] [:error] [pid 1530] [client 10.10.1.158:51204] PHP Fatal error:  Call to a member function getFileInfo() on a non-object in /var/www/owncloud/apps/files/appinfo/remote.php on line 49
[Mon Oct 20 10:37:04.992033 2014] [:error] [pid 1527] [client 10.10.1.158:51206] PHP Fatal error:  Call to a member function getFileInfo() on a non-object in /var/www/owncloud/apps/files/appinfo/remote.php on line 49
[Mon Oct 20 10:37:36.500322 2014] [:error] [pid 1528] [client 10.10.1.158:51219] PHP Fatal error:  Call to a member function getFileInfo() on a non-object in /var/www/owncloud/apps/files/appinfo/remote.php on line 49
[Mon Oct 20 10:38:08.195105 2014] [:error] [pid 1527] [client 10.10.1.158:51229] PHP Fatal error:  Call to a member function getFileInfo() on a non-object in /var/www/owncloud/apps/files/appinfo/remote.php on line 49
[Mon Oct 20 10:38:39.670223 2014] [:error] [pid 1529] [client 10.10.1.158:51231] PHP Fatal error:  Call to a member function getFileInfo() on a non-object in /var/www/owncloud/apps/files/appinfo/remote.php on line 49
[Mon Oct 20 10:39:11.167391 2014] [:error] [pid 1531] [client 10.10.1.158:51233] PHP Fatal error:  Call to a member function getFileInfo() on a non-object in /var/www/owncloud/apps/files/appinfo/remote.php on line 49

Content of remote.php file:

<?php

/**
 * ownCloud
 *
 * @author Frank Karlitschek
 * @author Jakob Sack
 * @copyright 2012 Frank Karlitschek frank@owncloud.org
 * @copyright 2011 Jakob Sack kde@jakobsack.de
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

// Backends
$authBackend = new OC_Connector_Sabre_Auth();
$lockBackend = new OC_Connector_Sabre_Locks();
$requestBackend = new OC_Connector_Sabre_Request();

// Fire up server
$objectTree = new \OC\Connector\Sabre\ObjectTree();
$server = new OC_Connector_Sabre_Server($objectTree);
$server->httpRequest = $requestBackend;
$server->setBaseUri($baseuri);

// Load plugins
$defaults = new OC_Defaults();
$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, $defaults->getName()));
$server->addPlugin(new \Sabre\DAV\Locks\Plugin($lockBackend));
$server->addPlugin(new \Sabre\DAV\Browser\Plugin(false)); // Show something in the Browser, but no upload
$server->addPlugin(new OC_Connector_Sabre_FilesPlugin());
$server->addPlugin(new OC_Connector_Sabre_MaintenancePlugin());
$server->addPlugin(new OC_Connector_Sabre_ExceptionLoggerPlugin('webdav'));

// wait with registering these until auth is handled and the filesystem is setup
$server->subscribeEvent('beforeMethod', function () use ($server, $objectTree) {
        $view = \OC\Files\Filesystem::getView();
        $rootInfo = $view->getFileInfo('');

        // Create ownCloud Dir
        $mountManager = \OC\Files\Filesystem::getMountManager();
        $rootDir = new OC_Connector_Sabre_Directory($view, $rootInfo);
        $objectTree->init($rootDir, $view, $mountManager);

        $server->addPlugin(new OC_Connector_Sabre_QuotaPlugin($view));
}, 30); // priority 30: after auth (10) and acl(20), before lock(50) and handling the request

// And off we go!
$server->exec();

@PVince81
Copy link
Contributor Author

@actyler555 yes, so it did not fix the getFileInfo issue.
Please follow up here: #11584

@lock lock bot locked as resolved and limited conversation to collaborators Aug 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: PHP Illegal offset type in isset or empty
7 participants