User tests: Successful: Unsuccessful:
Suppose that we have to insert some rows to category table. So we do this:
// Getting the category table
$category = JTable::getInstance('Category', 'JTable', array('dbo' => $this->_db));
// Bind data to save category
if (!$category->bind($row)) {
throw new Exception($category->getError());
}
// Insert the category
if (!$category->store()) {
throw new Exception($category->getError());
}
But this way to insert a new category returns the error: 'Application Instantiation Error' produced by the observers calls attached by default. Maybe this is an issue for the observers, i dont know why honesty, but i can solve the problem commenting this line:
https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/observer/updater.php#L104
The problem is that there is no way to disable the observable calls, so this patch add the method to disable the observable calls if the developers not need it.
I traced the bug 'Application Instantiation Error' that i have when i try to save or update a category using the JTableCategory table. Seems that the problem is in the line 125 of this file:
Applying your patch #1840 cause not changes in my tests, so i think its not related with this issue.
JoomlaCode: http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=33572&start=0
$ apache2 -v
Server version: Apache/2.4.6 (Ubuntu)
Server built: Mar 19 2014 20:56:01
$ php -v
PHP 5.5.3-1ubuntu2.2 (cli) (built: Feb 28 2014 20:06:05)
I'm also hitting same issue when trying to create categories for com_content from cli.
and getting the classic unhelpful j error:
Error displaying the error page: Application Instantiation Error: Application Instantiation Error
to reproduce just use simple JApplicationCli and michael babkers gist:
https://gist.github.com/mbabker/3211464
just change com_myextension to com_content and see that code borks in
JTableNested::store here
if (property_exists($this, '_observers'))
{
$this->_observers->doCallObservers($oldCallObservers);
}
for current project I dont need tags or content history.
I can hack around problem, but as per fastslack suggestion I'd also be pleased to see some public method to turn observers off, or some other workable solution to problem.
J 3.2.3
php 5.4.27
mysql 5.5.?
Which version of PHP are you using? I think the problem is related with this preg_replace_callback function with some PHP versions:
PHP Version 5.4.7
@vdespa - that gist from mbabker doesnt work for me with php 5.4.27 on CentOS to insert categories to com_content
but inserting to "com_myextension" (as per gist example code) works
I just needed a simple cli script to import base categories so I made temp core hack as workaround and have moved on since.
At the time I considered maybe its tags/content history related
But maybe fastslack's point could be correct:
I think the problem is related with this preg_replace_callback function with some PHP versions
in which case perhaps this SO answer is relevant?
http://stackoverflow.com/questions/11164563/preg-replace-callback-calback-inside-current-object-instance
@londoh if you try to insert categories to com_content, there it has attached the observers that cause the bug. If you use it to your own custom component, it dont has any attached observers so works without issues.
Seems that the way that is used to parse the alias is buggy for some OS or PHP versions, anyone know if there is another simple way to do that?
Labels |
Removed:
?
|
Thank you for your contribution and participation in the bug tracking process. As there has been no response to the request for further information I am closing this report at this time.
We have now moved our bug tracking process to http://issues.joomla.org/ so if you have further information that would enable this issue to be reopened please update the issue at http://issues.joomla.org/tracker/joomla-cms/3408 and it can be reopened.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2014-08-22 10:40:41 |
I encountered this issue also having these versions:
apache2 -v
Server version: Apache/2.4.7 (Ubuntu)
Server built: Jul 22 2014 14:36:38
php5 -v
PHP 5.5.9-1ubuntu4.4 (cli) (built: Sep 4 2014 06:56:34)
Joomla 3.3.6
I rewrote the code in https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/table/observer/contenthistory.php#L132 as http://stackoverflow.com/questions/11164563/preg-replace-callback-calback-inside-current-object-instance suggests to
protected function parseTypeAlias()
{
// Needed for PHP < 5.4.0 as it's not passing context $this to closure function
static::$_myTableForPregreplaceOnly = $this->table;
$this->contenthistoryHelper->typeAlias = preg_replace_callback('/{([^}]+)}/', array(get_class($this), '_preg_replace_callback'), $this->typeAliasPattern);
}
private function _preg_replace_callback($matches){
$this->table->{$matches[1]};
}
Now it's working. Maybe a patch should be made for Joomla?
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/3408.
Just wondering if it may be related to the fact that the observers are mapped in the cms.php?
I did a PR long ago to move those lines, see #1840.