Fatal error: Uncaught TypeError: Argument 1 passed to Mage_Core_Model_Design_Package::getPackageByUserAgent() - magento-1.9

I was getting a 500 error once I moved my magento 1.9 install from an old server to a new server. The old server was running php5 and this one is on 7. I am now getting the following error and I know I have to change some of the code, but I am not sure what:
Fatal error: Uncaught TypeError: Argument 1 passed to Mage_Core_Model_Design_Package::getPackageByUserAgent() must be of the type array, object given, called in /home1/acapps/flagstuff.com/app/code/core/Mage/Core/Model/Design/Package.php on line 576 and defined in /home1/acapps/flagstuff.com/app/code/core/Mage/Core/Model/Design/Package.php:586 Stack trace: #0 /home1/acapps/flagstuff.com/app/code/core/Mage/Core/Model/Design/Package.php(576): Mage_Core_Model_Design_Package::getPackageByUserAgent(Object(Zend_Log), 'design/theme/te...') #1 /home1/acapps/flagstuff.com/app/code/core/Mage/Core/Model/Design/Package.php(262): Mage_Core_Model_Design_Package->_checkUserAgentAgainstRegexps('design/theme/te...') #2 /home1/acapps/flagstuff.com/app/code/core/Mage/Core/Model/Design/Package.php(287): Mage_Core_Model_Design_Package->getTheme('template') #3 /home1/acapps/flagstuff.com/app/code/core/Mage/Core/Model/Design/Package.php(420): Mage_Core_Model_Design_Package->updateParamDefaults(Array) #4 /home1/acapps/flagstuff.com/app/code/core in /home1/acapps/flagstuff.com/app/code/core/Mage/Core/Model/Design/Package.php on line 586
This is the code that starts on line 586 of Package.php
public static function getPackageByUserAgent(array $rules, $regexpsConfigPath = 'path_mock')
{
foreach ($rules as $rule) {
if (!empty(self::$_regexMatchCache[$rule['regexp']][$_SERVER['HTTP_USER_AGENT']])) {
self::$_customThemeTypeCache[$regexpsConfigPath] = $rule['value'];
return $rule['value'];
}
$regexp = '/' . trim($rule['regexp'], '/') . '/';
if (#preg_match($regexp, $_SERVER['HTTP_USER_AGENT'])) {
self::$_regexMatchCache[$rule['regexp']][$_SERVER['HTTP_USER_AGENT']] = true;
self::$_customThemeTypeCache[$regexpsConfigPath] = $rule['value'];
return $rule['value'];
}
}
return false;
}

Turns out I needed to change this:
public static function getPackageByUserAgent(array $rules, $regexpsConfigPath = 'path_mock')
to this
public static function getPackageByUserAgent($rules, $regexpsConfigPath = 'path_mock')
after that, it worked like a charm

Related

An argument to be passed on the mktime built-in function in PHP. How to pass an argument in a mktime function

Actually, I was trying to run a PHP script on a local server, but unfortuantely i encountered this error
Fatal error: Uncaught ArgumentCountError: mktime() expects at least 1 argument, 0 given in C:\xampp\htdocs\SimplePharmacy-PHP\home.php:240 Stack trace: #0 C:\xampp\htdocs\SimplePharmacy-PHP\home.php(240): mktime() #1 {main} thrown in C:\xampp\htdocs\SimplePharmacy-PHP\home.php on line 240
Below is the PHP code that I was refereed to from my source code.
<?php
$Today = date('y:m:d',mktime()); // Line 238
$new = date('l, F d, Y', strtotime($Today));// Line 239
echo $new; // Line 240
?>
I am trying to disply the current date date and year

tcl/Itcl error: wrong # args: should be "itcl::class name { definition }"

I am currently learning Itcl language (based on tcl language)
and I wrote the following script.
the script is implementing a driver that should get 4 parameters and store them inside the private variables of the instance of the class
#!/bin/tclsh
package require Itcl
itcl::class driver {
# private variables
private variable bundle_id ""
private variable scope ""
private variable isSimulationModel ""
private variable isX ""
private method set_data_field {data_field_flag data_value} {
switch -- $data_field_flag {
-bundle {
set bundle_id $data_value
catch {unset bundle_id}
return
}
-scope {
set scope $data_value
catch {unset scope}
return
}
-isSimulationModel {
set isSimulationModel $data_value
catch {unset isSimulationModel}
return
}
-isX{
set isX $data_value
catch {unset isX}
return
}
}
return
}
constructor {bundle hdl_path is_simulation_model is_x} {
set_data_field -bundle $bundle
set_data_field -scope $hdl_path
set_data_field -isSimulationModel $is_simulation_model
set_data_field -isX $is_x
}
destructor {}
} #* _DRIVER_ * #
driver d 1 2 3 4
when I am trying to run it I get the following error :
wrong # args: should be "itcl::class name { definition }"
while executing "itcl::class driver {
# private variables
private variable bundle_id ""
private variable scope ""
private variable isSimulationModel ""
private v..."
(file "./driver.itcl" line 5)
can anyone help me and tell me what I did wrong that I am getting this error?
Inline comments have to begin with a semi-colon:
} ;#* _DRIVER_ * #
^
As it is right now, it looks like you are doing itcl::class driver { ... } #* _DRIVER_ * # with #* _DRIVER_ * # being 4 extra arguments (#*, _DRIVER_, * and #).
Read more about Tcl commenting on the wiki.

Sql error with drupal 7 and wamp

Okay, I've been geting this odd error whenever I am trying to do anything from flush caches to edit a block.
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 La
table 'test-site.cache_image' n'existe pas: TRUNCATE {cache_image} ;
Array ( ) in cache_clear_all() (line 167 of
C:\wamp\www\www.test-site.com\includes\cache.inc).
line 167 from cache.inc is:
function cache_clear_all($cid = NULL, $bin = NULL, $wildcard = FALSE) {
if (!isset($cid) && !isset($bin)) {
// Clear the block cache first, so stale data will
// not end up in the page cache.
if (module_exists('block')) {
cache_clear_all(NULL, 'cache_block');
}
cache_clear_all(NULL, 'cache_page');
return;
}
return _cache_get_object($bin)->clear($cid, $wildcard); *<- this is line 167*
}
Reinstalling drupal is out of the question right now. (the message from wamp is in French for some reason)

WWW::Wunderground::API Can't bless non-reference value

I would like to use module WWWW::Wunderground::API to download data with weather using JSON.
Here is my PERL script:
use WWW::Wunderground::API;
my $wun = new WWW::Wunderground::API(location=>'KIAD', api_key=>'my key');
print 'JSON source:'.$wun->json if $wun->api_type eq 'json';
It gives me an error:
Can't bless non-reference value at
/usr/local/share/perl5/Hash/AsObject.pm line 82.
I cannot fix it up. I have been trying to update cpan and other modules but it gives no results.
Could you tell me how can I repair it?
Thank you in advance
with Carp::Always:
Can't bless non-reference value at
/usr/local/share/perl5/Hash/AsObject.pm line 82
Hash::AsObject::AUTOLOAD('Hash::AsObject', undef) called at
/usr/local/share/perl5/WWW/Wunderground/API.pm line 37
WWW::Wunderground::API::update('WWW::Wunderground::API=HASH(0x1e5b178)',
'KIAD') called at /home/xyz/workspace/WeatherTest/scr.pl line 4
eval {...} called at /home/xyz/workspace/WeatherTest/scr.pl line
4
It comes from a lack of error checking. The following unexpectedly returns undef:
JSON::Any->jsonToObj($json)->{current_observation}
You might want to have a look at what's getting fetched by using the following:
use LWP::Simple qw( get );
my $api_key = 'my key';
my $location = 'KIAD';
print get("http://api.wunderground.com/api/$api_key/conditions/q/$location.json");
Perhaps there's an error message in the response you can address. For example, a bad API key would result in the following response:
{
"response": {
"version": "0.1"
,"termsofService": "http://www.wunderground.com/weather/api/d/terms.html"
,"features": {
}
,
"error": {
"type": "keynotfound"
,"description": "this key does not exist"
}
}
}

Tumblr Oauth returning 401 on API v2

I'm trying to set up an automatic tumblr post every time I add something new to my website. I'm using the following code:
$conskey = "APIKEY";
$conssec = "APISECRET";
$tumblr_blog = "blogname.tumblr.com";
$to_be_posted = "This is the text to be posted";
$oauth = new OAuth($conskey,$conssec);
$oauth->fetch("http://api.tumblr.com/v2/blog/".$tumblr_blog."/post", array('type'=>'text', 'body'=>$to_be_posted), OAUTH_HTTP_METHOD_POST);
$result = json_decode($oauth->getLastResponse());
if($result->meta->status == 200){
echo 'Success!';
}
As far as I can tell this is all formatted correctly. However this is the first time I've tried to connect up to a JSON API using Oauth so I'm not totally confident in what I'm doing.
This is the exact error I'm receiving:
Fatal error: Uncaught exception 'OAuthException' with message 'Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a redirect)' in /home/public_html/edge/tumblr.php:35 Stack trace: #0 /home/public_html/edge/tumblr.php(35): OAuth->fetch('http://api.tumb...', Array, 'POST') #1 /home/public_html/edge/index.php(95): include('/home/...') #2 {main} thrown in /home/public_html/edge/tumblr.php on line 35
Line 35 is the line beginning with $oauth->fetch.
Thanks for any help :-)
EDIT
I've solved the issue by substituting my previous code with the example on this page