Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

PHP Warning: call_user_func() expects…when Weakref enabled #4373

Closed

Conversation

weierophinney
Copy link
Member

PHP Warning: call_user_func() expects…when Weakref enabled

Hi.

When opening the ZendSkeletonApplication, it gave me a bunch of warnings and an error:

 PHP Warning:  call_user_func() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in /test/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php on line 472
 PHP Stack trace:
 PHP   1. {main}() /test/public/index.php:0
 PHP   2. Zend\\Mvc\\Application::init($configuration = *uninitialized*) /test/public/index.php:12
 PHP   3. Zend\\ModuleManager\\ModuleManager->loadModules() /test/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php:238
 PHP   4. Zend\\EventManager\\EventManager->trigger($event = *uninitialized*, $target = *uninitialized*, $argv = *uninitialized*, $callback = *uninitialized*) /test/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php:100
 PHP   5. Zend\\EventManager\\EventManager->triggerListeners($event = *uninitialized*, $e = *uninitialized*, $callback = *uninitialized*) /test/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php:207
 PHP   6. call_user_func(*uninitialized*, *uninitialized*) /test/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php:472

 PHP Warning:  call_user_func() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in /test/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php on line 472
 PHP Stack trace:
 PHP   1. {main}() /test/public/index.php:0
 PHP   2. Zend\\Mvc\\Application::init($configuration = *uninitialized*) /test/public/index.php:12
 PHP   3. Zend\\ModuleManager\\ModuleManager->loadModules() /test/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php:238
 PHP   4. Zend\\EventManager\\EventManager->trigger($event = *uninitialized*, $target = *uninitialized*, $argv = *uninitialized*, $callback = *uninitialized*) /test/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php:100
 PHP   5. Zend\\EventManager\\EventManager->triggerListeners($event = *uninitialized*, $e = *uninitialized*, $callback = *uninitialized*) /test/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php:207
 PHP   6. call_user_func(*uninitialized*, *uninitialized*) /test/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php:472

 PHP Fatal error:  Uncaught exception 'Zend\\ModuleManager\\Exception\\RuntimeException' with message 'Module (Application) could not be initialized.' in /test/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php:140
 Stack trace:
 #0 /test/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php(81): Zend\\ModuleManager\\ModuleManager->loadModule('Application')
 #1 [internal function]: Zend\\ModuleManager\\ModuleManager->onLoadModules(Object(Zend\\ModuleManager\\ModuleEvent))
 #2 /test/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(472): call_user_func(Array, Object(Zend\\ModuleManager\\ModuleEvent))
 #3 /test/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(207): Zend\\EventManager\\EventManager->triggerListeners('loadModules', Object(Zend\\ModuleManager\\ModuleEvent), NULL)
 #4 /test/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php(100): Zend\\EventManager\\EventManager->trigger('loadModules', Object(Zend\\ModuleManager\\ModuleManager), Object(Zend\\ModuleManager\\ModuleEvent))
 #5 /test/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php(238): Zend\\ModuleManager\\ModuleManager->loadModules()
 #6 /test/public/index.php(12): Zend\\Mvc\\Application::init(Array)
 #7 {main}
   thrown in /test/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php on line 140

 
I installed Weakref from source:

 wget http://pecl.php.net/get/Weakref-0.2.2.tgz
 tar xzvf Weakref-0.2.2.tgz
 cd Weakref-0.2.2
 /usr/local/php/bin/phpize
 ./configure --with-php-config=/usr/local/php/bin/php-config
 make
 make install

 // phpinfo() output -> Weak References support Version: 0.0.1-alpha

 
I'm using:

 Zend Framework version 2.1.5

 PHP 5.4.14 (cli) (built: Apr 30 2013 20:11:38)
 Copyright (c) 1997-2013 The PHP Group
 Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
      with XCache v3.0.1, Copyright (c) 2005-2013, by mOo
      with Xdebug v2.2.2, Copyright (c) 2002-2013, by Derick Rethans
      with XCache Cacher v3.0.1, Copyright (c) 2005-2013, by mOo
      with XCache Coverager v3.0.1, Copyright (c) 2005-2013, by mOo

 
Please advise.

@mwillbanks
Copy link
Contributor

Could you please try current master? I believe this issue has been fixed.

@ichiro-nagata
Copy link
Author

I tried dev-develop(2.3.0dev) and dev-master(2.2.0dev).
but issue has occurred.

@sasezaki
Copy link
Contributor

sasezaki commented May 4, 2013

Hi, @mwillbanks .
one month ago, Weakref issue had resolved for ONLY EventManager test case with #3882 .
But ModuleManager's TestCase (& running ZendSkeltonApplication ) fails.

$ php -d extension=weakref.so /usr/bin/phpunit -c tests/phpunit.xml.dist tests/ZendTest/ModuleManager
There were 3 failures:

1) ZendTest\ModuleManager\Listener\ConfigListenerTest::testBadConfigValueThrowsInvalidArgumentException
Failed asserting that exception of type "Zend\ModuleManager\Exception\RuntimeException" matches expected exception "InvalidArgumentException". Message was: "Module (BadConfigModule) could not be initialized.".


2) ZendTest\ModuleManager\Listener\DefaultListenerAggregateTest::testDefaultListenerAggregateCanAttachItself
Failed asserting that an array contains 'ZendTest\ModuleManager\Listener\DefaultListenerAggregateTest'.

/home/kazusuke/dev/zendframework_zf2/tests/ZendTest/ModuleManager/Listener/DefaultListenerAggregateTest.php:99

3) ZendTest\ModuleManager\ModuleManagerTest::testCanNotLoadSomeObjectModuleWithoutIdentifier
Failed asserting that exception of type "PHPUnit_Framework_Error_Warning" matches expected exception "Zend\ModuleManager\Exception\RuntimeException". Message was: "call_user_func() expects parameter 1 to be a valid callback, first array member is not a valid class name or object".

- While it initially worked, usage has grown problematic as we've done more
  performance optimizations, and as Weakref itself has changed. What I found was
  that Weakref and the GC were cleaning up early, making listeners disappear -
  and thus making tests fail unexpectedly. Since we never want a listener to
  disappear, it makes sense to remove this functionality.
@ghost ghost assigned mwillbanks May 7, 2013
@mwillbanks mwillbanks closed this in c91aaf3 May 7, 2013
mwillbanks pushed a commit that referenced this pull request May 7, 2013
weierophinney added a commit that referenced this pull request May 7, 2013
- Added note about removal of Weakref.
gianarb pushed a commit to zendframework/zend-eventmanager that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-eventmanager that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-stdlib that referenced this pull request May 15, 2015
gianarb pushed a commit to zendframework/zend-stdlib that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants