Error in loading drupal website call_user_func_array() - php

I'm trying to load my Drupal (6) website and I got this message:
warning: call_user_func_array()` expects parameter 1 to be a valid callback, function '_print_mail_access' not found or invalid function name in C:\wamp\www\mysite\includes\menu.inc on line 454.
The line 454 is in this function:
function ctools_menu_get_active_help() {
$output = '';
$router_path = ctools_menu_tab_root_path();
// We will always have a path unless we are on a 403 or 404.
if (!$router_path) {
return '';
}
$arg = drupal_help_arg(arg(NULL));
$empty_arg = drupal_help_arg();
foreach (module_list() as $name) {
if (module_hook($name, 'help')) {
// Lookup help for this path.
if ($help = module_invoke($name, 'help', $router_path, $arg)) {
$output .= $help ."\n";
}
// Add "more help" link on admin pages if the module provides a
// standalone help page.
if ($arg[0] == "admin" && module_exists('help') && module_invoke($name, 'help', 'admin/help#'. $arg[2], $empty_arg) && $help) {
$output .= theme("more_help_link", url('admin/help/'. $arg[2]));
}
}
}
return $output;
}
What am I doing wrong?

Related

Uncaught Error: Attempt to assign property "filename" on null

The below error message is triggered in PHP 8:
Uncaught Error: Attempt to assign property "filename" on null in
This points to this line of code:
$pluginInfo->filename = $this->pluginFile;
The whole section of code is:
$pluginInfo = null;
if ( !is_wp_error($result) && isset($result['response']['code']) && ($result['response']['code'] == 200) && !empty($result['body']) ){
$pluginInfo = PluginInfo_2_2::fromJson($result['body'], $this->debugMode);
$pluginInfo->filename = $this->pluginFile;
$pluginInfo->slug = $this->slug;
} else if ( $this->debugMode ) {
$message = sprintf("The URL %s does not point to a valid plugin metadata file. ", $url);
if ( is_wp_error($result) ) {
$message .= "WP HTTP error: " . $result->get_error_message();
} else if ( isset($result['response']['code']) ) {
$message .= "HTTP response code is " . $result['response']['code'] . " (expected: 200)";
} else {
$message .= "wp_remote_get() returned an unexpected result.";
}
trigger_error($message, E_USER_WARNING);
}
$pluginInfo = apply_filters('puc_request_info_result-'.$this->slug, $pluginInfo, $result);
return $pluginInfo;
}
Still at early stages of learning PHP, and struggling to rewrite this code for PHP 8 compatibility.
Any help would be appreciated.
Only current fix is to go back to PHP 7.4.

Codeigniter blank page - Severity: Compile Error

I have codeigniter application which working well in justhost. I am trying to transfer it to bigrock host. But in new host its not working I can only see blank page with 500 error,no error logs in cpanel. Followed many solution in stackoverflow but couldn't fix(innitioally i thought its .htaccess problem), and now I tried define environment variable to development, I can see php error which says as below
A PHP Error was encountered
Severity: Compile Error
Message: Can't use method return value in write context
Filename: models/Home_model.php
Line Number: 77
Backtrace:
Home model screen shot
login function which is in home model:
public function login($data) {
if(filter_var($data['email'], FILTER_VALIDATE_EMAIL)) {
$res = $data['email'];
}
else {
$settings = get_setting();
$pre = $settings->id_prefix;
$res = trim($data['email'],$pre);
}
$this->db->select('*');
$this->db->from('users');
$this->db->join('profiles', 'profiles.email = users.email','left');
$this->db->where('user_status','1');
$this->db->where('users.email', $res);
$this->db->or_where('matrimony_id',$res);
$chk_qry = $this->db->get();
//$chk_qry = $query->row();
//echo $this->db->last_query();die;
if ($chk_qry->num_rows() == 1) {
$pass = $this->encrypt->decode($chk_qry->row()->password);
if($data['password'] == $pass) {
$this->db->where('user_id', $chk_qry->row()->user_id);
$usr_qry = $this->db->get('profiles');
if(!empty($usr_qry->result())) {
if($usr_qry->result()[0]->profile_status != 2) {
if($usr_qry->result()[0]->profile_status != 4) {
if($usr_qry->result()[0]->profile_approval == 1) {
$status = 1;
$this->session->set_userdata('logged_in',$usr_qry->result()[0]);
$data1['date_time'] = date('Y-m-d H:i:s', time());
//$data1['user_id']=$usr_qry->result()[0]->user_id;
$data1['matrimony_id']=$usr_qry->result()[0]->matrimony_id;
$query = $this->db->where('matrimony_id',$data1['matrimony_id']);
$query = $this->db->get('active_members');
if ($query->num_rows() > 0){
$this->db->where('matrimony_id',$data1['matrimony_id']);
$this->db->update('active_members',$data1);
} else {
$this->db->insert('active_members', $data1);
}
} else { $status = 2; } // Profile Not Approved
} else { $status = 7; } // Profile Deactivated
} else { $status = 5; } // Profile Deleted or Banned
} else { $status = 6; } // No Accounts Found
} else { $status = 3; } // Ivalid Password
} else { $status = 4; } // Email not exist
return $status;
}
I wonder how this same script working fine in justhost.
Solved problem!!! silly me,
Updated php version from 5.4 to 5.6

A simple recursive function in PHP doesn't work

I'm trying to get a parent category for a given sub category using the following function in PHP.
require_once("Connection.php");
$flag=true;
function get_parent_id($cat_id, $parent_id)
{
if ($parent_id==0)
{
return($cat_id);
}
else if ($flag==true)
{
$data1=mysql_query("select parent_id from category where cat_id=" + $cat_id);
while($row = mysql_fetch_assoc($data1))
{
$parent_id=$row['parent_id'];
}
$flag = false;
}
else if ($flag==false)
{
$data2=mysql_query("select cat_id from category where cat_id=" + $parent_id);
while($row = mysql_fetch_assoc($data2)) //The warning comes from here.
{
$cat_id=$row['cat_id'];
}
$flag = true;
}
$cat_id = get_parent_id($cat_id, $parent_id);
return($cat_id);
}
}
echo get_parent_id($ed_id, $parent_id); //Call the above function.
It always prompts the following warning.
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL
result resource in C:\wamp\www\zoom\Category.php on line 492
Even though there is no error in SQL. The included file Connection.php also works fine on all other pages. I didn't understand at all why this happens.
Strings are concatenated with ., not +.
String Operators

PHP foreach invalid argument supplied

I'm trying display error messages on a form but only one is displayed (the last one always). I tried using a foreach loop but I keep getting the invalid argument error. The following displays errors one by one. Code is inside a class...
public $errorContainer = '';
// ------------------------------------------------------------
// ERROR MESSAGE PROCESSING
// ------------------------------------------------------------
private function responseMessage($respBool, $respMessage) {
$return['error'] = $respBool;
$return['msg'] = $respMessage;
if (isset($_POST['plAjax']) && $_POST['plAjax'] == true) {
echo json_encode($return);
} else {
$this->errorContainer = $respMessage;
}
}
The following always gives me the invalid for each argument error.
private function responseMessage($respBool, $respMessage) {
$return['error'] = $respBool;
$return['msg'] = $respMessage;
if (isset($_POST['plAjax']) && $_POST['plAjax'] == true) {
echo json_encode($return);
} else {
foreach ($respMessage as $value) {
$this->errorContainer = $value;
}
}
}
Thank you!
replace your foreach() with this:
private function responseMessage($respBool, $respMessage) {
// ...code...
foreach ((array) $respMessage as $value) {
$this->errorContainer .= $value;
}
// ...code---
}
Using type casting (array) above will make it works for both array and string type.
Edit:
Use this solution (type casting) only in your last effort. But your real problem is you're not passing an array to the function. See this code:
// incorrect
$msg = 'This is a message';
$this->responseMessage($some_bool, $msg);
// correct
$msg = array('This is a message');
$this->responseMessage($some_bool, $msg);
// correct
$msg = array('This is a message', 'And another message');
$this->responseMessage($some_bool, $msg);
If you pass the argument correctly like above, you don't need to cast $respMessage to array.

Custom Class not displaying echo

I have been trying to write a class to be used for displaying errors and error log.
class CError {
//Error Logging
var $Log;
public function Log($Comment, $Detail = ""){
$Log .= $Comment . "\n";
if ($Detail !== ""){
$Log .= "--" . $Detail . "--\n";
}
}
public function Clear_Log(){
$Log = "";
}
public function Display_Log(){
echo $this->Log;
}
//Error Display
var $ErrorCode = array(
0 => "0: No Error Code found, so either you got here by some rogue code or ...",
1 => "1: General Error, if you are here something went wrong",
2 => "2: Invalid information provided",
3 => "3: Alternate path taken, check message for details",
42 => "42: Here is your answer, but do you know the question?",
50 => "50: You messed with the Creepers without your Diamond Sword, didn't you",
9001 => "9001: Its over 9000... or more likely a value used was to large",
418 => "418: I'm a Teapot, found the error that drove you crazy"
);
public function Error($Error = 0, $ShowLog = false){
if ($Error === ""){
$Error = 0;
}
foreach ($ErrorCode as $key => $value){
if($key == $Error){
echo "<h3 style='color:red'>" . $value . "</h3><br />";
}
}
if($ShowLog == true){
echo $this->Log;
}
}
}
This is how I use the error class
include 'CError.php';
$Error = new CError;
$Error->Log("Email is Required");
$Error->Display_Log();
$Error->Error(2,true);
The problem is, nothing is displayed when used. It is skipped I think but not sure. I do not have access to the error logs for the server so I do not know if an error is being produced or not but the code will run through to the exit points in my main code(irrelevant to the class)
--EDIT--
The answers that tell to change $Log with $this->Log has fixed the issue with the $Log variable. It still has not fixed the issue with the error code array being displayed in the foreach loop.
--EDIT--
I solved the issue by adding $this->ErrorCode to the foreach loop.
You need to access class variable like $this->Log() in Log and Clear_Log() functions.
Try:
public function Log($Comment, $Detail = ""){
$this->Log .= $Comment . "\n";
if ($Detail !== ""){
$this->Log .= "--" . $Detail . "--\n";
}
}
public function Clear_Log(){
$this->Log = "";
}
You should modify $this->Log in methods Log and Clear_Log, like you access it in Display_Log. And you just access a local variable.
you're using the name Log for both function as well as variable. try changing the name for any one.

Categories