Web Tools oddity

I am developing something which I wish to share with people, so I do not wish to write my database password directly into the config file. Instead, I have it in a separate file, which gets merged with the config file. Here are the relevant parts:

app/config/config.php ```php <?php $config = new \Phalcon\Config(array( 'database' => array( 'adapter' => 'Mysql', ), 'application' => array( 'controllersDir' => DIR . '/../../app/controllers/', 'modelsDir' => DIR . '/../../app/models/', 'viewsDir' => DIR . '/../../app/views/', 'pluginsDir' => DIR . '/../../app/plugins/', 'libraryDir' => DIR . '/../../app/library/', 'cacheDir' => DIR . '/../../app/cache/', 'baseUri' => '/', ) )); $localConfigs = require_once DIR . "/config.local.php"; $config->merge($localConfigs); return ($config); ```

app/config/config.local.php: ```php <?php return(new \Phalcon\Config( array( 'database' => array( 'host' => 'localhost', 'username' => 'username', 'password' => 'password', 'dbname' => 'database_name' ) ) )); ```

When I use the generic bootstrap, it works.

When I use the Web Tool, it works -- I can even go to the models tab and see my tables.

When I use the Web Tool's models/create method, it fails with this error dump:

Phalcon\Config\Exception: Configuration must be an Object
#0 /var/www/app/config/config.php(17): Phalcon\Config->merge(true)
#1 /var/phalcon/vendor/phalcon/devtools/scripts/Phalcon/Builder/Component.php(60): include('/var/www/app/co...')
#2 /var/phalcon/vendor/phalcon/devtools/scripts/Phalcon/Builder/Model.php(242): Phalcon\Builder\Component->_getConfig('')
#3 /var/phalcon/vendor/phalcon/devtools/scripts/Phalcon/Web/Tools/controllers/ModelsController.php(66): Phalcon\Builder\Model->build()
#4 [internal function]: ModelsController->createAction()
#5 [internal function]: Phalcon\Dispatcher->dispatch()
#6 /var/phalcon/vendor/phalcon/devtools/scripts/Phalcon/Web/Tools.php(276): Phalcon\Mvc\Application->handle()
#7 /var/www/public/webtools.php(31): Phalcon\Web\Tools::main('/var/phalcon/ve...')
#8 {main}

What is even more odd is if I add die(var_dump($config)); just before the return in config.php, it shows me the config content no problem. But when I remove it, Phalcon thinks I am doing a merge(true) instead of merge($localConfigs).

I am using vagrant to provision a 64bit Wheezy using "Puppetlabs Debian 7.0rc1 x86_64, VBox 4.2.10" box on vagrantbox.es, PHP 5.4 from dotdeb (5.4.16-1~dotdeb.1), nginx 1.4.1 from dotdeb (1.4.1-1~dotdeb.1), and MariaDB 10 from official (10.0.3+maria-1~wheezy), and Phalcon was build from github master branch on Jun 17.

Any idea what can I do to make Web Tools work properly?



84.1k

It seems that for some reason the file sometimes is returning true and sometimes a valid object?

It consistently returns object when I do die(var_dump()), even if it is on models/create page. It also consistently return true when I use it in models/create as is, without edit. Let me do a quick screen recording and show you...

Video recorded on my potato laptop, sorry for blurry and ugly lag: http://www.youtube.com/watch?v=CKO9AMcPk%5U

Also, I did it completely improv, so no pre-planning, so sorry if it seems incoherent. Here's what's happening with matching time codes: 00:00 - 00:12 - Showing the config files in IDE 00:35 - Browser finally loaded the page (lag due to video recording) -- I switched to IDE wanting to show edits but realized I didn't show Web Tools so I tabbed back after. 01:00 - Loading up webtools.php, works no problem. 01:18 - Loading up models page, works no problem -- even fetches the tables from DB. 01:30 - merge(true) error :/ 02:10 - Edited config.php to die, but missed vardump, so it doesn't work. 02:30 - Added vardump, and it shows config gets merged correctly. 02:45 - Shows that merge does work properly even on another page. 02:55 - Comment out die(var_dump()) line... 03:10 - merge(true) again. 04:17 - Edited Component.php from webtools scripts to show it does indeed run to the correct place.

No idea why it is doing this. Perhaps something in phalcon.so?



84.1k

Can you try disabling any accelerator? APC, ZendOptimizer+, eAccelerator, XCache, etc?

No accelerators in this testbed. Only had XDebug enabled... disabled that and still the same problem.

[email protected]:/etc/php5/conf.d$ ls -lha
total 16K
drwxr-xr-x 2 root root 4.0K Jun 25 22:51 .
drwxr-xr-x 6 root root 4.0K Jun 18 03:43 ..
lrwxrwxrwx 1 root root   25 Jun 18 03:43 10-pdo.ini -> ../mods-available/pdo.ini
lrwxrwxrwx 1 root root   24 Jun 18 03:43 20-gd.ini -> ../mods-available/gd.ini
lrwxrwxrwx 1 root root   29 Jun 18 03:43 20-imagick.ini -> ../mods-available/imagick.ini
lrwxrwxrwx 1 root root   26 Jun 18 03:43 20-imap.ini -> ../mods-available/imap.ini
lrwxrwxrwx 1 root root   26 Jun 18 03:43 20-intl.ini -> ../mods-available/intl.ini
lrwxrwxrwx 1 root root   28 Jun 18 03:44 20-mcrypt.ini -> ../mods-available/mcrypt.ini
lrwxrwxrwx 1 root root   31 Jun 18 03:44 20-memcached.ini -> ../mods-available/memcached.ini
lrwxrwxrwx 1 root root   28 Jun 18 03:44 20-mysqli.ini -> ../mods-available/mysqli.ini
lrwxrwxrwx 1 root root   27 Jun 18 03:44 20-mysql.ini -> ../mods-available/mysql.ini
lrwxrwxrwx 1 root root   31 Jun 18 03:44 20-pdo_mysql.ini -> ../mods-available/pdo_mysql.ini
-rw-r--r-- 1 root root   21 Jun 18 03:50 phalcon.ini
-rw-r--r-- 1 root root  185 Jun 18 03:52 xdebug.ini.disable
[email protected]:/etc/php5/conf.d$

Edit: I saved a copy of the phpinfo() output here: http://dev.terrandin.net/phpinfo.html



84.1k

Can you send me the relevant parts of the application? or Grant me access to your system?

I can try to setup some sort of remote desktop on my laptop, and give you access that way (it is not running on a live server). This is a 4+ yrs old macbook, though, so it might run at potato speed.

Is the [email protected] email address appearing on github okay for me to send you login information at?



84.1k

Yes, please send me the info to [email protected]

Sent, thanks!

Resolved! Thank you Andres!

FYI for anyone who run into similar problem in the future:

\Phalcon\Web\Tool will attempt to load the config file. Then, when you are building things, \Phalcon\Builder\Component will attempt to load the config file again. If you are using includeonce or requireonce like me, the second load will return true (even though for some reason die(var_dump()) doesn't seem to be affected by this). As result of that return being true instead of the data, merge cannot merge the configurations properly.

Changing require_once to require resolved the issue for me.