-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Strange error after migration to Phalcon 3.0.0 #12056
Comments
My only guess it's beacause of windows perhaps ? Works on vagrant/ubuntu 14.04 without any problem. |
What is |
Hello.
//services.php line 6
$di = new \Phalcon\DI\FactoryDefault(); |
This is a really strange error. I am using Phalcon 3 on Windows 10, PHP 7.0.8 x64, and similar errors do not occur. |
Try to reload the page many times and the error should appear |
Are you using maybe opcache ? Try to check it disabled for instance. |
This seems to be affecting only Windows installations, I'll have to set up a Windows environment to check |
I have the same error. use Phalcon\Di\FactoryDefault;
$di = new FactoryDefault(); And keep refreshing this page or use apache ab.exe: Update: |
As i wrote, did you have opcache enabled ? Can you disable it for instance ? |
I've also got the same issue with WAMP3, (Which uses Apache) PHP 7.0.4 (TS). |
@Jurigag After I set opcache.enable=0 in php.ini and restarted apache, I still got this error.
Do you need me to do more tests? Update: |
No, i just thought it might be opcache, but looks like not. |
Yet another Window$ dev environment with strange behaviour. I wouldn't consider this as a bug unless the issue can be reproduced on production system (i.e. GNU/Linux). IMHO, just like Phalcon 3.0.0 has dropped support for Oracle RDBMS due to the noted reasons, same should have happened with DLL / Microsoft support. |
@stamster why? |
@stamster well, more interesting is that @Studentsov don't have this problem ? :D Sometimes people just want to use phalcon on their dev enviroment without using any virutal machine. |
For example, I prefer to program in Windows because switching PHP versions, web servers and DBMS I make one click. Isn't that progress? :D |
Studentsov - i make the same on linux:
Just phpbrew and proper script. |
http://stackoverflow.com/questions/38235349/fatal-error-access-to-undeclared-static-property-phalcon-di-default-pub |
same error occurs in: |
As you see above it's not phalcon problem really. |
what is the solution for this error? |
Don't use windows xD And/or apache php7 module. Try maybe using fpm and check if it works ? |
Also don't develop in an environment that is not like your production environment unless you want issues |
Actually you can write code in windows - just use vagrant/docker. |
If Phalcon didn't want to support developers on the Windows platform, they wouldn't compile the PHP module for Windows environments. |
@Mechzeit That is @Jurigag 's opinion, it's not the official position about Windows, of course this must be fixed |
@zhaoyanliang2 are you sure? |
zend_declare_property_null(phalcon_di_ce, SL("_default"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC); after then, after And each of thread will call these before exit See the php7.2 source, some changes have occurred in php7.3 and php7.4 |
7.3, zend_declare_property_ex() As far as I understand, the only case when the |
This bug has been fixed after php7.3 |
Ah, sorry, I misread what you wrote |
So we could possibly just backport this fix for php 7.2, 7.1 and 7 to zephir kernel and that's it? |
Well, in theory this should work then: diff --git a/Library/ClassDefinition.php b/Library/ClassDefinition.php
index 43cb5c6e..bdd20651 100644
--- a/Library/ClassDefinition.php
+++ b/Library/ClassDefinition.php
@@ -1227,6 +1227,10 @@ final class ClassDefinition
}
}
+ $codePrinter->output('#if PHP_VERSION_ID < 70300');
+ $codePrinter->output('zend_update_class_constants('.$this->getClassEntry().');');
+ $codePrinter->output('#endif');
+
$codePrinter->output('return SUCCESS;');
$codePrinter->outputBlankLine(); |
Or maybe not… |
So this should go to RINIT then… we will suffer performance penalty during RINIT for every request :-( |
@sjinks In a multi-thread environment, |
@Jurigag The php official team fixed the bug but did not merge it into php7.2. php/php-src@f78e681#diff-08f540d7b52da02794ca86b2de87ca69 |
Oh, so you suggest to try compiling php 7.2 with this fix and check if issue we have in phalcon still apears? That's actually good idea. If not then obviously php team should merge this fix to other php 7.x as well. |
Fixing this bug is not easy, and it is likely to cause performance problems, too many changes may break the compatibility of the PHP API. void zend_class_init_statics(zend_class_entry *class_type) /* {{{ */
{
int i;
zval *p;
if (!CE_STATIC_MEMBERS(class_type) && class_type->default_static_members_count) {
if (class_type->parent) {
zend_class_init_statics(class_type->parent);
}
CG(static_members_table)[(zend_intptr_t)(class_type->static_members_table)] = emalloc(sizeof(zval) * class_type->default_static_members_count);
for (i = 0; i < class_type->default_static_members_count; i++) {
p = &class_type->default_static_members_table[i];
if (Z_ISREF_P(p) &&
class_type->parent &&
i < class_type->parent->default_static_members_count &&
p == &class_type->parent->default_static_members_table[i] &&
Z_TYPE(CE_STATIC_MEMBERS(class_type->parent)[i]) != IS_UNDEF
) {
zval *q = &CE_STATIC_MEMBERS(class_type->parent)[i];
ZVAL_NEW_REF(q, q);
ZVAL_COPY_VALUE(&CE_STATIC_MEMBERS(class_type)[i], q);
Z_ADDREF_P(q);
} else {
ZVAL_DUP(&CE_STATIC_MEMBERS(class_type)[i], p);
}
}
}
}
void fix_class_static_member_thread_safe_bug()
{
zval *val;
ZEND_HASH_FOREACH_VAL(CG(class_table), val) {
zend_class_entry *ce = Z_PTR_P(val);
if ( ce->type == ZEND_INTERNAL_CLASS
&& !CE_STATIC_MEMBERS(ce)
&& ce->default_static_members_count
) {
zend_class_init_statics(ce);
}
} ZEND_HASH_FOREACH_END();
} call The above code is for php7.2, not tested under 7.0 and 7.1. |
@Jurigag I am afraid they won't :-( 7.2 active support ends on 30 Nov 2019, and they will likely let this bug expire :-( See, for example, https://bugs.php.net/bug.php?id=76301, https://bugs.php.net/bug.php?id=76302 (all these bugs came either from Zephir or Phalcon) :-( |
Maybe, we can manage static variable lists. |
@zhaoyanliang2, thanks for investigation. Im sove this problem for myself. Im write console multi-threading application with https://github.com/krakjoe/pthreads extension. In threads i have "Fatal error: Uncaught Error: Access to undeclared static property: Phalcon\Di::$_default". After read this thread i have invented 2 solutions. In both cases, first add in phalcon config.json:
The first option involves the use of superglobal variables, for example _SERVER. For this you need to change the di.zep in the following way:
The second option (which I use in my project) requires that you use the user space class in php. For this you need to change the di.zep in the following way:
in php script must be added before instantiating di:
BuildIn the archive I attach the config of the build of both versions of the docker images with a fixed di, as well as a test Build by commandЖ
TestingThe test script differs only in the presence of the user class PhStaticStorage for the second option.
Test result with disabled ini option:
Test result with enabled ini option:
Testing the second build is done by commands:
The result will be the same. |
@vGhost2000 |
Yes, I saw, but there are not so many of them and for the most part those that are not used in the console application, so I didn’t touch them. At the moment, so far this has solved my problem. If there is a need for others, I will correct them too. That's why I passed the PhStaticStorage universal, so that in case it could be used in other places. |
Would be great if somebody can test this against V4. |
In the 4th version, this is not required. This is a problem with PHP 7.2. In php 7.3 this bug is fixed. Falcon v4 oriented to php 7.3. Just use php 7.3 with phalcon v4. |
@vGhost2000 Thnx. In that case I'm closing this one. |
Give me a same error: <br />
<b>Fatal error</b>: Uncaught Error: Access to undeclared static property: Phalcon\Di::$_default in C:\projects\clicksseeker\server\public\api\index.php:17
Stack trace:
#0 [internal function]: Phalcon\Di->__construct()
#1 C:\projects\clicksseeker\server\public\api\index.php(17): Phalcon\Di\FactoryDefault->__construct()
#2 {main}
Next Error: Access to undeclared static property: Phalcon\Di::$_default in C:\projects\clicksseeker\server\public\api\index.php:17
Stack trace:
#0 [internal function]: Phalcon\Di->__construct()
#1 C:\projects\clicksseeker\server\public\api\index.php(17): Phalcon\Di\FactoryDefault->__construct()
#2 {main}
thrown in <b>C:\projects\clicksseeker\server\public\api\index.php</b> on line <b>17</b><br /> My environment: Environment: The project was created at least 1 year ago. |
Hello, i know this issue is closed, but i got same error but i didn't find the solution after read all the comment section.. so what is the solution ? |
Upgrade to php 7.3 Or use the non-thread-safe version. |
Thanks for you'r reply men, i apreciate |
Hello,
yesterday, I migrated my project to Phalcon 3.0 (from 2.1 version). And everything worked fine, except now I got very "randomly" this error:
On line 25 in my services.php file is where I create instance of DI factory class:
I work on Windows, Xampp v3.2.2 with PHP 7.0.8 and Phalcon 3.0.
Can you help me with this?
Thanks in advance!
The text was updated successfully, but these errors were encountered: