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

Fix Phalcon\Mvc\Micro\LazyLoader segfault #14238

Merged
merged 4 commits into from
Jul 10, 2019
Merged

Conversation

davidofferman
Copy link
Contributor

Hello!

In raising this pull request, I confirm the following:

  • I have read and understood the Contributing Guidelines
  • I have checked that another pull request for this purpose does not exist
  • I wrote some tests for this PR
  • I have updated the relevant CHANGELOG
  • I have created a PR for the documentation about this change

Small description of change:
Fixes a segfault when using Micro with Collections. The segfault happens when you lazy load a handler that has a syntax error.

Sample Application:
This sample application with index.php and controllers/BadController.php. The controller is missing a semi-colon on purpose when assigning the array to a variable.

<?php

try {
	$collection = new Phalcon\Mvc\Micro\Collection();
	$collection->setPrefix("");
	$collection->setHandler("Controller\\BadController");
	$collection->setLazy(true);
	$collection->head("/", "bugAction");
	$collection->get("/", "bugAction");

	$loader = new Phalcon\Loader();
	$loader->registerNamespaces([
		"Controller" => __DIR__ . "/controllers/"
	]);

	$loader->register();

	$app = new Phalcon\Mvc\Micro();
	$app->mount($collection);
	$app->handle();
} catch(Throwable $t) {
	print_r($t);
}
<?php

namespace Controller;

class BadController {

	public function bugAction($slug) {
		$a = []
	}

}

Thank you.

@niden
Copy link
Sponsor Member

niden commented Jul 9, 2019

@davidofferman Thank you for this. Could you please target the 4.x branch and update the changelog with your change?

Thanks!

@niden niden added 4.0 labels Jul 9, 2019
phalcon/mvc/micro/lazyloader.zep Show resolved Hide resolved
phalcon/mvc/micro/lazyloader.zep Outdated Show resolved Hide resolved
sergeyklay
sergeyklay previously approved these changes Jul 10, 2019
@sergeyklay sergeyklay merged commit 1341f1d into phalcon:3.4.x Jul 10, 2019
@sergeyklay
Copy link
Contributor

Thank you

@sergeyklay
Copy link
Contributor

@niden 4.0.x: #14243

@stamster
Copy link
Contributor

Thumbs up for @davidofferman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: low Low
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants