Joomla installfile "Call to undefined method" - php

I'm rewriting a component, and I've been following
a tutorial here: http://docs.joomla.org/Managing_Component_Updates_with_Joomla!1.6_-_Part_3
In the install file code they compare the existing installed component with the new
install file's params. The code to get the installed version is this:
$oldRelease = $this->getParam('version');
When I run this, it dies with the following:
Fatal error: Call to undefined method
com_mycomponentInstallerScript::getParam()
I thought that in Joomla 1.6+ the params were accessible
automatically via the getParam?
Thanks for help.

If you look at the full script you linked to, they added a function getParam to the class. since com_mycomponentInstallerScript isn't extending an existing Joomla class, that function doesn't exist unless you define it.

Related

barryvdh/laravel-debugbar won't allow method calls in Lumen

I'm using Lumen 5.5.2, and the latest version of the laravel-debugbar package I installed via Composer.
I made the necessary changes to these files, as specified in the manual.
app/bootstrap/app.php:
+ $app->register(Barryvdh\Debugbar\LumenServiceProvider::class);
+ $app->configure('debugbar');
app/config/app.php
+ 'aliases' => ['Debugbar' => Barryvdh\Debugbar\Facade::class]
The bar displays fine, but I ran into an issue of not being able to call any methods mentioned in the manual. For example, when I try to report exceptions, using this code in app/Exceptions/Handler.php
public function report(Exception $e)
{
\Debugbar::addException($e);
parent::report($e);
}
I get the following uncaught error: Class 'Debugbar' not found in /home/vagrant/code/lumen/app/Exceptions/Handler.php on line 37.
Considering I registered the alias within my app config, I'm puzzled why Lumen is unable to get the class.
I discovered a solution on my own, provided you've set everything up properly, it's possible to set $var = app('debugbar');, and then call methods relative to $var, ex.: $var->info('Logging info...').
I'm still curious if there is a better solution.

Prestashop 1.5 Tools::getPageName error when _PS_DEBUG_PROFILING_ enabled

I am trying to tweak Prestashop productivity, but when I enable
define('_PS_DEBUG_PROFILING_', true);
i get php fatal error on all front-end pages:
Fatal error: Call to undefined method Tools::getPageName() in /override/classes/Link.php on line 32
In admin panel debug output works perfectly. I tryed to search for such an error on the community forums but failed. My Prestashop version is 1.5.5.
The Tools class doesn't have a getPageName method. You should remove the method call from the overridden Link class.
An old question, but maybe someone will need an answer.
In PrestaShop 1.5 profiling includes it's own override for Tools class (in tools/profiling). So if you have your own overriden Tools class with method getPageName() you need to change it's name or move this method to Core class.

Drupal/Wordpress Fatal error: Cannot redeclare functions - Errors keep showing

I have a drupal site and inside i have a wordpress blog like that drupal_site/wordpress_blog.
When i did the implantation all seemed to work fine but now i am getting the following error
Fatal error: Cannot redeclare timer_start() (previously declared in (path_of_mysite)/includes/bootstrap.inc:456) in (path_of_mysite)/blog/wp-includes/load.php on line 197
I have renamed the timer_start() but then i got another same error for another function.
So the problem is that drupal's functions "overrides" wp functions and renaming every wp core function not working.
Also i have tried at least the errors to not shown at my page, i have disable them from my drupal dashboard, i have tried via .htaccess,via index.php,also via phpmyadmin but this error keeps showing.
Update:I found the solution for the errors to not be shown,i just have added
error_reporting(0);
to wp-config.php.So at least there is something.
Any clue for the solution?
Drupal and Wordpress are trying to declare the same function names. To solve this type of problems PHP had introduced namespaces in PHP 5.3, more info: http://www.php.net/manual/en/language.namespaces.php, but saddly Drupal and Wordpress did not use namespaces.
My recomendation to avoid this problem is to install Drupal and Wordpress in different subdomains, so if your domain is drupal_site.com, use blog.drupal_site.com for Wordpress installation.

Fatal error: Call to undefined function: MDB2_Driver_MYSQL::getAll()

I am upgrading a site from Fedora 14, PHP4, and PEAR DB to Fedora 16, PHP 5.4 and PEAR MDB2 2.5.0b3, and I am getting the error
Fatal error: Call to undefined function: MDB2_Driver_MYSQL::getAll(). in /usr/share/php/MDB2.php on line 1892
Obviously, I've checked line 1892 of the MDB2.php file, and it contains the error reporting code for the __call magic method (allows you to call a specific function by passing it into __call)
I have checked for usages of __call, and there don't seem to be any. Likewise, when I try to find where MDB2_Driver_MYSQL is coming from, the only place it is even mentioned is in MDB2.php (as a comment about the driver for MySQL), in the class declaration (class MDB2_Driver_mysql extends MDB2_Driver_Common), and the description title in the .xml file.
I have manually included the /usr/share/php/MDB2/Extended.php file in the file where the MDB2_Driver_mysql class is defined, and that didn't help (not that this would have been a permanant fix...)
Has anyone encountered this error, and if so, what did you do to fix it? Google has proved nearly useless, as the only place it is specifically mentioned doesn't really deal with fixing it.
change getAll() in your class, to queryAll(), cause there some difference between DB & MDB2, and the same with getOne, getRow - they all changed to queryOne, queryRow. Here you can read about it http://www.phpied.com/db-2-mdb2/
Make sure you load the extended module in your code prior to making a query, similar to below:
$db->loadModule('Extended');

drupal undefined function static html with post to php

I have placed my own php file in /sites/all/modules/<myfolder> and call it via $.post(<myphppage>) from a static html page (javascript function) also in /sites/all/modules/<myfolder>.
However, the php does not appear to be executing as expected, but is getting called (access logs in Apache HTTPD show it is post'ed to).
If I try to manually request the same php page, I receive this error:
Fatal error: Call to undefined function db_insert() in /full/path/to/sites/modules/<myfolder>/<myphppage> on line x.
The echo statement I have in the php page is outputted properly above this error, and simply uses $_GET['paramname']. (And _POST, changed for testing direct request) to print a few query string parameters for debugging).
Also, when I added a call to watchdog, I receive:
Fatal error: Call to undefined function watchdog() in /full/path/to/sites/modules/<myfolder>/<myphppage> on line x.
Is it not possible to access the PHP page directly? Or is there a Drupal library I need to import? Or am I just plain missing something else with how Drupal works?
You are getting those errors about undefined functions because your PHP file is independent from Drupal and it is not bootstrapping it.
The Drupal way of doing what you are trying to do is to create a module (see Creating Drupal 7.x modules, and Creating Drupal 6.x modules) that defines a URL it handles with hook_menu(); that URL is then used with $.post().
As example of the way of bootstrapping Drupal, see the content of the index.php file that comes with every Drupal installation. (The following code is the one used from Drupal 7.)
/**
* Root directory of Drupal installation.
*/
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
The code changes from Drupal 6 to Drupal 7, but drupal_bootstrap() is defined in both Drupal versions.
The correct way is to create a module, anyway. For a list of reasons why a module should use a PHP file that bootstraps Drupal, see Are there cases where a third-party module would need to use its own file similar to xmlrp.php, cron.php, or authenticate.php?

Categories