Swagger-php: How to enable verbose to check excluded directories? - php

Using Swagger-php and the following command, how can I make it show the folders/files it searches so that I can check my excudes actually work?
$openapi = \OpenApi\scan('./myfolder', [
'exclude' => ['/vendor/', '/node_modules/', '/migrations/'],
]);

There is currently no code in swagger-php to log each filename being processed. It's a good idea though... https://github.com/zircote/swagger-php/issues/1410
As a one-off you could just manually add logging around line 492 in \OpenApi\Generator.php

Related

How do I start the process of debugging raw php code from a Wordpress site after an update?

I need to debug some errors and formatting within a professional wordpress site. I need to do the debugging from the raw code. It is mostly php and JS. I have ended up with more than 2million lines of code after the most recent update. There are some empty box space on the home page and a list of bugs from the WP_DEBUG log.
This is my first time working with Wordpress at all. I am overwhelmed by the amount of code, and can't figure out where any of the bugs and issues are. I have worked with Angular Typescript in the past.
I would assume, to an extent, that some of these issues would be able to be fixed within the 'drag and drop' API of wordpress, but I have no idea how to use that either, when there is an already several million lined website code, and like I said, I was given the raw php code of over 2 mil lines to debug with.
I have been using VS code for the editor and MAMP as a live server.
I have no idea where to start, and I have not been able to find any useful tutorials online. Any help is greatly appreciated. I could really just use some guidance on how this process might work. Or if it even is something that people do, ever. It looks like according to the internet, this may not be the way to go about debugging. Feel free to ask questions I'll try to answer anything I can without giving away any confidential info.
Here are the bugs that show up on the site from WP_Debug:
Warning: preg_match(): No ending delimiter '*' found in C:\repos\website\wp-content\mu-plugins\no-cache.php on line 8
Warning: preg_match(): Empty regular expression in C:\repos\website\wp-content\mu-plugins\no-cache.php on line 8
Notice: Trying to get property 'Location' of non-object in C:\repos\website\wp-content\themes\Child-Theme\functions.php on line 45
Notice: Trying to get property 'Subrole' of non-object in C:\repos\website\wp-content\themes\Child-Theme\functions.php on line 46
Update: I am still having issues with these same errors. I am looking for assistance on how the process of debugging raw WP php code works, and if I am trying the right things. I can provide the code that a few errors are pointing to, but I do have to adjust the variables to maintain confidentiality.
\Child-Theme\functions.php (35-50):
if(class_exists(\RoleList\RoleList::class)) {
wp_localize_script('site-name', 'SiteName', [
'RoleList' => [
'categories' => $role_categories,
'locations' => \RoleList\Categories::getLocations(),
'category_counts' => \RoleList\Listings::getCategoryCounts(),
],
'CurrentRole' => [
'is_role_page' => ($listing ? true : false),
'current_category' => ($current_category ? $current_category : null),
'current_location' => ($listing->Location ? $listing->Location : null),
'current_subrole' => ($listing->Subrole ? $listing->Subrole : null),
'home_url' => home_url(),
]
]);
}

How to add comments to each forum post in yii, using bbii forum module and comments-module

I am using Yii bbii forum module and it works fine. But now I want to add comments-module so every forum post could be seperately commented.
At the begining it might look:
I followed instruction what is here, but I can't make it work :(
And why I even need to include this file, if I want to add just comment?
When I added the same widget to user page (just for testing) - I got "This item cann't be commentable" and it's fine because probably I don't have correct configuration in main.php.
Difference between widget in user model view and forum view is data passed in it.
Here:
public function actionPostComment()
{
if(isset($_POST['Comment']) && Yii::app()->request->isAjaxRequest)
{
$comment = new Comment();
$comment->attributes = $_POST['Comment'];
var_dump($comment);
var_dump returned this when tried to submit comment in forum, and here in user view page.
And probably it is not even possible to combine these to modules? I'm really new in Yii.
Updated:
Basically what I have done is:
exstracted comment module (under protected->modules)
in main.php (under protected->config) added all cofiguration in modules array:
'comments'=>array(
//you may override default config for all connecting models
'defaultModelConfig' => array(
//only registered users can post comments
'registeredOnly' => false,
'useCaptcha' => false,
.......
and in view file _post.php added following:
<?php $this->widget('comments.widgets.ECommentsListWidget', array(
'model' => $data,
));
and var_dump($data) gives this (when this is called in controller where post is reseaved).
An error message was given here:
include(BbiiPost.php): failed to open stream: No such file or directory
You said that the Bbii was working with Yii and it broke when you tried to add comments.
The links to your var_dump files are broken, but I did try to read them ;)
It looks like the comments module is interfering with the POST path so that when the form submission comes in it is in a different path from the root which is confusing the YiiBase's autoloader.
You could try explicitly adding the path to BbiiPost.php to the autoloader's search path, or finding where the include("BbiiPost.php") line is and changing it to an absolute path.
Another possibility is that the forum page you are on has links to add comments but the page routing has not been taken from the route. So it might be that the POST link to the comments is actually at /forum/123/comment/add instead of just /comment/add. So when the form is submitted it is trying to the comments/add controller/action but finding that it is in /forum/view and getting confused about the paths to the include files.
I have generally found that the instructions on the Yii (v1) [v2 docs are much better] site for these modules is flaky at best. Quite often the source download link on the page points to an old buggy version of the code as the project has usually moved somewhere else. You generally need to have a pretty good PHP/Yii knowledge to debug these user-submitted modules and get them working.

Message on Wordpress site after upgrading PHP

I have upgraded the server to PHP 5.3 recently and I just noticed that one of the sites that uses wordpress has this message appeared at the top of every pages.
. // // Alexey A.Znayev, znaeff#mail.ru, http://xbsoft.org,
http://xbsoft.ru //
///////////////////////////////////////////////////////////////////////////
// This file contains public class DNSBL // This class performs IP
address check in spam blocking lists as described // on
http://ru.wikipedia.org/wiki/RBL class DNSBL { private $_aCheckers =
array( // list of checkers available for individual checking
'spamhaus' => array('.zen.spamhaus.org', true), //available for group
checking with 'all' key 'spamcop' => array('.bl.spamcop.net',
true), //available for group checking with 'all' key 'dsbl' =>
array('.list.dsbl.org', false), //not available for group checking
with 'all' key 'ordb' => array('.relays.ordb.org', false), //not
available for group checking with 'all' key 'sorbs' =>
array('.dnsbl.sorbs.net', false), //not available for group checking
with 'all' key 'njabl' => array('.dnsbl.njabl.org', false) //not
available for group checking with 'all' key ); // AZ - 1. Key 'all' is
illegal // AZ - 2. Most of spammer IP addresses is ...........
The other sites that use Drupal, Magento, & Symfony don't have a problem.
Any idea?
Thanks.
hc.
First, make sure that your server is still executing PHP. For that, just create a simple php page with this : <?php phpinfo(); ?> and call it from your browser. If you see all your server's information, it's fine. If you see nothing, there's a problem with your server. (don't forget to remove the file as it gives a lot of information on your server)
If the phpinfo thing works, I would make a search on all files on this site to find one of the sentence. For example, use a tool to search for "array('.bl.spamcop.net', true)" in all the files. If you find it, please post the content here.
Do you use Linux for your site? Do you have a copy of your Website on your computer? Can you connect remotely to your computer through a shell or something similar? (sorry, can't use the comment feature because of my low rep)
Edit : Like "nevermind" said, check the file with the name DNSBL.php. It looks like something to prevent spam. Maybe you have a security plugin of some sort?
If you have Linux on your server and have a shell access, you can issue this command to find the file:
find / -name 'DNSBL.php'
Edit #2 : The file you found should look like this (the first lines) :
<?
///////////////////////////////////////////////////////////////////////////
//
// DNSBL - Spam IP address checker.
// Copyright (C) 2011 Alexey A.Znayev
From what you copied in your question, it looks like everything is missing until "Alexey A.Znavev".
If the file is fine, check the source code of one of the the page that displays the text on your site (ctrl+u on most browsers). What do you see in it? Is there more "weird" stuff at the beginning of the page?

Need a help on logs with codeigniter?

I have used codeigniter framework.Have used its log part.
I had a query regarding configuring logs in the application.
As per the documentation they say that we can configure in app/config/php and filter the logs as debug,error or info messages.
But even after doing that, I am not able to filter the logs.
Wanted to know the reason for this or am i missing something.
Help would be highly appreciated.
You need to follow the following steps to keep log file.
Change the following line of your application/config/config.php file
$config['log_threshold'] = 4;
instead of
$config['log_threshold'] = 0;
This change will produce a log file in your application/logs directory with current date as file name.
Now if you want to write your custom log in this log file then write the following code:
log_message('ERROR','YOUR_MESSAGE_HERE');
Here you can use 'ERROR', 'DEBUG' etc.
Hope this will help you.

How to create image with magento api

I'm trying to use the magento api to create an image, but it's failing with the message
SoapFault exception: [104] Cannot create image.
This is not a helpful error message! What does this mean? Why is it doing this? How do I create an image, using the magento api?
This is my code:
$client = new SoapClient($wsdlurl);
$sessionId = $client->login($user, $key);
$file = array(
'content' =>
base64_encode(file_get_contents($filename)),
'mime' => 'image/jpeg',
'name' => 'newfile.jpg'
);
$result = $client->call(
$sessionId,
'catalog_product_attribute_media.create',
array(
$productId,
array('file'=>$file, 'label'=>'new_test_label', 'position'=>'100', 'types'=>array('thumbnail'), 'exclude'=>0)
)
);
What am I doing wrong?
I found the solution. The directory it was trying to put the image in (.../media/catalog/product/) did not have permissions set to allow new folders to be created in it.
For the benefit of others, though, I did find a couple of useful things:
First, filesystem operations are carried out by ./lib/Varien/Io/File.php, which has it's own wrappers for cd, mkdir, etc, which throw really vague exceptions if they fail.
The directory creation was occurring in Mage_Catalog_Model_Product_Attribute_Backend_Media->_moveImageFromTmp
which was called from ./app/code/core/Mage/Catalog/Model/Product/Attribute/Media/Api.php
which handles all the image api calls, e.g. create, update, remove, etc.
So, if you have the same problem and it's not a permissions issue... you now know where to put your debug code ;).
Oh yeah, and if you want to output an error message, you can't just echo or die; you need to throw an exception, which will get caught by Mage_Catalog_Model_Product_Attribute_Media_Api, which will then call $this->_fault to send it to the client.
I just wanted to add some other relevant information to this - and thanks Benubird for your comments, they were very helpful. I was trying to upload images via the API and was getting the "Cannot create image" message.
After diving deep into Magento I found that if you have a memory limit in your php.ini file of -1 then this PREVENTS any image from being uploaded. In the Magento core there is a check made before the image is attempted to be dealt with (lib/Varien/Image/Adapter/Gd2.php line 57) where the size of the image is compared to the available memory. It does not take into account a value of -1 meaning unlimited and throws a "Memory limit has been reached" exception.
The fix for this is to set your memory_limit value to a non-negative number. The correct fix for this is for the Magento code to handle this properly (although if imagecreatefromjpeg dies with a non-catchable error then maybe it's not possible).
Good luck!

Categories