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

Notice "Cannot use a scalar value as an array" #10673

Merged
merged 1 commit into from
Jul 16, 2015
Merged

Notice "Cannot use a scalar value as an array" #10673

merged 1 commit into from
Jul 16, 2015

Conversation

olivier-monaco
Copy link
Contributor

@andresgutierrez
Copy link
Contributor

Could you please provide the script or unit-test you used to test this?

@olivier-monaco
Copy link
Contributor Author

For simple.zep, I don't have any test. It's by code review. It revert the following commit: https://github.com/olivier-monaco/cphalcon/commit/4f5e28abfbe586f43d5ee6c41d3901b91a85d02a#diff-0a0014cdd026fc43956d243d1ecebbcdL202

The current code is doing something like:

let renamed[this->_columnMap[key][0][0]] = value

But a I think column map entry can't be array of array.

Same for model.zep.

@andresgutierrez
Copy link
Contributor

They can be arrays, it you're using orm.castOnHydrate = true

@olivier-monaco
Copy link
Contributor Author

Interesting... I'm working on a use case...

@olivier-monaco
Copy link
Contributor Author

Using use case from #10648 (comment).

I added a var_dump in simple.zep just before using renamedKey:

                        /**
                         * Check if the key is part of the column map
                         */
                        if !fetch renamedKey, columnMap[key] {
                            throw new Exception("Column '" . key . "' is not part of the column map");
                        }

var_dump("SIMPLE", renamedKey);
                        if typeof renamedKey == "array" {
                            if !fetch renamedKey, renamedKey[0] {
                                throw new Exception("Column '" . key . "' is not part of the column map");
                            }

                            let renamed[renamedKey[0]] = value;
                        } else {
                            let renamed[renamedKey] = value;
                        }

The result:

string(6) "SIMPLE"
array(2) {
  [0]=>
  string(2) "id"
  [1]=>
  int(0)
}
PHP Notice:  Cannot use a scalar value as an array in phalcon/mvc/model/resultset/simple.zep on line 209 in .../i10673a.php on line 24

It's not an array of array.

andresgutierrez added a commit that referenced this pull request Jul 16, 2015
Notice "Cannot use a scalar value as an array"
@andresgutierrez andresgutierrez merged commit 7ef05c5 into phalcon:2.0.x Jul 16, 2015
@andresgutierrez
Copy link
Contributor

Thanks

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

Successfully merging this pull request may close these issues.

2 participants