Issues with Searchable Behavior and PHP 4.x.x - php

I am trying to use Searchable Behaviour hosted here: http://code.google.com/p/searchable-behaviour-for-cakephp/
To initialize the search_index table with existing data, I have used this: http://code.google.com/p/searchable-behaviour-for-cakephp/issues/detail?id=1&q=controller Reply No. 2 which creates the class SearchController.
The code was working fine on my local test server which runs PHP5.
However, the server has PHP 4 and when I tried the code on server it gives this error:
Fatal error: Cannot redeclare class searchcontroller in LONG_PATH/cake/app/models/behaviors/searchable.php on line 2
Does it really has to do something with the PHP version or have I done some logical mistake?

Not sure, but you could try my Searchable plugin instead

I just changed the name of the search Initialization controller and it worked. Looks like there is a Search Class created with Searchable behaviour.
Also, while using searchable plugin for CakePHP 4.x.x, if html_entity_decode and iconv are giving problems(as they did to me), use ut8_decode for decoding in place of html_en... and just comment out the iconv. The result may look ugly, but it works for most cases.

Related

Cakephp 3 Interacive Component Action

I change with cakephp 3.2 to a new server and this server is running php 7 instead of 5.4. Now I have an issue with my interactive way of calling an component and the needed action. What I was using is the following:
$data[$csvKnowField->field_number] = $this->Replace->$csvKnowField['imports_mapping']['component_action']($data[$csvKnowField->field_number]);
This is giving the error: Function name must be a string. As far as I can see the problem is coming from the action called because if I change it to:
$data[$csvKnowField->field_number] = $this->Replace->replaceComma($data[$csvKnowField->field_number]);
everything works fine. The variable $csvKnowField['imports_mapping']['component_action'] is holding an interactive value so the different actions can be called in the Replace component, so it would be great to keep it that way.
Is there somebody how knows an solution so the the value in the variable can be used as an interactive way?

Error when Querying Parse with PHP

I am trying to use the Parse.com SDK with PHP. I have downloaded and installed the SDK and I have successfully created a test object.
However, when trying to retrieve an object with a basic query using the sample code provided in the Parse docs and when I try to run it I get:
Fatal Error: Class 'ParseQuery' not found in /home/jameshilton/public_html/index.php on line 109
I would have guessed that it is not linking to the SDK properly but everything else is working fine.
Any ideas what I'm doing wrong?
By looking at the code of the class ParseClient in on GitHub I can see that the classes are declared in the namespace parse. So when you need an object from the Parse library you need to select the namespace. This can be done in two ways.
At the top of your file write:
use \parse;
or when instantiating the class:
$query = new \parse\ParseQuery
And remember to make sure the files are included either through an autoloader (composer?) or manually using include or require.
Regards.

Find double defined functions in PHP

I work in a php project with multiple independent developers and recently we had case where a function getmicrotime() was twice defined.
all worked fine, because they were defined in different files that were not both included in a single call ... until some refactory.
in the standardcase php would just output a fatal error, but here the output was blocked. (because a thirdparty website called a website ...) so we did not get the output, just the information that nothing worked anymore.
To the point:
Is there any method, external script, etc to check if functions with the same name are defined twice in the project?
i thought about reg. expr search, but ofcourse class methods can have the same name like a::meth1 and b:meth1 .... so its not that easy.
i am talking about a project with ~100.000 lines of ugly code ... so manual checking is not possible
Thanks in advance.
Consider static code analysis. I would suggest Sonar + PHP plugin: http://docs.codehaus.org/display/SONAR/PHP+Plugin
Here is the life example how it works:
http://nemo.sonarqube.org/dashboard/index/net.php.pear.phpcodesniffer
You can always write a simple script (i.e. perl or python) which will find all duplicates. The algorithm would be simple...

atk4 schema generator error

I get the following error when running:
class page_generator extends Page_SchemaGenerator {
}
Application Error: requires jQuery or jUI support
BaseException, code: 0
C:\projects\wamp\atk4\atk4\lib\Form\Submit.php:33
Where did you get such class? What version of ATK4 are you using?
Anyway, you have to add jUI class iun your Frontend class.
Sorry, but I couldn't remain silent and will say that - schema generators are evil !!! :)
There are only very rare case when they are OK. One of such cases is if you actually require dynamically changeable DB structure. If that's the case, then better use this add-on: https://github.com/atk4/atk4-addons/tree/master/dynamic_model
Add the following to your lib/Frontend.php
$this->add('jUI');
And as #DarkSide said - schema generators are evil.
There is also on-the-fly generator controller for model:
https://github.com/atk4/atk4-addons/tree/master/dynamic_model

CakePHP Facebook integration tutorial "Fatal error: Call to a member function share() on a non-object" [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Call to a member function on a non-object
I'm doing this tutorial here:
http://tv.cakephp.org/video/webtechnick/2011/01/12/nick_baker_--_facebook_integration_with_cakephp
I baked a new project with cake bake facebook_app and set the configuration database file to the correct settings and the default cakePHP screen showed that tmp directory was writable, DB setup was good, etc.
I downloaded the CakePHP plugin by WebTechNick here: https://github.com/webtechnick/CakePHP-Facebook-Plugin, and filled out app information (app_secret, app_id, etc), adding it to facebook_app/config/facebook.php
Changed facebook_app/app_controller.php:
class AppController extends Controller {
var $name = 'Facebook';
var $helpers = array('Session', 'Facebook.Facebook');
}
Then just exactly as in the tutorial `facebook_app/views/pages/home.ctp':
<h1>Facebook_App</h1>
<?php $this->Facebook->share(); ?>
returning the error message:
Undefined property: View::$Facebook
I realize that means PHP didn't recognize Facebook as an object. But I installed the plugin!
Also, it seems not MVCish to have something like $this->Facebook->share(); in a view (home.ctp). However, this is exactly how WebTechNick does it in his tutorial (I followed it exactly 3x) and it does not work for me. I'm a complete noob at cakePHP (although I've read the entire documentation) and I'm just trying to learn and understand through examples.
:) To be fair, it's PHP - you didn't install anything. Or if you prefer, "install" != "invoke." PHP is really amazingly easy to debug. I mean, it tells you exactly what's wrong:
Like turning to a channel that's not on the air, the error your getting means that the object you're calling doesn't actually exist, at least not in the scope you're trying to invoke it.
Is that your IDE? Is it set up for your Cake app? Are you sure the instructions were to set your AppController's $name to 'Facebook' instead of $name = Facebook_App in your AppController? It looks like you either replaced your actual app's AppController with the plugin files instead of putting them in the proper directory, or the plugin is not deferring / calling / extending / returning to the application the way it's supposed to. Knee jerk -> typo, naming conflict, path problem, permissions.
Cake's not even rendering. I can tell because your screenshot would show that error with the styled Cake errors. That tells you it's erroring before AppController class makes it to View class.
Create an instance of the Facebook object statically in the view and see what happens. Then, what does
function beforeFilter() {
parent::__construct() ?
}
get you? Anything? What about debug(), var_dump, the object functions will also shed light on what's happening. So will your logfiles.
Btw, if you don't use them already: Firefox + FirePHP + Xdebug = made of win.
I was having this problem and I found that the plugin I was using was for CakePHP 1.3 and I was using Cake 2.0. I found the BETA branch for the upgraded Cake 2.0 and it worked perfect.
Here is the Cake 2.0 BETA Branch

Categories