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] Crash while rendering element's label #1212

Merged
merged 4 commits into from Sep 9, 2013
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/forms/element.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ PHP_METHOD(Phalcon_Forms_Element, label){
/**
* Check if there is an 'id' attribute defined
*/
if (phalcon_array_isset_string(attributes, SS("id"))) {
if (attributes && phalcon_array_isset_string(attributes, SS("id"))) {
PHALCON_OBS_VAR(name);
phalcon_array_fetch_string(&name, attributes, SL("id"), PH_NOISY);
} else {
Expand Down
12 changes: 12 additions & 0 deletions ext/tests/issue-1210.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
Copy link
Author

Choose a reason for hiding this comment

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

I am planning to add more tests for all segmentation faults — this will make it easier for package maintainers to verify that Phalcon works — they will be able to do that with make test.

Crash while rendering element's label - https://github.com/phalcon/cphalcon/issues/1210
--SKIPIF--
<?php if (!extension_loaded("phalcon")) print "skip"; ?>
--FILE--
<?php
$e = new \Phalcon\Forms\Element\Text('test');
$e->setLabel('Test');
echo $e->label(), PHP_EOL;
?>
--EXPECTF--
<label for="test">Test</label>
9 changes: 9 additions & 0 deletions unit-tests/FormsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,4 +476,13 @@ public function testIssue1190()
$expected = '<input type="text" value="Hello &quot;world!&quot;" name="title" id="title" />';
$this->assertEquals($actual, $expected);
}

public function testIssue1210()
{
$e = new \Phalcon\Forms\Element\Text('test');
$e->setLabel('Test');
$actual = $e->label();
$expected = '<label for="test">Test</label>';
$this->assertEquals($actual, $expected);
}
}