Wordpress: Problem managin wp-users and the taxonomy.php file - php

I have a code to link our students users with the wp-user. It was working without problems, and creating wp users without problems, but between July 29th and June 2nd, I think some plugin have been updated and now I can't edit passwords or create useres from my php code. It looks like Wordpress is working fine but my code not.
require_once $_SERVER["DOCUMENT_ROOT"] . '/wp-load.php';
require_once $_SERVER["DOCUMENT_ROOT"] . '/wp-config.php';
require_once $_SERVER['DOCUMENT_ROOT'] . "/wp-includes/formatting.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/wp-includes/user.php";
wp_set_password($password, $id);
this code returns an error.
Fatal error: Uncaught Error: Call to a member function add_query_var() on string in /var/app/current/wordpress-beanstalk/wp-includes/class-wp-taxonomy.php:460
Stack trace:
#0 /var/.../wp-includes/taxonomy.php(441): WP_Taxonomy->add_rewrite_rules()
#1 /var/.../wp-includes/taxonomy.php(79): register_taxonomy('category', 'post', Array)
#2 /var/.../wp-settings.php(375): create_initial_taxonomies()
#3 /var/.../wp-config.php(36): require_once('/var/app/curren...')
#4 /var/.../api/wp.php(6): require_once('/var/app/curren...')
#5 /var/.../api/customers/changepassword.php(22): updateWpPassword('********', '3')
#6 {main} thrown in /var/app/current/wordpress-beanstalk/wp-includes/class-wp-taxonomy.php on line 460
Notice: is_embed was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /var/app/current/wordpress-beanstalk/wp-includes/functions.php on line 5313
Notice: is_search was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. Please see Debugging in WordPress for more information. (This message was added in version 3.1.0.) in /var/app/current/wordpress-beanstalk/wp-includes/functions.php on line 5313
I don't know what is happening, I have updated the plugins and the problem is there. I can't understand how Wordpress keep working but the code I have created calling to the wp function's is not.

The problem was related to $wp. I was overwriting that variable in mi code. The previous problem those days was a coincidence, something different and I was focusing in the wrong part of my code. Until I read the Chris Haas comentary I didn't realized that.

Related

WordPress - Fatal error: Uncaught Error: Undefined constant "SBVCGMAP_PLUGIN_VERSION"

I just moved my wordpress site from a server to my localhost to make some changes.
The websites on the server works great. But when i run it on localhost i get this.
Fatal error: Uncaught Error: Undefined constant "SBVCGMAP_PLUGIN_VERSION" in
/opt/lampp/htdocs/cruiceWP/wp-content/plugins/modeltheme-framework/inc/sb-google-
maps-vc-addon/sb-google-maps-vc-addon.php:3 Stack trace: #0
/opt/lampp/htdocs/cruiceWP/wp-content/plugins/modeltheme-framework/modeltheme-
framework.php(65): require_once() #1 /opt/lampp/htdocs/cruiceWP/wp-settings.php(409):
include_once('/opt/lampp/htdo...') #2 /opt/lampp/htdocs/cruiceWP/wp-config.php(90):
require_once('/opt/lampp/htdo...') #3 /opt/lampp/htdocs/cruiceWP/wp-load.php(50):
require_once('/opt/lampp/htdo...') #4 /opt/lampp/htdocs/cruiceWP/wp-blog-
header.php(13): require_once('/opt/lampp/htdo...') #5
/opt/lampp/htdocs/cruiceWP/index.php(17): require('/opt/lampp/htdo...') #6 {main}
thrown in /opt/lampp/htdocs/cruiceWP/wp-content/plugins/modeltheme-framework/inc/sb-
google-maps-vc-addon/sb-google-maps-vc-addon.php on line 3
Notice: is_embed was called incorrectly. The conditional functions do not work before the
query is executed. Before the basic application they give false. Please see the Debugging
in WordPress page for more information. (This message was added in version 3.1.0.) In
/opt/lampp/htdocs/cruiceWP/wp-includes/functions.php on line 5535
Notice: is_search was called incorrectly. The conditional functions do not work before
the query is executed. Before the basic application they give false. Please see the
Debugging in WordPress page for more information. (This message was added in version
3.1.0.) In /opt/lampp/htdocs/cruiceWP/wp-includes/functions.php on line 5535
This is the file that has the problem as the error message says.
sb-google-maps-vc-addon.php
<?php
#define(SBVCGMAP_PLUGIN_VERSION,'1.4'); //Plugin Version
#define(SBVCGMAP_PLUGIN_NAME, 'MT Google Maps'); //Plugin Name
#define(SBVCGMAP_PLUGIN_DIR, trim(plugin_dir_url(__FILE__), '/')); //Plugin Dir
#define(SBVCGMAP_PLUGIN_PATH, trim(plugin_dir_path(__FILE__), '/')); //Plugin Path
//Including all common functions
include('inc/functions.php');
//Including admin panel
include('admin/admin-panel.php');
//Including shortcodes
include('shortcodes.php');
Im stuck for days in this. Does anyone have any idea?
PHP constant names need to be defined as strings. Prior to PHP 8, if you passed an unquoted string, PHP would raise a warning but still treat it as a string which is why that developer included the silencing # operator.
The fix is to quote the names, and I’d remove the #, too
define('SBVCGMAP_PLUGIN_VERSION','1.4');

Fatal error: Uncaught Error: Function name must be a string (Responsive Google Maps WP Plugin - Metabox.php on line 115)

Hello fellow developers and problem-solvers,
I'm running into a PHP7 issue it seems where my code needs to be updated for:
/home/wp-theme/public_html/wp-content/plugins/responsive-google-maps/classes/MarkAdCoreClasses/Metabox.php on line 115
I did some searches and wasn't able to find this particular issue with other threads on Stack Overflow. I'm somewhat familiar with PHP, but not a guru at working with core PHP files. I'm more of a front-end/full-stack developer.
Error Shown on the sidebar: "Responsive Google Maps" WordPress Plugin
Fatal error: Uncaught Error: Function name must be a string in /home/wp-theme/public_html/wp-content/plugins/responsive-google-maps/classes/MarkAdCoreClasses/Metabox.php:115 Stack trace: #0 /home/wp-theme/public_html/wp-admin/includes/template.php(1048): ResponsiveGoogleMaps_MarkAdCoreClasses_Metabox->render_metabox_content(Object(WP_Post), Array) #1 /home/wp-theme/public_html/wp-admin/edit-form-advanced.php(696): do_meta_boxes(Object(WP_Screen), 'side', Object(WP_Post)) #2 /home/wp-theme/public_html/wp-admin/post.php(173): include('/home/wp-theme...') #3 {main} thrown in /home/wp-theme/public_html/wp-content/plugins/responsive-google-maps/classes/MarkAdCoreClasses/Metabox.php on line 115
Source code: Metabox.php on line 115
$field_output .= $this->form_fields->$field['type'](array($field, $settings['metabox_id'], $passed_values));
Much appreciated if someone can help me. Thanks in advance.
Line 115 seems to be calling a dynamic function, whose name is retrieved from the $field variable of type array within the form_fields object.
The same issue does seem to be reported on the CodeCanyon item page a few years ago here.
I would recommend redownloading the plugin and uploading it to /wp-content/plugins/ folder on the website to see if the latest update resolves the issue.
Managed to fix it, I was right about it being related to PHP7.
Change
$field_output .= $this->form_fields->$field['type'](array($field, $settings['metabox_id'], $passed_values));
to
$field_output .= $this->form_fields->{$field['type']}(array($field, $settings['metabox_id'], $passed_values));

PHP mysqli functions fatal ERROR when using the query function

I am programming a website and my current task is to save the text on a mysql server so I can login as admin and then edit the displayed text online.
I already got so far that everything works but I have done it using mysql functions. Now changed all those functions to mysqli ones, since I heard those are way better.
Here is my mysql_connect.php which I created so I could include this in the other scripts wherever I need to connect to the server:
mysql_connect.php
This is my block1_aboutme.php file, where I connect to the server and request all the text from it so I can display it on my "about me" page. This also works as intended and it properly displays the text on my page.
block1_aboutme.php
The problem is when I login as an admin a part of the login verification is this code below in my class.login.php script. As soon as I am logged in and go to my aboutme page an error occurs:
Fatal error: Uncaught Error: Call to a member function query() on unknown in C:\xampp\htdocs\mywebsites\LuPaw\admin\class.login.php:84 Stack trace: #0 C:\xampp\htdocs\mywebsites\LuPaw\admin\class.login.php(73): Login->verifyDatabase() #1 C:\xampp\htdocs\mywebsites\LuPaw\admin\class.login.php(36): Login->verifySession() #2 C:\xampp\htdocs\mywebsites\LuPaw\aboutme.php(42): Login->isLoggedIn() #3 {main} thrown inC:\xampp\htdocs\mywebsites\LuPaw\admin\class.login.php on line 84
This error refers to line 84 which is the $data = $db-> query("select stuff") function.
Somehow this does not work here, while the nearly exact same code line does work in the block1_aboutme script.
I would place the link of my 3rd script here but I can't since I don't have reputation pints yet to place 3 links in one post. Will post 3rd picture in the comments.
I already tried out a few things. If I for example echo out the "$path" it shows the correct path which means $db should be a viable variavble.
Does anyone see the problem here?
Try not to use include_once in your class method as the file will not be included if anywhere during the script execution has been already included: use include instead.
Anyway this is not the best solution you can achieve, I can suggest you to implement a DB class as a singleton and then retrieve the database instance in order to execute your queries.

CHttpException when trying to submit a form with a captcha

I'm new to the yii framework and I am trying to execute a php application in my local zwamp environment. The application works correctly in a production environnent.
The Error I receive is after filling the form and trying to submit it. The captcha doesn't validate and I get the following error in the logs:
2014/11/10 10:23:17 [error] [exception.CHttpException.404] exception 'CHttpException' with message 'The system cannot find the action « undefined » that is requested.' in D:\Users\....\web\CController.php:483
Stack trace:
#0 D:\Users\...\web\CController.php(270): CController->missingAction('undefined')
#1 D:\Users\...\web\CWebApplication.php(282): CController->run('undefined')
#2 D:\Users\...\web\CWebApplication.php(141): CWebApplication->runController('site/undefined')
#3 D:\Users\...\base\CApplication.php(180): CWebApplication->processRequest()
#4 D:\Users\....\index.php(23): CApplication->run()
#5 {main}
REQUEST_URI=/appname/site/undefined
HTTP_REFERER=http://localhost:92/appname/site/form
How can I fix this or identify which action is causing the problem?
**EDIT: problem seems to come from here : the verification code does not match the image displayed.. **
/**
* Gets the verification code.
* #param boolean $regenerate whether the verification code should be regenerated.
* #return string the verification code.
*/
public function getVerifyCode($regenerate=false)
{
if($this->fixedVerifyCode !== null)
return $this->fixedVerifyCode;
$session = Yii::app()->session;
$session->open();
$name = $this->getSessionKey();
if($session[$name] === null || $regenerate)
{
$session[$name] = $this->generateVerifyCode();
$session[$name . 'count'] = 1;
}
$message = $session[$name];
echo "<script type='text/javascript'>alert('$message');</script>";
return $session[$name];
}
what could be the issue?
Ayrad, the error message is quite ambiguous saying like, "...action « undefined ».....", in general Yii 404 errors specifies name of it (for example, "...Unable to resolve the request "ABC XYZ ...." ).
These kind of errors depend on many things, like, was engine rewrite was enabled, how is your .htacess. At least, how is your "URLManager" looks in your Config.
So, my answer is from my experience from the problem which I faced earlier. Their are some broken links in my CSS file, so I got error likes this,
[error] [exception.CHttpException.404] exception 'CHttpException' with message 'The system is unable to find the requested action "undefined".' in C:\wamp\yii\framework\web\CController.php:484
Stack trace:
#0 C:\wamp\yii\framework\web\CController.php(271): CController->missingAction('undefined')
#1 C:\wamp\yii\framework\web\CWebApplication.php(283): CController->run('undefined')
#2 C:\wamp\yii\framework\web\CWebApplication.php(142): CWebApplication->runController('site/undefined')
#3 C:\wamp\yii\framework\base\CApplication.php(162): CWebApplication->processRequest()
#4 C:\wamp\www\index.php(27): CApplication->run()
#5 {main}
REQUEST_URI=/site/undefined
HTTP_REFERER=http://localhost/site/index
I checked my main layout and find out this buggy javascript function causes that error:
$(".shortcuts").each(function(){
var cacheImage = document.createElement('img');
cacheImage.src = $(this).attr('rel');
cache.push(cacheImage);
});
It was suppose to preload shortcuts images on the bootstrap navbar. so that fixed the problem. Hope this helps. if not, please try to post extra details.
Error logs show clearly what this is about,
REQUEST_URI=/appname/site/undefined
this shows that somehow you generated a url like that and when it was trying to resolve using that, it faild (I think it's your forms url)
you have to share to view that made this form, otherwise we can't help you
If this code working correctly in production environment. Then the issue may be due to mismatch of database or main.php. I think, this error is due to not getting the site action correctly. check that, the requesting URL is given correctly.

Magento white page at front and backend

After customizing some files last week, both the back end and front end of the site I’m developing for went blank. I have already searched the internet and tried out some possible solutions, but none of them works.
Somehow I can’t manage to show any error message. I already uncommented ini_set(’display_errors’, 1);, changed error_reporting(E_ALL | E_STRICT); into error_reporting(E_ALL); and I tried even more possible solutions.
I also edited the memory to 128M, changed some settings in php.ini, changed local.xml.sample to local.xml. Nothing seems to work.
I seriously have no idea how I can solve this, so that’s why I’m here. I hope someone can help me. If you need more information, please ask, I don’t really know what’s necessary to answer my question.
After adding the following lines to index.php I managed to get error messages:
error_reporting(E_ALL);
ini_set(’display_errors’, 1);
ini_set(‘memory_limit’, ’256M’);
The error I get is:
Cannot send headers; headers already sent in /home/cheapas/public_html/index.php, line 39
Trace:
#0 /home/cheapas/public_html/lib/Zend/Controller/Response/Abstract.php(115): Zend_Controller_Response_Abstract->canSendHeaders(true)
#1 /home/cheapas/public_html/app/code/core/Mage/Core/Model/App.php(1246): Zend_Controller_Response_Abstract->setHeader(’Content-Type’, ‘text/html; char...’)
#2 /home/cheapas/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(80): Mage_Core_Model_App->getResponse()
#3 /home/cheapas/public_html/app/code/core/Mage/Core/Model/Url/Rewrite.php(204): Mage_Core_Controller_Varien_Front->getResponse()
#4 /home/cheapas/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(166): Mage_Core_Model_Url_Rewrite->rewrite()
#5 /home/cheapas/public_html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#6 /home/cheapas/public_html/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#7 /home/cheapas/public_html/index.php(91): Mage::run(’’, ‘store’)
#8 {main}
Guess what, line 39 is: ini_set(‘memory_limit’, ’256M’);
When I delete this line I get a blank page again, so that doesn’t solve anything. Does anyone have an idea on solving this? Thanks!
As you may have understood, I actually can get error messages to show when I force an error by adding an unknown or uncomplete line to my index.php. Somehow there is a problem which doesn’t want to show up.

Categories